1

Within an SDK that I'm using within one of my apps there are some images. These images are not just listed as image files but as hexedecimal encoded strings like:

unsigned char MASTCloseButton_png[] = {
  0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
  0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x38,
  0x08, 0x06, 0x00, 0x00, 0x00, 0xa8, 0x86, 0x3b, 0x1e, 0x00, 0x00, 0x00,
  0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x2e, 0x23, 0x00, 0x00, 0x2e,
  0x23, 0x01, 0x78, 0xa5, 0x3f, 0x76, 0x00, 0x00, 0x0a, 0x4d, 0x69, 0x43,
};

No I'd like to adjust this image within this SDK but unfortunately I don't know how to convert my .png file into a hexadecimal string as listed above.

Are there any tools to convert my .png image (with transparency) to a hexadecimal string?

BarryK88
  • 1,806
  • 2
  • 25
  • 41

1 Answers1

1

Try with following code:

NSData *imageData = [[NSData alloc]initWithData:UIImagePNGRepresentation(myImage.image)];
NSString *imageStr = [GTMBase64 stringByEncodingData:imageData];

OR follow:

http://kelp.phate.org/2012/05/high-performance-hex-encode-in.html

Nimantha
  • 6,405
  • 6
  • 28
  • 69
iPatel
  • 46,010
  • 16
  • 115
  • 137
  • http://stackoverflow.com/questions/12309158/objective-c-how-to-properly-encode-hex-to-image-file – iPatel Jul 17 '13 at 14:44