0

I have an array of integers. Each int represents a pixel and has ARGB information. I also know the width and height of the image.

How can I turn these informations into an image?

It's an IOS app and I'm only going to display the image onscreen, no need to save it. I'm going to create one image per frame.

HSNN
  • 531
  • 1
  • 6
  • 14

2 Answers2

0

Depends on what type of image you want to create. PPM for example if you have the RGB values you just specify the image type in the header. So you would create an empty file, open it for I/O then write something like this

P6

width height 255

rgbrgbrgbrgb

The problem is not all images are created this way. So I suppose the question is what type of image do you want to create? You will need to write the file differently for each file type you will support.

Popeye
  • 11,839
  • 9
  • 58
  • 91
  • I'm only going to display the image onscreen, no need to save it. I'm going to create one image per frame. – HSNN Dec 10 '13 at 19:39
0

Assuming you are developing for iOS, I would try to join this: How can I make an UIImage programatically?

With this: iPhone : How to change color of particular pixel of a UIImage?

Hope this places you on the right track.

Community
  • 1
  • 1
paulonogueira
  • 2,684
  • 2
  • 18
  • 31
  • Mixing them together might do the trick, but I wonder if there's a better way to do it performance wise. I will be doing this every frame. – HSNN Dec 10 '13 at 20:01
  • Check the accepted answer on this question: http://stackoverflow.com/questions/11860830/byte-array-to-nsdata – paulonogueira Dec 10 '13 at 20:07