images::ImageDither Class Reference

ImageDither. More...

#include <image_dither.h>

Public Member Functions

 ImageDither (void)
 ~ImageDither (void)
void dither_to_8bits (const BitmapAttributes *attrs_src, BitmapAttributes *attrs_dst)
 Convert and dither 32bits or 24bits true color image into 256 grayscale image.

Static Public Member Functions

static int get_rowstride (int width, int bytes_per_pixel, int alignment)
 Get the rowstride.

Detailed Description

ImageDither.

Definition at line 49 of file image_dither.h.


Constructor & Destructor Documentation

images::ImageDither::ImageDither ( void   ) 

Definition at line 39 of file image_dither.cpp.

References LOGPRINTF.

00040 {
00041     LOGPRINTF("entry");
00042 }

images::ImageDither::~ImageDither ( void   ) 

Definition at line 44 of file image_dither.cpp.

References LOGPRINTF.

00045 {
00046     LOGPRINTF("entry");
00047 }


Member Function Documentation

void images::ImageDither::dither_to_8bits ( const BitmapAttributes attrs_src,
BitmapAttributes attrs_dst 
)

Convert and dither 32bits or 24bits true color image into 256 grayscale image.

Parameters:
attrs_src in 32bits or 24bits
attrs_dst return in 256 grayscale

Definition at line 49 of file image_dither.cpp.

References images::BitmapAttributes::bytes_per_pixel, images::BitmapAttributes::data, get_rowstride(), images::BitmapAttributes::height, LOGPRINTF, images::BitmapAttributes::rowstride, and images::BitmapAttributes::width.

Referenced by images::TestImageDither::test().

00051 {
00052     LOGPRINTF("entry %p, %p", attrs_src, attrs_dst);
00053 
00054     assert(attrs_src);
00055     assert(attrs_dst);
00056     assert(attrs_src->data);
00057     assert((attrs_src->bytes_per_pixel == 3) 
00058             || (attrs_src->bytes_per_pixel == 4));
00059     assert(attrs_src->rowstride >= 
00060             (attrs_src->width * attrs_src->bytes_per_pixel));
00061    
00062     attrs_dst->width = attrs_src->width;
00063     attrs_dst->height = attrs_src->height;
00064     attrs_dst->rowstride = get_rowstride(attrs_src->width, 1, 4);
00065     attrs_dst->bytes_per_pixel = 1;
00066 
00067     if (attrs_src->bytes_per_pixel == 4)
00068     {
00069         attrs_dst->data = dither_32bits_to_8bits(attrs_src->data, 
00070                                            attrs_src->width, 
00071                                            attrs_src->height, 
00072                                            attrs_src->rowstride);
00073     }
00074     else
00075     {
00076         attrs_dst->data = dither_24bits_to_8bits(attrs_src->data, 
00077                                            attrs_src->width, 
00078                                            attrs_src->height, 
00079                                            attrs_src->rowstride);
00080     }
00081 }

Here is the call graph for this function:

Here is the caller graph for this function:

int images::ImageDither::get_rowstride ( int  width,
int  bytes_per_pixel,
int  alignment 
) [static]

Get the rowstride.

Parameters:
width width of image
Returns:
rowstride

Definition at line 255 of file image_dither.cpp.

References LOGPRINTF.

Referenced by dither_to_8bits(), and images::ImagePage::estimate_length().

00258 {
00259     LOGPRINTF("entry %d, %d, %d", width, bytes_per_pixel, alignment);
00260 
00261     int rowstride;
00262 
00263     int original_rowstride = width * bytes_per_pixel;
00264     if (original_rowstride % alignment)
00265     {
00266         int padding = alignment - (original_rowstride % alignment);
00267         rowstride = original_rowstride + padding;
00268     }
00269     else
00270     {
00271         rowstride = original_rowstride;
00272     }
00273     
00274     LOGPRINTF("return %d", rowstride);
00275 
00276     return rowstride;
00277 }

Here is the caller graph for this function:


The documentation for this class was generated from the following files:
Generated by  doxygen 1.6.2-20100208