0

I have a JPEG file in a char* buffer from a jpeg encoder. Assume if I write it correctly to file it'll be pic.jpg. Say then I read in using ifstream from pic.jpg and store it in char* buffer2.

What's the difference between these two buffers, if there's any?

(The reason I'm asking is that, I have jpeg file in a char * buffer from a jpeg decoder and I need to write it to disk. But using the system file descripter and write() method in fcntl.h doesn't write it out properly... I can open the picture, but it's very obvious that the colors are off. Please assume that the picture has valid colors when it was outputed from the decoder, because I can write directly from decoder to disk and everything's fine. It's just I need to put it in a char* buffer for other purposes, and I need to verify that buffer has valid data before further processing.)

1 Answers1

0

The description you are giving implies that you are reading Y component(responsible for brightness) properly and not reading UV components (responsible for color) properly.This looks like either you are not writing the entire decoded data to disk or you are not reading the entire decoded data from disk while rendering(displaying). Best place to start is check the size of decoded data (size = height * width of original jpg image).

http://software.intel.com/sites/products/documentation/hpc/ipp/ippi/ippi_ch6/Images/ch6_image_downsampling.jpg