   Opening a PPM Image File
  Hi I am new here and i am practically learning about game programming and i have started with image and graphics. I have basic knowledge in reading and loading a bitmap image since MFC supports it but how about if it is on another format like for example PPM? I hope anyone here who can help me with this one. Thank you to all   
  You're in luck. The PPM is one of the easiest to parse because it is so simple.specs;  thanks kelly. can you give me an algorithm after parsing how can i display the image using the Device Context? thanks   ;  If you are using MFC, you just decode the PPM into an area of memory, and use that info to create a CBitmap object, in particular see the CreateBitmap member of CBitmap.   ;  hi, base on my knowledge i know how to open a bitmap andplace it on handle then attach the bitmap and select it on the devicecontext and view it using bitblt funtion. I need your expertice on this one. I have some questions.how can i read a PPM file by using CFile?- how can i access P6?- how can i access the width and length?how can i interpret the ppm data and convert into bitmap?how can i covert color values and put them into pixels into a windowbitmap? ;  Do you know how to use any file-reading library? What language are you using? Most programming languages contain methods that let you read files one line at a time, or one char at a time, in to string variables. Read the first line and simply check it to see if it is P6. If you can trust your own files then you can just throw this value away. As you are reading, ignore any values that begin with '#' because these are comments. The next line that isn't a comment are the two resolution values. Use string manip functions to split these at the space and parse each as an int. I think the the next line after that is the color depth per channel, but I don't use anything other than 255 so I ignore this as well. Next you read the pixels. I read it in to a Byte array of size = width * height * 3, because there are three color channels. If the file is ascii, like the example, then reading the bytes is the same as reading the height and width. Find the next number, cast it to a byte and put it in the next empty spot in the array.   ;  I believe the P6 file is the same except that each color channel value of each pixel is represented vy a single 255 bit character. Simply read the pixels, one character at a time, and add the values to your array.   ;  hi kelly i have done what you said. I have already parsed the PP image file and i have accessed all necessary data like the P6, width, height, 255(the last entry of the header) and i have placed all the pixel one by one on an array. Now how im gonna display the image by using the device context? I using MFC by the way Visual C++ Ver. 6, I hope you can share your expertice. Thanks   ;  Mastaba mentioned this already. I'm not familiar with MFC but It looks like you can use this CBitmap class. You probably use CreateBitmap to initialize the bitmap and you can pass the byte array into that. Unfortunatly I don't know how you attach the bitmap to a window.   ;  thanks to you kelly and all for your support i think i am on my own now.-positive vibes   