Jump to content
  • Advertisement
Sign in to follow this  
udvat

.ppm reader

This topic is 3771 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
Advertisement
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
Thanks for the reply. I had a small bug in my read function. Now it is working fine.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!