Click to See Complete Forum and Search --> : write as JPEG


taurean
May 17th, 2004, 06:31 PM
Hi,

i've a RGBA array and would like to output it as a JPEG. how do i do that.....any input is appreciated.

~ Matt

yiannakop
May 18th, 2004, 10:28 AM
I think (but I am not sure) that JPEG format does not support transparency, so you will have to forget about the alpha channel. Though, you could transform RGBA array to RGB and then save the RGB values in a jpeg file.
I don't know if there is a ready function for jpeg I/O in Visual C++, but I found this (http://www.smalleranimals.com/jpegfile.htm) link that gives free code for writing and reading jpeg files in C++.
(I am sure that there are standard functions in Java for this purpose, but I suppose you use Visual C++)
Regards,
Theodore.

yiannakop
May 18th, 2004, 10:35 AM
Sth else: maybe it will be hard to transform RGBA to RGB. I believe it is wrong just to keep the RGB channels and "throw" away the transparency. Maybe, you should do sth like:

RGB = RGB_channels_of_RGBA + alpha*BackGround_RGB_values

taurean
May 18th, 2004, 11:25 AM
what does this do --- alpha*BackGround_RGB_values...

BackGround_RGB_values -- what does this stand for....background of what ?

~ Matt

yiannakop
May 19th, 2004, 07:15 AM
The alpha channel (transaction) has meaning when the image has a background. And to convert an ARGB array to RGB you have to know the background values.