Project Description
The C++ Bitmap Library consists of simple, robust, optimized and portable processing routines for the 24-bit per pixel bitmap image format.

The library has the following capabilities:
  • Read/Write 24-bit Bitmap Images
  • Pixel, row or column level batch editing
  • Color conversions (RGB,YCbCr) in byte and floating values
  • Highly optimized subsample and upsample (resizing)
  • Various color maps (1000 levels - autumn, copper, gray, hot, hsv, jet, prism, vga, yarg)
  • Texture generation (checkered pattern, plasma)
  • Graphics drawing interface (line, line-segmentm rectangle, triangle, quadix, horizontal and vertical line-segments, ellipse, circle, plot pixel, pen width, pen color)
  • PSNR and Image comparisons


The C++ Bitmap Library implementation is compatible with the following C++ compilers:
  • GNU Compiler Collection (4.1+)
  • Intel® C++ Compiler (9.x+)
  • Clang/LLVM (1.1+)
  • PGI C++ (10.x+)
  • Microsoft Visual Studio C++ Compiler (8.1+)
  • Comeau C++ Compiler (4.3+)
  • IBM XL C/C++ (10.x+)

Simple Example 1
The following example will open a bitmap image called 'input.bmp' and count the number of pixels that have a red channel value of 111 and larger, then proceed to print the count to stdout.

#include <cstdio>
#include "bitmap_image.hpp"

int main()
   bitmap_image image("input.bmp");

   if (!image)
      printf("Error - Failed to open: input.bmp\n");
      return 1;

   unsigned char red;
   unsigned char green;
   unsigned char blue;

   unsigned int total_number_of_pixels = 0;

   const unsigned int width  = image.width();
   const unsigned int height = image.height();

   for (std::size_t y = 0; y < height; ++y)
      for (std::size_t x = 0; x < width; ++x)
         if (red >= 111)

   printf("Number of pixels with red >= 111: %d\n",total_number_of_pixels);
   return 0;

Simple Example 2
The following example will create a bitmap of dimensions 200x200 pixels, set the background color to orange, then proceed to draw a circle centered in the middle of the bitmap of radius 50 pixels and of color red then a rectangle centered in the middle of the bitmap with a width and height of 100 pixels and of color blue. The newly constructed image will be saved to disk with the name: 'output.bmp'.

#include "bitmap_image.hpp"

int main()
   bitmap_image image(200,200);

   // set background to orange

   image_drawer draw(image);

   draw.pen_color(255,0,0); / 2, image.height() / 2,50);



   return 0

Last edited May 5 at 2:59 AM by ArashPartow, version 11