-1
您好我正在激发一个交易,但由事务结果一个结果来作为blob属性,即图像,我想改变该blob属性为图像 我为那个“图标”是从交易中取图像的关键, 所以请帮我看看这个, 图像打印为零, 为什么?Blob图像转换
NSString *inputString = [[[self formModel] attributeAsString:@"icon"] description];
NSLog(@"icon is %@",[[self formModel] attributeAsString:@"icon"]);
NSLog(@"inputstring is %@",inputString);
//NSImage *image = [NSUnarchiver unarchiveObjectWithData:[[self formModel] attributeAsString:@"icon"]];
// NSLog(@“image is%@”,image);
NSArray *words = [inputString componentsSeparatedByString:@" "];
NSLog(@"words is %@",words);
NSArray *sizes = [words valueForKey:@"length"];
int sizeOfBytes = 0;
for (NSNumber *size in sizes) {
sizeOfBytes += [size intValue]/2;
}
int bytes[sizeOfBytes];
int counts = 0;
for (NSString *word in words) {
// convert each word from string to int
NSMutableString *ostr = [NSMutableString stringWithCapacity:[word length]];
while ([word length] > 0) {
[ostr appendFormat:@"%@", [word substringFromIndex:[word length] - 2]];
word = [word substringToIndex:[word length] - 2];
}
NSScanner *scaner = [NSScanner scannerWithString:ostr];
unsigned int val;
[scaner scanHexInt:&val];
bytes[counts] = val;
counts++;
}
// get NSData form c array
NSData *data = [NSData dataWithBytes:bytes length:sizeOfBytes];
NSLog(@"My NSDATA %@",data);
NSImage *Image = [[NSImage alloc] initWithData:data];