Forum Moderators: coopster

Message Too Old, No Replies

creating an image from an array of raw data

can the GD library do this?

         

dhiggerdhigger

6:00 pm on May 17, 2004 (gmt 0)

10+ Year Member



I have an array of numbers (which I shall be manipulating server-side), which I wish to convert into an image. The elements of the array are essentially the 1D subscripts of a 256*256 image.
I've been looking at the GD library functions all day, but I can't seem to translate the array to a jpeg or png or whatever. (The GD library functions are working though.) It seems that creating an image from another image is easy, but not from the raw data.

How can I make a greyscale image out of this array, scaled to the maximum pixel?

Thanks
Dave Higgins
PHP 4.3.4, Apache(Unix)1.3.22, GD 2.0.15

jatar_k

6:25 pm on May 17, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



hmmm, I would think this could be done

not sure which function would work best though.

I am still reading but this is my best thought so far
[ca.php.net...]

dhiggerdhigger

8:34 am on May 18, 2004 (gmt 0)

10+ Year Member



I wondered about imagecreatefromstring, but I don't fully understand the command. I tried imagecreateing an image and then taking the data from my raw data array by referencing subscripts one at a time, and imagesetpixeling each pixel of the new image. But I never managed to get a jpeg in my browser to show any data (i.e. the jpeg loaded ok, but it was just black, like we get from imagecreate).

I wondered if the data was in there but that it was a scaling issue, but I don't really know. This is where I got confused and headed for the forum.

Using imagecreatefromstring would seem prefereable, if this can be accomplished without nested for loops!

Any help is greatly appreciated :)
Dave Higgins