summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Image.cc19
1 files changed, 14 insertions, 5 deletions
diff --git a/lib/Image.cc b/lib/Image.cc
index a2e7a7c..8b973f6 100644
--- a/lib/Image.cc
+++ b/lib/Image.cc
@@ -26,6 +26,7 @@ typedef my_destination_mgr * my_dest_ptr;
METHODDEF(void)
init_destination (j_compress_ptr cinfo)
{
+ Base::printm(M_INFO, "init_destination()\n");
my_dest_ptr dest = (my_dest_ptr) cinfo->dest;
/* Allocate the output buffer --- it will be released when done with image */
@@ -40,6 +41,7 @@ init_destination (j_compress_ptr cinfo)
METHODDEF(boolean)
empty_output_buffer (j_compress_ptr cinfo)
{
+ Base::printm(M_INFO, "empty_output_buffer()\n");
my_dest_ptr dest = (my_dest_ptr) cinfo->dest;
if (dest->outfile->write(dest->buffer, OUTPUT_BUF_SIZE) !=
@@ -55,6 +57,8 @@ empty_output_buffer (j_compress_ptr cinfo)
METHODDEF(void)
term_destination (j_compress_ptr cinfo)
{
+ Base::printm(M_INFO, "term_destination()\n");
+
my_dest_ptr dest = (my_dest_ptr) cinfo->dest;
size_t datacount = OUTPUT_BUF_SIZE - dest->pub.free_in_buffer;
@@ -69,6 +73,8 @@ GLOBAL(void)
jpeg_handle_dest (j_compress_ptr cinfo, Handle * outfile)
{
my_dest_ptr dest;
+
+ Base::printm(M_INFO, "jpeg_handle_dest()\n");
/* The destination object is made permanent so that multiple JPEG images
* can be written to the same file without re-executing jpeg_stdio_dest.
@@ -207,12 +213,13 @@ bool Image::Prepare(unsigned int f) throw (GeneralException) {
throw GeneralException("You can't create a jpeg image when the library libjpeg isn't linked in.");
#else
{
+ printm(M_INFO, "Converting image buffer to 24 bits - %ix%i.\n", x, y);
char * rgb_buffer = (char *) malloc(x * y * 3);
- for (iy = 0; iy < y; y++) {
- for (ix = 0; ix < x; x++) {
- rgb_buffer[(ix + iy * x) * 3 + 0] = img[ix + iy * x].R;
+ for (iy = 0; iy < y; iy++) {
+ for (ix = 0; ix < x; ix++) {
+ rgb_buffer[(ix + iy * x) * 3 + 0] = img[ix + iy * x].B;
rgb_buffer[(ix + iy * x) * 3 + 1] = img[ix + iy * x].G;
- rgb_buffer[(ix + iy * x) * 3 + 2] = img[ix + iy * x].B;
+ rgb_buffer[(ix + iy * x) * 3 + 2] = img[ix + iy * x].R;
}
}
@@ -229,14 +236,16 @@ bool Image::Prepare(unsigned int f) throw (GeneralException) {
cinfo.image_height = y;
cinfo.input_components = 3;
cinfo.in_color_space = JCS_RGB;
+ printm(M_INFO, "Starting jpeg stuff...\n");
jpeg_set_defaults(&cinfo);
- jpeg_set_quality(&cinfo, 9, TRUE /* limit to baseline-JPEG values */);
+ jpeg_set_quality(&cinfo, 85, TRUE /* limit to baseline-JPEG values */);
jpeg_start_compress(&cinfo, TRUE);
int row_stride = x * 3;
while (cinfo.next_scanline < cinfo.image_height) {
+ printm(M_INFO, "Looping...\n");
row_pointer[0] = (JSAMPLE *) &rgb_buffer[cinfo.next_scanline * row_stride];
(void) jpeg_write_scanlines(&cinfo, row_pointer, 1);
}