Article View: comp.sources.bugs
Article #660ImageMagick 2.2 - patch #2
From: Cristy Dude
Date: Tue, 22 Dec 1992 21:28
Date: Tue, 22 Dec 1992 21:28
451 lines
12848 bytes
12848 bytes
ImageMagick 2.2 Patch #2
To apply this patch:
cd to the top of the source tree (to the directory containing the
"ImageMagick" subdirectories) and do:
patch -p < ThisFile
Prereq: ImageMagick 2.2.1 (posted from comp.sources.misc, Volume 34,
Issue 28 + Patch 1).
Alternatively get the entire distribution as contrib/ImageMagick.tar.Z
on export.lcs.mit.edu. I will post this patch to comp.sources.misc in
a few days.
diff -r -c ImageMagick/ChangeLog ImageMagick2.2.2/ChangeLog
*** ImageMagick/ChangeLog Mon Dec 21 14:12:35 1992
--- ImageMagick2.2.2/ChangeLog Tue Dec 22 16:07:20 1992
***************
*** 1,3 ****
--- 1,14 ----
+ ImageMagick 2.2.2
+
+ o Dithering did not work properly on the Cray (due to right shift problem).
+
+ o In most cases dithering requires 1/2 as much memory as previously.
+
+ o Dithering was sped up by ~15%.
+
+ o Occasionally the quantization error was reported incorrectly.
+
+
ImageMagick 2.2.1
o The number of colors reported with the -verbose option was on
diff -r -c ImageMagick/X.c ImageMagick2.2.2/X.c
*** ImageMagick/X.c Mon Dec 21 14:12:34 1992
--- ImageMagick2.2.2/X.c Tue Dec 22 16:06:18 1992
***************
*** 1283,1291 ****
/*
Initialize annotated image.
*/
! if (image->packets != (image->columns*image->rows))
! if (!UncompressImage(image))
! return(False);
/*
Initialize annotated pixmap.
*/
--- 1283,1290 ----
/*
Initialize annotated image.
*/
! if (!UncompressImage(image))
! return(False);
/*
Initialize annotated pixmap.
*/
diff -r -c ImageMagick/display.h ImageMagick2.2.2/display.h
*** ImageMagick/display.h Tue Dec 22 16:23:13 1992
--- ImageMagick2.2.2/display.h Tue Dec 22 16:23:32 1992
***************
*** 51,55 ****
*/
#ifndef lint
static char
! Version[]="@(#)ImageMagick 2.2.1 92/12/10 cristy@dupont.com";
#endif
--- 51,55 ----
*/
#ifndef lint
static char
! Version[]="@(#)ImageMagick 2.2.2 92/12/22 cristy@dupont.com";
#endif
diff -r -c ImageMagick/image.c ImageMagick2.2.2/image.c
*** ImageMagick/image.c Fri Dec 18 17:07:28 1992
--- ImageMagick2.2.2/image.c Tue Dec 22 16:06:19 1992
***************
*** 731,739 ****
/*
Image must be uncompressed.
*/
! if (image->packets != (image->columns*image->rows))
! if (!UncompressImage(image))
! return;
if (!image->alpha)
{
/*
--- 731,738 ----
/*
Image must be uncompressed.
*/
! if (!UncompressImage(image))
! return;
if (!image->alpha)
{
/*
***************
*** 5190,5195 ****
--- 5189,5196 ----
RunlengthPacket
*uncompressed_pixels;
+ if (image->packets == (image->columns*image->rows))
+ return(True);
/*
Uncompress runlength-encoded packets.
*/
Common subdirectories: ImageMagick/images and ImageMagick2.2.2/images
diff -r -c ImageMagick/quantize.c ImageMagick2.2.2/quantize.c
*** ImageMagick/quantize.c Mon Dec 21 11:12:00 1992
--- ImageMagick2.2.2/quantize.c Tue Dec 22 16:06:18 1992
***************
*** 745,753 ****
blue;
} ScaledColorPacket;
- Image
- *dithered_image;
-
int
*cache,
odd_scanline;
--- 745,750 ----
***************
*** 769,786 ****
*cs,
*ns;
register unsigned int
id;
- register unsigned short
- index;
-
ScaledColorPacket
*scanline;
unsigned char
! *range_limit,
! *range_table;
unsigned int
i,
--- 766,785 ----
*cs,
*ns;
+ register unsigned char
+ *range_limit;
+
register unsigned int
id;
ScaledColorPacket
*scanline;
unsigned char
! blue,
! green,
! *range_table,
! red;
unsigned int
i,
***************
*** 787,803 ****
x,
y;
/*
! Initialize dithered image attributes.
*/
! image->orphan=True;
! dithered_image=CopyImage(image,image->columns,image->rows,False);
! image->orphan=False;
! if (dithered_image == (Image *) NULL)
! {
! Warning("unable to dither image","memory allocation failed");
! return(True);
! }
/*
Allocate the cache & scanline buffers to keep track of quantization error.
*/
--- 786,800 ----
x,
y;
+ unsigned short
+ index;
+
/*
! Image must be uncompressed.
*/
! if (!UncompressImage(image))
! return(True);
! image->compression=NoCompression;
/*
Allocate the cache & scanline buffers to keep track of quantization error.
*/
***************
*** 827,846 ****
Preload first scanline.
*/
p=image->pixels;
- image->runlength=p->length+1;
cs=scanline+1;
for (i=0; i < image->columns; i++)
{
- if (image->runlength > 0)
- image->runlength--;
- else
- {
- p++;
- image->runlength=p->length;
- }
cs->red=p->red;
cs->green=p->green;
cs->blue=p->blue;
cs++;
}
odd_scanline=False;
--- 824,836 ----
Preload first scanline.
*/
p=image->pixels;
cs=scanline+1;
for (i=0; i < image->columns; i++)
{
cs->red=p->red;
cs->green=p->green;
cs->blue=p->blue;
+ p++;
cs++;
}
odd_scanline=False;
***************
*** 856,871 ****
ns+=(image->columns+2);
for (i=0; i < image->columns; i++)
{
- if (image->runlength > 0)
- image->runlength--;
- else
- {
- p++;
- image->runlength=p->length;
- }
ns->red=p->red;
ns->green=p->green;
ns->blue=p->blue;
ns++;
}
}
--- 846,855 ----
ns+=(image->columns+2);
for (i=0; i < image->columns; i++)
{
ns->red=p->red;
ns->green=p->green;
ns->blue=p->blue;
+ p++;
ns++;
}
}
***************
*** 874,880 ****
/*
Distribute error left-to-right for even scanlines.
*/
! q=dithered_image->pixels+image->columns*y;
cs=scanline+1;
ns=scanline+(image->columns+2)+1;
step=1;
--- 858,864 ----
/*
Distribute error left-to-right for even scanlines.
*/
! q=image->pixels+image->columns*y;
cs=scanline+1;
ns=scanline+(image->columns+2)+1;
step=1;
***************
*** 884,890 ****
/*
Distribute error right-to-left for odd scanlines.
*/
! q=dithered_image->pixels+image->columns*y+(image->columns-1);
cs=scanline+(image->columns+2)+(image->columns-1)+1;
ns=scanline+(image->columns-1)+1;
step=(-1);
--- 868,874 ----
/*
Distribute error right-to-left for odd scanlines.
*/
! q=image->pixels+image->columns*y+(image->columns-1);
cs=scanline+(image->columns+2)+(image->columns-1)+1;
ns=scanline+(image->columns-1)+1;
step=(-1);
***************
*** 891,900 ****
}
for (x=0; x < image->columns; x++)
{
! q->red=range_limit[cs->red];
! q->green=range_limit[cs->green];
! q->blue=range_limit[cs->blue];
! i=(q->red >> 2) << 12 | (q->green >> 2) << 6 | q->blue >> 2;
if (cache[i] < 0)
{
/*
--- 875,884 ----
}
for (x=0; x < image->columns; x++)
{
! red=range_limit[cs->red];
! green=range_limit[cs->green];
! blue=range_limit[cs->blue];
! i=(red >> 2) << 12 | (green >> 2) << 6 | blue >> 2;
if (cache[i] < 0)
{
/*
***************
*** 903,911 ****
node=cube.root;
for ( ; ; )
{
! id=(q->red > node->mid_red ? 1 : 0) |
! (q->green > node->mid_green ? 1 : 0) << 1 |
! (q->blue > node->mid_blue ? 1 : 0) << 2;
if ((node->children & (1 << id)) == 0)
break;
node=node->child[id];
--- 887,895 ----
node=cube.root;
for ( ; ; )
{
! id=(red > node->mid_red ? 1 : 0) |
! (green > node->mid_green ? 1 : 0) << 1 |
! (blue > node->mid_blue ? 1 : 0) << 2;
if ((node->children & (1 << id)) == 0)
break;
node=node->child[id];
***************
*** 913,931 ****
/*
Find closest color among siblings and their children.
*/
! cube.color.red=q->red;
! cube.color.green=q->green;
! cube.color.blue=q->blue;
cube.distance=(~0);
ClosestColor(node->parent);
cache[i]=cube.color_number;
}
index=(unsigned short) cache[i];
! red_error=(int) q->red-(int) cube.colormap[index].red;
! green_error=(int) q->green-(int) cube.colormap[index].green;
! blue_error=(int) q->blue-(int) cube.colormap[index].blue;
q->index=index;
- q->length=0;
q+=step;
/*
Propagate the error in these proportions:
--- 897,914 ----
/*
Find closest color among siblings and their children.
*/
! cube.color.red=red;
! cube.color.green=green;
! cube.color.blue=blue;
cube.distance=(~0);
ClosestColor(node->parent);
cache[i]=cube.color_number;
}
index=(unsigned short) cache[i];
! red_error=(int) red-(int) cube.colormap[index].red;
! green_error=(int) green-(int) cube.colormap[index].green;
! blue_error=(int) blue-(int) cube.colormap[index].blue;
q->index=index;
q+=step;
/*
Propagate the error in these proportions:
***************
*** 933,953 ****
3/16 5/16 1/16
*/
cs+=step;
! cs->red+=red_error-((red_error*9+8) >> 4);
! cs->green+=green_error-((green_error*9+8) >> 4);
! cs->blue+=blue_error-((blue_error*9+8) >> 4);
ns-=step;
! ns->red+=(red_error*3+8) >> 4;
! ns->green+=(green_error*3+8) >> 4;
! ns->blue+=(blue_error*3+8) >> 4;
ns+=step;
! ns->red+=(red_error*5+8) >> 4;
! ns->green+=(green_error*5+8) >> 4;
! ns->blue+=(blue_error*5+8) >> 4;
ns+=step;
! ns->red+=(red_error+8) >> 4;
! ns->green+=(green_error+8) >> 4;
! ns->blue+=(blue_error+8) >> 4;
}
odd_scanline=!odd_scanline;
}
--- 916,936 ----
3/16 5/16 1/16
*/
cs+=step;
! cs->red+=(red_error-((red_error*9+8)/16));
! cs->green+=(green_error-((green_error*9+8)/16));
! cs->blue+=(blue_error-((blue_error*9+8)/16));
ns-=step;
! ns->red+=(red_error*3+8)/16;
! ns->green+=(green_error*3+8)/16;
! ns->blue+=(blue_error*3+8)/16;
ns+=step;
! ns->red+=(red_error*5+8)/16;
! ns->green+=(green_error*5+8)/16;
! ns->blue+=(blue_error*5+8)/16;
ns+=step;
! ns->red+=(red_error+8)/16;
! ns->green+=(green_error+8)/16;
! ns->blue+=(blue_error+8)/16;
}
odd_scanline=!odd_scanline;
}
***************
*** 957,968 ****
(void) free((char *) scanline);
(void) free((char *) range_table);
(void) free((char *) cache);
- (void) free((char *) image->pixels);
- image->packets=dithered_image->packets;
- image->pixels=dithered_image->pixels;
- dithered_image->file=(FILE *) NULL;
- dithered_image->pixels=(RunlengthPacket *) NULL;
- DestroyImage(dithered_image);
return(False);
}
--- 940,945 ----
Common subdirectories: ImageMagick/scenes and ImageMagick2.2.2/scenes
Common subdirectories: ImageMagick/utilities and ImageMagick2.2.2/utilities
Common subdirectories: ImageMagick/xtp and ImageMagick2.2.2/xtp
--
cristy@dupont.com
Technical Details
Message-ID:
<cristy.725059729@eplrx7.es.dupont.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!paladin.american.edu!darwin.sura.net!udel!louie!eplrx7!eplrx7.es.dupont.com!cristyShow Full Headers
Complete Article Headers
Newsgroups: comp.sources.bugs Path: arc1-ca.pugleaf.net!sparky!uunet!paladin.american.edu!darwin.sura.net!udel!louie!eplrx7!eplrx7.es.dupont.com!cristy From: cristy@eplrx7.es.duPont.com (Cristy Dude) Subject: ImageMagick 2.2 - patch #2 Message-ID: <cristy.725059729@eplrx7.es.dupont.com> Summary: X11 image processing and display utilities Keywords: UNIX VMS X11 SGI DEC Cray Sun Vax Organization: DuPont Engineering Physics Laboratory Date: Tue, 22 Dec 1992 21:28:49 GMT Lines: 451