Bitmap Deconstruction (AKA: How to get pixel values from a file)
-
Hi all, I'm looking for some snippets of code that show me how to get the individual pixel colors out of a bitmap or other graphic file format. So if it is given a file, it would find out what color each pixel is, and maybe output it to a text file or something. Any ideas? This is for a really cool project for little kids, and I'm excited to get started. Any guidance would be great. Thanks for your time, Michael Fritzius
-
Hi all, I'm looking for some snippets of code that show me how to get the individual pixel colors out of a bitmap or other graphic file format. So if it is given a file, it would find out what color each pixel is, and maybe output it to a text file or something. Any ideas? This is for a really cool project for little kids, and I'm excited to get started. Any guidance would be great. Thanks for your time, Michael Fritzius
matrix2681 wrote:
his is for a really cool project for little kids, and I'm excited to get started. Any guidance would be great.
Using GetPixel[^] is an option. Also you can use ::LoadImage to load a bitmap from file.
Nibu babu thomas Microsoft MVP for VC++ Code must be written to be read, not by the compiler, but by another human being. Programming Blog: http://nibuthomas.wordpress.com
-
Hi all, I'm looking for some snippets of code that show me how to get the individual pixel colors out of a bitmap or other graphic file format. So if it is given a file, it would find out what color each pixel is, and maybe output it to a text file or something. Any ideas? This is for a really cool project for little kids, and I'm excited to get started. Any guidance would be great. Thanks for your time, Michael Fritzius
You can use GDI+ for loading the images and use methods LockBits(..)/UnlockBits(..) to get access to pixel data. there are loads of application on CP to help you out few are http://www.codeproject.com/KB/GDI-plus/gdi__and_mfc.aspx[^] http://www.codeproject.com/KB/GDI-plus/cgdiplusbitmap.aspx[^] http://www.codeproject.com/KB/cpp/GDI_.aspx[^]
Regards, Sandip.
-
Hi all, I'm looking for some snippets of code that show me how to get the individual pixel colors out of a bitmap or other graphic file format. So if it is given a file, it would find out what color each pixel is, and maybe output it to a text file or something. Any ideas? This is for a really cool project for little kids, and I'm excited to get started. Any guidance would be great. Thanks for your time, Michael Fritzius
CImage class has good functions for work with images.