Mac OS How to create an image from PNG data?

I have a data array representing PNG:

unsigned short systemFontTexture[] = {

...
0x5089,0x474E,0x0A0D,0x5089,0x474E,0x0A0D,0x5089,
0x474E,0x0A0D,0x5089,0x474E,0x474E,0x0A0D,0x5089,
0x474E,0x0A0D,0x5089,0x474E,0x474E,0x0A0D,0x5089,
...

}

Can I create a PNG file using this data? If yes, then HOW?

+3
source share
3 answers

Create a graphic context for the image and draw it. then save to png

Create CGBitmapContext

draw pixels

create CGImage creation from CGBitmapContext

save CGImage as PNG using CGImageDestination

+2
source

really close, just use the stream to save your array as "picture.png". If your hex is correct and you have an 8-byte signature before the pixels, it should work.

0
source

Source: https://habr.com/ru/post/1731174/


All Articles