[Gtkradiant] workaround patch: gtkradiant crash on single component jpeg

reed mideke gtkradiant@zerowing.idsoftware.com
Wed, 26 Dec 2001 18:25:59 -0800


Timothee Besset wrote:

> Thanks for reporting, I have filed that into the bug tracker. Very useless
> black texture in any case ... if at least there was something interesting
> to it, it would be worth loading :-)
> Will have to look at fixing JPG loading code.
> 
> TTimo
> 
> http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=277

Here's a one line (except for comments) patch that works around the
problem in stable.  This is tested on win32. I also looked through
and ran the unstable code, and verified that it doesn't have the
problem. (The libs/jpeg6/jpgload.cpp file is not used, instead
plugins/image/jpeg.cpp does the equivalent work, correctly.)

Index: libs/jpeg6/jpgload.cpp
===================================================================
RCS file: /cvs/GtkRadiant/libs/jpeg6/jpgload.cpp,v
retrieving revision 1.2.4.2
diff -u -a -r1.2.4.2 jpgload.cpp
--- libs/jpeg6/jpgload.cpp      21 Dec 2000 16:45:10 -0000      1.2.4.2
+++ libs/jpeg6/jpgload.cpp      27 Dec 2001 01:56:46 -0000
@@ -65,10 +65,17 @@
     */

    /* Step 4: set parameters for decompression */
-
-  /* In this example, we don't need to change any of the defaults set by
-   * jpeg_read_header(), so we do nothing here.
-   */
+  /*
+   * +++rfm
+   * workaround for single component .jpg files.
+   * All textures are assumed to be rgba in the radiant code, so
+   * force RGB output. In this version of libjpeg, GREYSCALE -> RGB
+   * conversion is not supported (the most recent version from
+   * http://www.ijg.org/ does), but with this we get a nice error
+   * message in the console and can work with the textures even though
+   * it is displayed with the 'unable to load texture' icon.
+  */
+  cinfo.out_color_space = JCS_RGB;

    /* Step 5: Start decompressor */


--
Email:               rfm(at)redshift.com or rfm(at)portalofevil.com
Home page:                             http://www.redshift.com/~rfm