Re: [GD-DEVEL] Need som help writing raw data to a jpg
| From: | Pierre | Date: | Wed, 08 Nov 2006 23:41:17 +0000 |
| Subject: | Re: [GD-DEVEL] Need som help writing raw data to a jpg | ||
| References: | 1 | Groups: | php.gd.devel |
| Request: | Send a blank email to php-gd-devel+get-18@lists.php.net to get a copy of this message | ||
Hello Tomas,
On 11/8/06, Tomas Zajc <tzajc@conae.gov.ar> wrote:
I'm just starting using libgd and I wold need some help. I'm trying to make a program that should be able to write some raw data I've got on a float pointer to a jpg file. I couldn't find the correct way to do it looking at the examples on the gd page. so long I gotIf you target format, I suggest you to use gdImageCreateTrueColor. This format has "unlimited" colors. The question is what represent the float values. For the example here, I will suppose you get a two dimensional array and assign the float value to each channel, red, green and blue. im = gdImageCreateTrueColor(outsamples, outlines); for (y = 0; y < outlines; y++) { for (x = 0; x < outsamples; x++) {im = gdImageCreate(outsamples, outlines); black = gdImageColorAllocate(im, 0, 0, 0); white = gdImageColorAllocate(im, 255, 255, 255);if((quick=fopen(argv[2], "wb"))==NULL) { printf("No se pudo abrir el jpg archivo de salida %s\n", argv[2]); return 2; } gdImageJpeg(im, quick, 70);but I cant put my data into the im pointer. I I'm not sure which function should I use to do it. I tried: gdImageCreateFromJpegPtr(int size, void *data) withpout any help. I'm now starting to doubt if gd can do such thing. Any sugestion?
gdImageSetPixel(im, gdTrueColor(val,val,val));} } /* Save the image */ gdTrueColor function simply creates the 24bit RGB value (no alpha used here) using the float value. gdImageSetPixel put this value at the position (x,y) in the image buffer. I hope I answered your question, please feel free to ask further informations or optimizations. --Pierre