开发者

Mac OS. How to create image from PNG data?

开发者 https://www.devze.com 2022-12-19 04:50 出处:网络
I have an array of data that repres开发者_运维技巧ents PNG: unsigned short systemFontTexture[] = {

I have an array of data that repres开发者_运维技巧ents 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 PNG file using this data? If yes, then HOW?


Create a data provider to serve up the data, and then create an image with the data provider.


create a graphics context for an image and draw onto it. then save to png

Create a CGBitmapContext

draw your pixels

create a create a CGImage from from the CGBitmapContext

save the CGImage as PNG using CGImageDestination


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

0

精彩评论

暂无评论...
验证码 换一张
取 消