image_dither.h

Go to the documentation of this file.
00001 /*
00002  * File Name: image_dither.h
00003  */
00004 
00005 /*
00006  * This file is part of uds-plugin-images.
00007  *
00008  * uds-plugin-images is free software: you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation, either version 2 of the License, or
00011  * (at your option) any later version.
00012  *
00013  * uds-plugin-images is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  * along with this program. If not, see <http://www.gnu.org/licenses/>.
00020  */
00021 
00022 /**
00023  * Copyright (C) 2008 iRex Technologies B.V.
00024  * All rights reserved.
00025  */
00026 
00027 #ifndef _IMAGE_DITHER_H_
00028 #define _IMAGE_DITHER_H_
00029 
00030 #include <gdk-pixbuf/gdk-pixbuf.h>
00031 #include <glib.h>
00032 
00033 #define WHITE_BACKGROUND 255
00034 
00035 namespace images
00036 {
00037     typedef struct 
00038     {
00039         int width;
00040         int height;
00041         int rowstride;
00042         int bytes_per_pixel;
00043         unsigned char * data;
00044     }BitmapAttributes;
00045 
00046     /**
00047      * @brief ImageDither 
00048      */
00049     class ImageDither
00050     {
00051         public:
00052             ImageDither(void);
00053             ~ImageDither(void);
00054 
00055         public:
00056             /**
00057              * @brief Convert and dither 32bits or 24bits true color image 
00058              *        into 256 grayscale image.
00059              * @param attrs_src in 32bits or 24bits
00060              * @param attrs_dst return in 256 grayscale
00061              */
00062             void dither_to_8bits(const BitmapAttributes *attrs_src,
00063                                   BitmapAttributes *attrs_dst);
00064 
00065         private:
00066            /**
00067              * @brief Convert and dither image data in 32bits or 24bits
00068              *        into the one in 8bits. 
00069              * @param data the image data
00070              * @param w    the width of image
00071              * @param h    the height of image
00072              * @return     the image data in 8bits
00073              */
00074             unsigned char*dither_32bits_to_8bits(const unsigned char *data, 
00075                                              int w, int h, int rowstride);
00076 
00077             unsigned char*dither_24bits_to_8bits(const unsigned char *data, 
00078                                              int w, int h, int rowstride);
00079 
00080         public:
00081             /**
00082              * @brief Get the rowstride. 
00083              * @param width  width of image
00084              * @return       rowstride
00085              */
00086             static int get_rowstride(int width, 
00087                                      int bytes_per_pixel, 
00088                                      int alignment);
00089    };
00090 
00091 } // namespace image
00092 
00093 #endif // _IMAGE_DITHER_H_
00094 
00095 
Generated by  doxygen 1.6.2-20100208