CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2009
    Posts
    2

    Decoding custom image in Visual C++

    Hi everyone!

    I have something which I'm completely confused about it. I have 3 different image files (*.img, *.frg, *.raw). I have their respective file formats containing the header information (i.e. file name, number of images in the file, image width, image depth, etc.). Within the file format I have the bytes containing specific information. For example, my *.img file contains images with width and depth to be 512 respectively. From this information, each image file size will be 512x512x1bytes = 262,144 bytes.

    My question is, how do I parse through the image bytes to draw an image in Visual C++? I can't use the Image class because it doesn't support my custom file type. I also can't use PaintLib because of the same reasons with the Image class. Im guessing the bytes for the image file will contain information for each pixel but I have no idea how to do it.

    I'm fairly new at Visual C++ so please excuse me if this is a newbie question

    Thanks in advance!

  2. #2
    Join Date
    Aug 2000
    Location
    New York, NY, USA
    Posts
    5,656

    Re: Decoding custom image in Visual C++

    I guess you should look into SetDIBits function.
    You said that you have 1 byte per pixel. Do you know its meaning? Is it a monochrome image? Or do you have a palette?
    Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
    Convenience and productivity tools for Microsoft Visual Studio:
    FeinWindows - replacement windows manager for Visual Studio, and more...

  3. #3
    Join Date
    Oct 2007
    Location
    Scotland
    Posts
    137

    Re: Decoding custom image in Visual C++

    usually the pixel data is just a sequence of bytes that follows the header, but this can be encoded in whatever way, you will have to read the format spec. for specific file formats to see how they store the pixel data, some will use palettes, compression or just store the raw pixel data.

    An easy format to start with would be windows bitmap.

  4. #4
    Join Date
    Jun 2009
    Posts
    2

    Re: Decoding custom image in Visual C++

    Quote Originally Posted by VladimirF View Post
    I guess you should look into SetDIBits function.
    You said that you have 1 byte per pixel. Do you know its meaning? Is it a monochrome image? Or do you have a palette?
    according to the data format i have, my images are saved as processed images in log scale, 256 gray levels, one byte per pixel

    that's all the information I have.

    I've been told that i could try and use createDIBsection?

    thank you all for your replies, i really appreciate it

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured