summaryrefslogtreecommitdiff
path: root/graphics/xzgv/patches/patch-ac
diff options
context:
space:
mode:
Diffstat (limited to 'graphics/xzgv/patches/patch-ac')
-rw-r--r--graphics/xzgv/patches/patch-ac82
1 files changed, 82 insertions, 0 deletions
diff --git a/graphics/xzgv/patches/patch-ac b/graphics/xzgv/patches/patch-ac
new file mode 100644
index 00000000000..c7e23180c08
--- /dev/null
+++ b/graphics/xzgv/patches/patch-ac
@@ -0,0 +1,82 @@
+$NetBSD: patch-ac,v 1.3 2006/09/23 14:59:34 adrianp Exp $
+
+--- src/readjpeg.c.orig 2006-09-23 15:52:41.000000000 +0100
++++ src/readjpeg.c
+@@ -179,11 +179,13 @@ static unsigned char **lineptrs;
+ static int have_image;
+ static int width,height;
+ static unsigned char *image;
++static int cmyk;
+ unsigned char *ptr,*ptr2;
+ int chkw,chkh;
+ int f,rec;
+ static int greyscale; /* static to satisfy gcc -Wall */
+
++cmyk=0;
+ greyscale=0;
+
+ lineptrs=NULL;
+@@ -225,6 +227,15 @@ if(cinfo.jpeg_color_space==JCS_GRAYSCALE
+ greyscale=1;
+ }
+
++if(cinfo.jpeg_color_space==JCS_CMYK)
++ cmyk=1;
++
++if(cinfo.jpeg_color_space==JCS_YCCK)
++ {
++ cmyk=1;
++ cinfo.out_color_space=JCS_CMYK;
++ }
++
+ *wp=width=cinfo.image_width;
+ *hp=height=cinfo.image_height;
+
+@@ -266,7 +277,7 @@ if(!careful_jpeg)
+ /* this one shouldn't hurt */
+ cinfo.do_block_smoothing=FALSE;
+
+-if(WH_BAD(width,height) || (*imagep=image=malloc(width*height*3))==NULL)
++if(WH_BAD(width,height) || (*imagep=image=malloc(width*(height+cmyk)*3))==NULL)
+ longjmp(jerr.setjmp_buffer,1);
+
+ jpeg_start_decompress(&cinfo);
+@@ -279,12 +290,33 @@ ptr=image+width*2*greyscale; /* put data
+ for(f=0;f<height;f++,ptr+=width*3)
+ lineptrs[f]=ptr;
+
+-rec=cinfo.rec_outbuf_height;
+-while(cinfo.output_scanline<height)
++if(!cmyk)
+ {
+- f=height-cinfo.output_scanline;
+- jpeg_read_scanlines(&cinfo,lineptrs+cinfo.output_scanline,
+- f>rec?rec:f);
++ rec=cinfo.rec_outbuf_height;
++ while(cinfo.output_scanline<height)
++ {
++ f=height-cinfo.output_scanline;
++ jpeg_read_scanlines(&cinfo,lineptrs+cinfo.output_scanline,
++ f>rec?rec:f);
++ }
++ }
++else /* cmyk output */
++ {
++ int tmp;
++
++ ptr=image;
++ while(cinfo.output_scanline<height)
++ {
++ jpeg_read_scanlines(&cinfo,&ptr,1);
++ ptr2=ptr;
++ for(f=0;f<width;f++,ptr+=3,ptr2+=4)
++ {
++ tmp=ptr2[3];
++ ptr[0]=(tmp*ptr2[0])/255;
++ ptr[1]=(tmp*ptr2[1])/255;
++ ptr[2]=(tmp*ptr2[2])/255;
++ }
++ }
+ }
+
+ free(lineptrs);