Simple class to convert UIImage objects to bitmap arrays (RGBA8)
Objective-C C
Permalink
Failed to load latest commit information.
ImageConversion.xcodeproj
Shared
iPad
iPhone Added xcode project adn files Sep 22, 2010
.gitignore Updated gitignore for Xcode4. Apr 7, 2011
GraphicsCommon.h
GraphicsCommon.m Fixed a bug with the transparency not being preserved when converting… Aug 24, 2011
ImageConversion-Info.plist Added xcode project adn files Sep 22, 2010
ImageConversion_Prefix.pch Added xcode project adn files Sep 22, 2010
ImageHelper.h
ImageHelper.m Fixed a bug with the transparency not being preserved when converting… Aug 24, 2011
MITLicense.txt updated license date Apr 7, 2011
README Updated the Readme Sep 22, 2010

README

UIImage Conversion Sample
-------------------------
Paul Solt 2010

Here's a sample project and code to convert between UIImage objects and RGBA8 bitmaps. The sample project is iPhone 4/iPad 3.2 compatible. 

The ImageHelper works with iPhone 4 and the Retina display using the correct scale factor with high resolution images.


Basic Example Usage showing the ability to convert back and forth between formats: 
---------------------------------------------------------------------------------

// Look at the sample project for actual usage

	NSString *path = (NSString*)[[NSBundle mainBundle] pathForResource:@"Icon4" ofType:@"png"];
	UIImage *image = [UIImage imageWithContentsOfFile:path]; 
	int width = image.size.width;
	int height = image.size.height;
	
	// Create a bitmap
	unsigned char *bitmap = [ImageHelper convertUIImageToBitmapRGBA8:image];
	
	// Create a UIImage using the bitmap
	UIImage *imageCopy = [ImageHelper convertBitmapRGBA8ToUIImage:bitmap withWidth:width withHeight:height];
	
	// Display the image copy on the GUI
	UIImageView *imageView = [[UIImageView alloc] initWithImage:imageCopy];

	// Cleanup
	free(bitmap);