2

I am wondering if there is any good tutorial or a book on loading,creating and editing bitmaps in c++. I need to edit bitmap pixel by pixel but none of the tutorials don't show how. I want to understand how does bitmap "work" and wikipedia helped a little.

Transcendental
  • 983
  • 2
  • 11
  • 27
  • Did you look at ["What's simplest way to read and write BMP files using C++"][1]? [1]: http://stackoverflow.com/q/199403/6294 – Maggie Feb 04 '12 at 20:31
  • @user1183602: "Bitmaps" can be a vague term. Are you talking about files that end in ".bmp"? Or just images in memory? Or something else? – Drew Dormann Feb 04 '12 at 20:35

3 Answers3

3

If you want to manipulate bitmaps on the pixel level, then you should start learning Image Processing and then read something about bitmap file formats. It is not a C++ question. C++ is just icing on the cake in such task.

Here you can find some lectures on Image processing: http://www.archive.org/details/Lectures_on_Image_Processing

And here is the description of BMP file format: http://www.fileformat.info/format/bmp/spec/e27073c25463436f8a64fa789c886d9c/view.htm

You can easily find a lot of sources for other formats as well. Good luck, I have been studying this topic three years at the university... I think you really should use some open source library as David Grayson advised.

vitakot
  • 3,786
  • 4
  • 27
  • 59
  • I've been studying about BMP's past 2 days but what i really need to do is to read the R,G and B color values from each pixel so i can use them later. I need to make matrix that is m*n where m is width and n height of the image and store color values in each element ..I cant figure out how to do it – Transcendental Feb 05 '12 at 15:03
  • Here is the detailed tutorial how to do what you want: http://tipsandtricks.runicsoft.com/Cpp/BitmapTutorial.html – vitakot Feb 05 '12 at 18:05
2

If you want to edit a bitmap you only need to learn about the format you want to edit. How many bits per component, how many components per pixel, where is the width and height defined, what's the standard for said format files. If you want to use the popular BMP you can find all this in Wikipedia.

If all this made little sense to you, then you should try a tutorial on digital image processing first.

An image is just an array of structures (pixels) with a certain number of components each, you just need to read and write said array to do whatever edition you want. But be warned, although common crops and pixel replacement are almost trivial, advanced edition and altering are not.

whtlnv
  • 2,109
  • 1
  • 25
  • 26
1

I'm assuming you searched Google already and didn't find anything good.

If I were you, I would learn about the binary format of bitmaps first. You can learn about it by reading the specifications and/or looking at bitmap files with a hex editor like WinHex or ghex2.

Then I would learn how to read files and work with binary data in C++.

But really you could probably save a lot of effort if you just used the Magick++ library:

http://www.imagemagick.org/Magick++/

David Grayson
  • 84,103
  • 24
  • 152
  • 189