forked from PaulSolt/UIImage-Conversion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME
30 lines (20 loc) · 1.12 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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);