#include <image_dither_unittest.h>
Public Member Functions | |
TestImageDither (void) | |
~TestImageDither (void) | |
void | set_image (const std::string &filepath) |
void | test (void) |
(1)Calling ImageDither to dither to 8bits. (2)Convert 8bits to 24bits for saving. (3)Save the image data in 24bits to file to verify. |
Definition at line 34 of file image_dither_unittest.h.
TestImageDither::TestImageDither | ( | void | ) |
Definition at line 34 of file image_dither_unittest.cpp.
TestImageDither::~TestImageDither | ( | void | ) |
Definition at line 39 of file image_dither_unittest.cpp.
void TestImageDither::set_image | ( | const std::string & | filepath | ) |
Definition at line 43 of file image_dither_unittest.cpp.
Referenced by main().
void TestImageDither::test | ( | void | ) |
(1)Calling ImageDither to dither to 8bits. (2)Convert 8bits to 24bits for saving. (3)Save the image data in 24bits to file to verify.
Definition at line 48 of file image_dither_unittest.cpp.
References images::ImageDither::dither_to_8bits().
Referenced by main().
00049 { 00050 // Load the image. 00051 GdkPixbuf * pixbuf = gdk_pixbuf_new_from_file (img_path.c_str (), 0); 00052 00053 // Set all fields of attrs_src. 00054 BitmapAttributes attrs_src, attrs_dst, attrs_tmp; 00055 00056 attrs_src.width = gdk_pixbuf_get_width (pixbuf); 00057 attrs_src.height = gdk_pixbuf_get_height (pixbuf); 00058 attrs_src.rowstride = gdk_pixbuf_get_rowstride (pixbuf); 00059 attrs_src.data = gdk_pixbuf_get_pixels (pixbuf); 00060 attrs_src.bytes_per_pixel = gdk_pixbuf_get_n_channels (pixbuf); 00061 00062 // Convert the image data to be in 8bits. 00063 ImageDither dither; 00064 dither.dither_to_8bits (&attrs_src, &attrs_dst); 00065 00066 // Convert the image data to be in 24bits for saving. 00067 convert_8bits_to_24bits (&attrs_dst, &attrs_tmp); 00068 00069 // Save to image file to verify. 00070 save_24bits_to_file (&attrs_tmp); 00071 00072 // Free the memory. 00073 g_object_unref (pixbuf); 00074 delete [] attrs_dst.data; 00075 // delete [] attrs_tmp.data; 00076 }