[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-dev] [PATCH] Expand grayscale JPEG data to RGB
From: |
Timothy Lee |
Subject: |
[Gnash-dev] [PATCH] Expand grayscale JPEG data to RGB |
Date: |
Tue, 25 Apr 2006 16:52:40 +0800 |
User-agent: |
Thunderbird 3.0a1 (X11/20060421) |
Dear all,
Another minor patch to convert data read from a grayscale JPEG image
into RGB. I've attached a sample file that displays incorrectly without
the patch.
Regards,
Timothy
diff -u -r1.5 jpeg.cpp
--- libbase/jpeg.cpp 24 Apr 2006 14:42:52 -0000 1.5
+++ libbase/jpeg.cpp 25 Apr 2006 08:38:46 -0000
@@ -427,6 +427,20 @@
int lines_read = jpeg_read_scanlines(&m_cinfo,
&rgb_data, 1);
assert(lines_read == 1);
lines_read = lines_read; // avoid warning in
NDEBUG
+
+ // Expand grayscale to RGB
+ if (m_cinfo.out_color_space == JCS_GRAYSCALE)
+ {
+ int w = get_width();
+ unsigned char* src = rgb_data + w - 1;
+ unsigned char* dst = rgb_data + (w * 3) - 1;
+ for (; w; w--, src--)
+ {
+ *dst-- = *src;
+ *dst-- = *src;
+ *dst-- = *src;
+ }
+ }
}
};
monochrome.swf
Description: application/shockwave-flash
- [Gnash-dev] [PATCH] Expand grayscale JPEG data to RGB,
Timothy Lee <=