Author: post
Date: 2010-01-28 18:10:00 +0100 (Thu, 28 Jan 2010)
New Revision: 3105
Modified:
branches/rawstudio-ng-color/plugins/output-jpegfile/output-jpegfile.c
Log:
Fix JPEG output crash temporarily (now always exports as sRGB).
Modified: branches/rawstudio-ng-color/plugins/output-jpegfile/output-jpegfile.c
===================================================================
--- branches/rawstudio-ng-color/plugins/output-jpegfile/output-jpegfile.c
2010-01-28 15:13:20 UTC (rev 3104)
+++ branches/rawstudio-ng-color/plugins/output-jpegfile/output-jpegfile.c
2010-01-28 17:10:00 UTC (rev 3105)
@@ -190,11 +190,19 @@
FILE * outfile;
JSAMPROW row_pointer[1];
const RSIccProfile *profile = NULL;
- RSFilterResponse *response = rs_filter_get_image8(filter, NULL);
- RSColorSpace *colorspace =
rs_filter_param_get_object_with_type(RS_FILTER_PARAM(response), "colorspace",
RS_TYPE_COLOR_SPACE);
- if (colorspace)
- profile = rs_color_space_get_icc_profile(colorspace);
+ gint x,y;
+
+
+ RSFilterRequest *request = rs_filter_request_new();
+ rs_filter_request_set_quick(RS_FILTER_REQUEST(request), FALSE);
+ /*FIXME: Support other output profiles */
+ rs_filter_param_set_object(RS_FILTER_PARAM(request), "colorspace",
rs_color_space_new_singleton("RSSrgb"));
+ RSFilterResponse *response = rs_filter_get_image8(filter, request);
+
+ g_object_unref(request);
GdkPixbuf *pixbuf = rs_filter_response_get_image8(response);
+ g_object_unref(pixbuf);
+ g_object_unref(response);
cinfo.err = jpeg_std_error(&jerr);
jpeg_create_compress(&cinfo);
@@ -203,7 +211,7 @@
jpeg_stdio_dest(&cinfo, outfile);
cinfo.image_width = gdk_pixbuf_get_width(pixbuf);
cinfo.image_height = gdk_pixbuf_get_height(pixbuf);
- cinfo.input_components = gdk_pixbuf_get_n_channels(pixbuf);
+ cinfo.input_components = 3;
cinfo.in_color_space = JCS_RGB;
jpeg_set_defaults(&cinfo);
jpeg_set_quality(&cinfo, jpegfile->quality, TRUE);
@@ -217,6 +225,24 @@
g_free(data);
}
+ if (gdk_pixbuf_get_n_channels(pixbuf) == 4)
+ {
+ GdkPixbuf *out = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8,
cinfo.image_width, cinfo.image_height);
+ for( y = 0; y < cinfo.image_height; y++){
+ gint* in = (gint*)GET_PIXBUF_PIXEL(pixbuf, 0, y);
+ guchar* o = GET_PIXBUF_PIXEL(out, 0, y);
+ for( x = 0; x < cinfo.image_width ; x++) {
+ guint i = *in++;
+ o[0] = i&0xff;
+ o[1] = (i>>8)&0xff;
+ o[2] = (i>>16)&0xff;
+ o+=3;
+ }
+ }
+ g_object_unref(pixbuf);
+ pixbuf = out;
+ }
+
while (cinfo.next_scanline < cinfo.image_height)
{
row_pointer[0] = GET_PIXBUF_PIXEL(pixbuf, 0,
cinfo.next_scanline);
@@ -227,7 +253,6 @@
fclose(outfile);
jpeg_destroy_compress(&cinfo);
g_object_unref(pixbuf);
- g_object_unref(response);
gchar *input_filename = NULL;
rs_filter_get_recursive(filter, "filename", &input_filename, NULL);
_______________________________________________
Rawstudio-commit mailing list
[email protected]
http://rawstudio.org/cgi-bin/mailman/listinfo/rawstudio-commit