Correction to YCCK and CNYK jpeg images loading into blender
authorSergey Sharybin <sergey.vfx@gmail.com>
Tue, 13 Nov 2012 14:28:45 +0000 (14:28 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Tue, 13 Nov 2012 14:28:45 +0000 (14:28 +0000)
There was incorrect formula applied on color components, used the same
as gimp uses. It makes image looking nicer in blender, however it's
still not 100% correct. Seems lots of software are handling profiles
from jpeg file nicely. But that's another topic.

source/blender/imbuf/intern/jpeg.c

index d96a01d709359ca5185d8aa7ed1cd01c553f7eca..758617bdd486f1f62490b4d8e05198e61c1c6e09 100644 (file)
@@ -348,25 +348,12 @@ static ImBuf *ibJpegImageFromCinfo(struct jpeg_decompress_struct *cinfo, int fla
                                                        g = *buffer++;
                                                        b = *buffer++;
                                                        k = *buffer++;
-                                                       
-                                                       k = 255 - k;
-                                                       r -= k;
-                                                       if (r & 0xffffff00) {
-                                                               if (r < 0) r = 0;
-                                                               else r = 255;
-                                                       }
-                                                       g -= k;
-                                                       if (g & 0xffffff00) {
-                                                               if (g < 0) g = 0;
-                                                               else g = 255;
-                                                       }
-                                                       b -= k;
-                                                       if (b & 0xffffff00) {
-                                                               if (b < 0) b = 0;
-                                                               else b = 255;
-                                                       }
-                                                       
-                                                       rect[3] = 255 - k;
+
+                                                       r = (r * k) / 255;
+                                                       g = (g * k) / 255;
+                                                       b = (b * k) / 255;
+
+                                                       rect[3] = 255;
                                                        rect[2] = b;
                                                        rect[1] = g;
                                                        rect[0] = r;