Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ranjimagi

macrumors newbie
Original poster
Nov 25, 2009
2
0
Hi,
I need to know is there is a way to convert a JPEG image to Byte array and byte array to JPEG image.I need to know how to do in iphone application.Thanks in advance.
 
To read an image from file you can use CGImageSourceCreateWithURL() which will give you CGImageRefs. You can get the image data via CGImageGetDataProvider(). If you need to convert to another data format, use a CGBitmapContext. UIImageJPEGRepresentation() can be used to get the JPEG data from a UIImage/CGImageRef.
 
convert jpec image to byte array

Hi,
Thanks for your reply....

At present we are reading an image from resource file.We r using the following code
Code:
CGRect myImageRect = CGRectMake(0.0f, 0.0f, 300.0f, 250.0f);
	UIImageView *imageview = [[UIImageView alloc] initWithFrame:myImageRect];
	[imageview setImage:[UIImage imageNamed:@"image1.jpg"]];
	imageview.opaque = YES; // explicitly opaque for performance
	[self.view addSubview:imageview];
Now we can display the image.But we want convert that image to Byte array.Then again convert Byte array to Image.Then finally to display that image.Actually i am new in iPhone developing.i tried.But i didn't get.i hope u will give better idea regarding this...

Thanks
vijayalakshmi
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.