Sign in to follow this  

.ppm reader

This topic is 3485 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am having problem with a code that reads an input image file "image.ppm" and again write it as "hello.ppm". No modification is applied on the input image. But the output image is different in color than the input image. For example, the green changed to blue, yellow changed to green etc. Would anyone plz tell me what is happening here?

Share this post


Link to post
Share on other sites
It sounds like your read function or write function has a bug in it. Without further details (e.g. which flavours are you using? P3 (ASCII) or P6 (binary)) or a look at the code, it isn't possible to give you an exact answer.

My guess would be that some of the R, G and B components in each pixel are being swapped around, the answer will be in either the data structure for a single pixel/colour value or the code that reads or writes using that data structure. If you store colour in a DWORD in your code, make sure you are reading the correct components into the correct bits (e.g. endianness or incorrect shift, or even structure elements in the wrong order in a union).

Only other (related) guess is that the address of the pixel data you're saving from is incorrect so offset by some number that's causing R, G and B to be read in the wrong order. One thing that could cause this would be passing a pointer to the header of a P6 PPM instead of a pointer to the raw image data when calling your write/save routine.

Share this post


Link to post
Share on other sites

This topic is 3485 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this