我在vb中有一段代码.我需要将字节数组转换为base 64字符串.以下是vb代码.
如果arrLicence.Count> 0则
LicenceBytes = CType(Array.CreateInstance(GetType(Byte),6),Byte())
Run Code Online (Sandbox Code Playgroud)LicenceBytes(0) = Convert.ToByte(arrLicence(0).ToString(), 16) LicenceBytes(1) = Convert.ToByte(arrLicence(1).ToString(), 16) LicenceBytes(2) = Convert.ToByte(arrLicence(2).ToString(), 16) LicenceBytes(3) = Convert.ToByte(arrLicence(3).ToString(), 16) LicenceBytes(4) = Convert.ToByte(arrLicence(4).ToString(), 16) LicenceBytes(5) = Convert.ToByte(arrLicence(5).ToString(), 16) LicenceString = Convert.ToBase64String(LicenceBytes) '6 byteArray - passed by the user - Base64Encoded
我需要它在iphone中的等价物.我试过NSData和base64转换,但结果推迟.
我用这个链接进行转换. http://www.cocoadev.com/index.pl?BaseSixtyFour
我尝试使用创建单个字节memcpy然后创建一个数组,但没有成功.
我试过的内容如下:
NSData *d1 =[@"64" dataUsingEncoding:NSUTF16StringEncoding];
NSData *d2 = [@"37" dataUsingEncoding:NSUTF16StringEncoding];
NSData *d3 = [@"81" dataUsingEncoding:NSUTF16StringEncoding];
NSData *d4 = [@"d4" dataUsingEncoding:NSUTF16StringEncoding];
unsigned char *buffer = (unsigned char*)malloc(8);
buffer[0] = [d1 bytes] ; …Run Code Online (Sandbox Code Playgroud) 我再次提出两个相互关联的问题
阴影创造不均匀.它们在某些方面变暗我正在添加我用来绘制线条的代码..
for (int i=0; i<[currentPath count]; i++)
{
CGPoint mid1 = [[self midPoint:[currentPath objectAtIndex:i+1] :[currentPath objectAtIndex:i]] CGPointValue];
CGPoint mid2 = [[self midPoint:[currentPath objectAtIndex:i+2] :[currentPath objectAtIndex:i+1]] CGPointValue];
CGContextMoveToPoint(context, mid1.x, mid1.y);
CGContextAddQuadCurveToPoint(context, [[currentPath objectAtIndex:i+1] CGPointValue].x, [[currentPath objectAtIndex:i+1] CGPointValue].y, mid2.x, mid2.y);
CGContextSetShadow(context, CGSizeMake(-2, -2), 3);
CGContextSetLineCap(context, kCGLineCapRound);
CGContextSetStrokeColorWithColor(context,[color CGColor]);
CGContextSetLineWidth(context, linewidth);
CGContextStrokePath(context);
i+=2;
}
Run Code Online (Sandbox Code Playgroud) 我试图从unsigned char*中的原始数据创建一个新的Image.我从存储的数据中获得每像素位数.我尝试将原始数据转换为NSData,但结果图像为零,
unsigned char*bitmap = myData;
NSUInteger myImageDataLength = strlen((const char*)bitmap);
NSData*d = [NSData dataWithBytes:位图长度:myImageDataLength];
imgView.image = [UIImage imageWithData:d];
然后我尝试使用上下文来创建一个图像,如下所示:
CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB();
int width = mWidth;
int height = mHeight;
size_t bpp = mBpp;
size_t bpc = 8;
size_t bpr = (width * 4);
CGContextRef context = CGBitmapContextCreate(bitmap, width, height, 8, bpr, colorspace, kCGImageAlphaNone);
CGImageRef cgImage = nil;
if (context != nil) {
cgImage = CGBitmapContextCreateImage (context);
CGContextRelease(context);
}
CGColorSpaceRelease(colorspace);
UIImage *newImage = [UIImage imageWithCGImage:cgImage];
Run Code Online (Sandbox Code Playgroud)
我收到一条错误信息
<Error>: CGBitmapContextCreate: …
这是我的代码.X轴标签未显示.我正在使用核心情节.
scatterGraph = [[CPXYGraph alloc] initWithFrame:CGRectZero];
CPTheme *theme = nil;
[scatterGraph applyTheme:theme];
hostView.hostedGraph = scatterGraph;
hostView.backgroundColor = [UIColor clearColor];
hostView.collapsesLayers = NO;
scatterGraph.paddingTop = 25.0;
scatterGraph.paddingRight = 25.0;
scatterGraph.paddingLeft = 25.0;
scatterGraph.paddingBottom = 25;
scatterGraph.plotAreaFrame.masksToBorder = NO;
CPXYPlotSpace *scatterPlot = (CPXYPlotSpace *) scatterGraph.defaultPlotSpace;
scatterPlot.xRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromFloat(0.0) length:CPDecimalFromInt(yCount)];
float xx = [self findMax:LivePriceFeedArray] - [self findMin:LivePriceFeedArray]+1.0;
scatterPlot.yRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromFloat([self findMin:LivePriceFeedArray]-0.5) length:CPDecimalFromFloat(xx)];
CPXYAxisSet *axisSet =(CPXYAxisSet *) scatterGraph.axisSet;
CPXYAxis *xAxis = axisSet.xAxis;
axisSet.delegate = self;
xAxis.title = @"Days";
xAxis.titleLocation = CPDecimalFromFloat(4.0f); …Run Code Online (Sandbox Code Playgroud)