Chad Carisch
Chad Carisch

Reputation: 2472

multi-dimension array to image

if i had a 5 X 5 multidimensional-array, where all values would be ether 0 or 1, would there be a way to generate a 5 X 5 pixel image where 1 was black and 0 was white?

i would like to do this in c.

the output image type would not matter.

--Thanks

chad

Upvotes: 0

Views: 158

Answers (2)

khachik
khachik

Reputation: 28703

If the output type does not matter, just generate it in raw format, for each 1 write three bytes 255 to the output (binary) file, for each 0 write three 0 bytes.

Upvotes: 0

Dov Grobgeld
Dov Grobgeld

Reputation: 4983

If the array is 5x5 then it is 2-dimensional which is more specific than calling it multi-dimensional.

Read up on the pbm or the pgm image formats. They are very easy to use and they are easily output by your program.

Upvotes: 1

Related Questions