English 中文(简体)
* 前往国家统计局在UIImage展示 观点
原标题:char * to NSData to display in UIImageView

I am getting image data in form of char * (stored on sql server). I want to convert those data to NSData to display image in UIImage view. char * data is a bytearray for source image. how can i convert char * to NSData to display to get an UIImage instance for displaying in UIImageView?

感谢。

问题回答

鉴于:

unsigned char *myImageData;
NSUInteger myImageDataLength;

myImageData 是JPEG、PNG或其他一些UIImage支持格式的图像时,使用:

-(UIImage*)myImage {
    return [UIImage imageWithData:[NSData dataWithBytes:myImageData length:myImageDataLength]];
}

如果你的果园数据为基准64,请登录。 http://www.cocoadev.com/index.pl?BaseSixtyFour

我用网络服务的数据和图像来做这项工作。 例如:

// Note hex = ".PNG..", the start of the PNG header.
static unsigned char myImageData[] = { 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a,... };  

长度是图像档案尺寸,从图像档案中可以生成下列面值:

hexdump -e   16/1 "0x%02x, " "
"  MyImage.png




相关问题
Code sign Error

I have created a new iPhone application.I have two mach machines. I have created the certificate for running application in iPhone in one mac. Can I use the other mac for running the application in ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

将音频Clips从Peter改为服务器

我不禁要问,那里是否有任何实例表明从Peit向服务器发送音响。 I m不关心电话或SIP风格的解决办法,只是一个简单的袖珍流程......

• 如何将搜查线重新定位?

我正试图把图像放在搜索条左边。 但是,问题始于这里,搜索条线不能重新布署。

热门标签