]> mj.ucw.cz Git - libucw.git/commitdiff
Do not leave any colorspace conversions to libjpeg and make them manually.
authorPavel Charvat <pchar@paja.(none)>
Wed, 29 Apr 2009 14:20:46 +0000 (16:20 +0200)
committerPavel Charvat <pchar@paja.(none)>
Wed, 29 Apr 2009 14:20:46 +0000 (16:20 +0200)
images/io-libjpeg.c

index ba2cfbe463226c3c15ee15fe9d5bad3d4be9b406..8725610d330e5f035c00d61aa48c562c1a5c0e17 100644 (file)
@@ -358,39 +358,29 @@ libjpeg_read_data(struct image_io *io)
   uns read_flags = io->flags;
 
   /* Select color space */
-  switch (read_flags & IMAGE_COLOR_SPACE)
+  switch (i->cinfo.jpeg_color_space)
     {
-      case COLOR_SPACE_GRAYSCALE:
-       i->cinfo.out_color_space = JCS_GRAYSCALE;
+      case JCS_GRAYSCALE:
+        read_flags = (read_flags & ~IMAGE_COLOR_SPACE & IMAGE_CHANNELS_FORMAT) | COLOR_SPACE_YCBCR; 
+        i->cinfo.out_color_space = JCS_YCbCr;
+        break;
+      case JCS_YCbCr:
+       read_flags = (read_flags & ~IMAGE_COLOR_SPACE & IMAGE_CHANNELS_FORMAT) | COLOR_SPACE_YCBCR; 
+       i->cinfo.out_color_space = JCS_YCbCr;
        break;
-      case COLOR_SPACE_CMYK:
+      case JCS_CMYK:
+       read_flags = (read_flags & ~IMAGE_COLOR_SPACE & IMAGE_CHANNELS_FORMAT) | COLOR_SPACE_CMYK; 
        i->cinfo.out_color_space = JCS_CMYK;
        break;
-      case COLOR_SPACE_YCCK:
+      case JCS_YCCK:
+       read_flags = (read_flags & ~IMAGE_COLOR_SPACE & IMAGE_CHANNELS_FORMAT) | COLOR_SPACE_YCCK; 
        i->cinfo.out_color_space = JCS_YCCK;
        break;
       default:
-       switch (i->cinfo.jpeg_color_space)
-         {
-           case JCS_YCbCr:
-             read_flags = (read_flags & ~IMAGE_COLOR_SPACE & IMAGE_CHANNELS_FORMAT) | COLOR_SPACE_YCBCR; 
-             i->cinfo.out_color_space = JCS_YCbCr;
-             break;
-           case JCS_CMYK:
-             read_flags = (read_flags & ~IMAGE_COLOR_SPACE & IMAGE_CHANNELS_FORMAT) | COLOR_SPACE_CMYK; 
-             i->cinfo.out_color_space = JCS_CMYK;
-             break;
-           case JCS_YCCK:
-             read_flags = (read_flags & ~IMAGE_COLOR_SPACE & IMAGE_CHANNELS_FORMAT) | COLOR_SPACE_YCCK; 
-             i->cinfo.out_color_space = JCS_YCCK;
-             break;
-           default:
-             read_flags = (read_flags & ~IMAGE_COLOR_SPACE & IMAGE_CHANNELS_FORMAT) | COLOR_SPACE_RGB; 
-             i->cinfo.out_color_space = JCS_RGB;
-             break;
-         }
+       read_flags = (read_flags & ~IMAGE_COLOR_SPACE & IMAGE_CHANNELS_FORMAT) | COLOR_SPACE_RGB; 
+       i->cinfo.out_color_space = JCS_RGB;
        break;
-    }
+  }
 
   /* Prepare the image  */
   struct image_io_read_data_internals rdi;