cristy@dupont.com (05/24/91)
Submitted-by: cristy@dupont.com Posting-number: Volume 13, Issue 27 Archive-name: imagemagic/part11 #!/bin/sh # this is img.11 (part 11 of ImageMagick) # do not concatenate these parts, unpack them in order with /bin/sh # file ImageMagick/rotate.c continued # if test ! -r _shar_seq_.tmp; then echo 'Please unpack part 1 first!' exit 1 fi (read Scheck if test "$Scheck" != 11; then echo Please unpack part "$Scheck" next! exit 1 else exit 0 fi ) < _shar_seq_.tmp || exit 1 if test ! -f _shar_wnt_.tmp; then echo 'x - still skipping ImageMagick/rotate.c' else echo 'x - continuing file ImageMagick/rotate.c' sed 's/^X//' << 'SHAR_EOF' >> 'ImageMagick/rotate.c' && % % % RRRR OOO TTTTT AAA TTTTT EEEEE % % R R O O T A A T E % % RRRR O O T AAAAA T EEE % % R R O O T A A T E % % R R OOO T A A T EEEEE % % % % % % Rotate a raster image by an arbitrary angle. % % % % % % % % Software Design % % John Cristy % % January 1991 % % % % % % Copyright 1991 E. I. Dupont de Nemours & Company % % % % Permission to use, copy, modify, distribute, and sell this software and % % its documentation for any purpose is hereby granted without fee, % % provided that the above Copyright notice appear in all copies and that % % both that Copyright notice and this permission notice appear in % % supporting documentation, and that the name of E. I. Dupont de Nemours % % & Company not be used in advertising or publicity pertaining to % % distribution of the software without specific, written prior % % permission. E. I. Dupont de Nemours & Company makes no representations % % about the suitability of this software for any purpose. It is provided % % "as is" without express or implied warranty. % % % % E. I. Dupont de Nemours & Company disclaims all warranties with regard % % to this software, including all implied warranties of merchantability % % and fitness, in no event shall E. I. Dupont de Nemours & Company be % % liable for any special, indirect or consequential damages or any % % damages whatsoever resulting from loss of use, data or profits, whether % % in an action of contract, negligence or other tortious action, arising % % out of or in connection with the use or performance of this software. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Function RotateImage is based on the paper "A Fast Algorithm for General % Raster Rotatation" by Alan W. Paeth. RotateImage is adapted from a similiar % routine based on the Paeth paper written by Michael Halle of the Spatial % Imaging Group, MIT Media Lab. % */ X /* X Include declarations. */ #include "display.h" #include "image.h" X /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % C o l u m n S h e a r % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Procedure ColumnShear displaces a subcolumn of pixels a specified number of % pixels. % % The format of the ColumnShear routine is: % % ColumnShear(source_image,source_columns,column,y,length,displacement, % background) % % A description of each parameter follows. % % o source_image: A pointer to a ColorPacket structure which contains the % source image. % % o source_columns: Specifies the number of columns in the source image. % % o column: Specifies which column in the image to move. % % o y: Specifies the offset in the source image. % % o length: Specifies the number of pixels to move. % % o displacement: Specifies the number of pixels to displace the column of % pixels. % % o background: Specifies the background color. % % */ static void ColumnShear(source_image,source_columns,column,y,length, X displacement,background) ColorPacket X *source_image; X register unsigned int X source_columns; X unsigned int X column, X y, X length; X double X displacement; X ColorPacket X background; { X ColorPacket X last_pixel; X X double X fractional_step; X X enum {UP,DOWN} X direction; X X long int X blue, X green, X int_fractional_step, X red, X step; X X register ColorPacket X *p, X *q; X X register int X i; X X if (displacement == 0.0) X return; X else X if (displacement > 0.0) X direction=DOWN; X else X { X displacement*=(-1.0); X direction=UP; X } X step=(int) floor(displacement); X fractional_step=displacement-(double) step; X if (fractional_step == 0.0) X { X /* X No fractional displacement-- just copy the pixels. X */ X switch (direction) X { X case UP: X { X p=source_image+y*source_columns+column; X q=p-step*source_columns; X for (i=0; i < length; i++) X { X *q=(*p); X q+=source_columns; X p+=source_columns; X } X /* X Set old column to background color. X */ X for (i=0; i < step; i++) X { X *q=background; X q+=source_columns; X } X break; X } X case DOWN: X { X p=source_image+(y+length)*source_columns+column; X q=p+step*source_columns; X for (i=0; i < length; i++) X { X q-=source_columns; X p-=source_columns; X *q=(*p); X } X /* X Set old column to background color. X */ X for (i=0; i < step; i++) X { X q-=source_columns; X *q=background; X } X break; X } X } X return; X } X /* X Fractional displacment. X */ X step++; X int_fractional_step=(int) (((double) (1 << 14))*fractional_step); X last_pixel=background; X switch (direction) X { X case UP: X { X p=source_image+y*source_columns+column; X q=p-step*source_columns; X for (i=0; i < length; i++) X { X red=(last_pixel.red*((1 << 14)-int_fractional_step)+p->red* X int_fractional_step) >> 14; X if (red > MaxRgb) X q->red=MaxRgb; X else X if (red < 0) X q->red=0; X else X q->red=(unsigned char) red; X green=(last_pixel.green*((1 << 14)-int_fractional_step)+p->green* X int_fractional_step) >> 14; X if (green > MaxRgb) X q->green=MaxRgb; X else X if (green < 0) X q->green=0; X else X q->green=(unsigned char) green; X blue=(last_pixel.blue*((1 << 14)-int_fractional_step)+p->blue* X int_fractional_step) >> 14; X if (blue > MaxRgb) X q->blue=MaxRgb; X else X if (blue < 0) X q->blue=0; X else X q->blue=(unsigned char) blue; X last_pixel=(*p); X q+=source_columns; X p+=source_columns; X } X /* X Set old column to background color. X */ X red=(last_pixel.red*((1 << 14)-int_fractional_step)+background.red* X int_fractional_step) >> 14; X if (red > MaxRgb) X q->red=MaxRgb; X else X if (red < 0) X q->red=0; X else X q->red=(unsigned char) red; X green=(last_pixel.green*((1 << 14)-int_fractional_step)+background.green* X int_fractional_step) >> 14; X if (green > MaxRgb) X q->green=MaxRgb; X else X if (green < 0) X q->green=0; X else X q->green=(unsigned char) green; X blue=(last_pixel.blue*((1 << 14)-int_fractional_step)+background.blue* X int_fractional_step) >> 14; X if (blue > MaxRgb) X q->blue=MaxRgb; X else X if (blue < 0) X q->blue=0; X else X q->blue=(unsigned char) blue; X q+=source_columns; X for (i=0; i < step-1; i++) X { X *q=background; X q+=source_columns; X } X break; X } X case DOWN: X { X p=source_image+(y+length)*source_columns+column; X q=p+step*source_columns; X for (i=0; i < length; i++) X { X q-=source_columns; X p-=source_columns; X red=(last_pixel.red*((1 << 14)-int_fractional_step)+p->red* X int_fractional_step) >> 14; X if (red > MaxRgb) X q->red=MaxRgb; X else X if (red < 0) X q->red=0; X else X q->red=(unsigned char) red; X green=(last_pixel.green*((1 << 14)-int_fractional_step)+p->green* X int_fractional_step) >> 14; X if (green > MaxRgb) X q->green=MaxRgb; X else X if (green < 0) X q->green=0; X else X q->green=(unsigned char) green; X blue=(last_pixel.blue*((1 << 14)-int_fractional_step)+p->blue* X int_fractional_step) >> 14; X if (blue > MaxRgb) X q->blue=MaxRgb; X else X if (blue < 0) X q->blue=0; X else X q->blue=(unsigned char) blue; X last_pixel=(*p); X } X /* X Set old column to background color. X */ X q-=source_columns; X red=(last_pixel.red*((1 << 14)-int_fractional_step)+background.red* X int_fractional_step) >> 14; X if (red > MaxRgb) X q->red=MaxRgb; X else X if (red < 0) X q->red=0; X else X q->red=(unsigned char) red; X green=(last_pixel.green*((1 << 14)-int_fractional_step)+background.green* X int_fractional_step) >> 14; X if (green > MaxRgb) X q->green=MaxRgb; X else X if (green < 0) X q->green=0; X else X q->green=(unsigned char) green; X blue=(last_pixel.blue*((1 << 14)-int_fractional_step)+background.blue* X int_fractional_step) >> 14; X if (blue > MaxRgb) X q->blue=MaxRgb; X else X if (blue < 0) X q->blue=0; X else X q->blue=(unsigned char) blue; X for (i=0; i < step-1; i++) X { X q-=source_columns; X *q=background; X } X break; X } X } X return; } X /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % I n t e g r a l R o t a t i o n % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Function IntegralRotation rotates the source image starting at location % (x,y) an integral of 90 degrees and copies the result to the rotated image % buffer. % % The format of the IntegralRotation routine is: % % IntegralRotation(image,source_columns,source_rows,rotated_image, % rotated_columns,x,y,rotations) % % A description of each parameter follows. % % o source_image: A pointer to a Image structure containing the source % image. % % o source_columns: Specifies the number of columns of pixels in the % source image. % % o source_rows: Specifies the number of rows of pixels in the source % image. % % o rotated_image: A pointer to a ColorPacket structure containing the % rotated image. % % o rotated_columns: Specifies the number of columns of pixels in the % rotated image. % % o x: Specifies the x offset in the source image. % % o y: Specifies the y offset in the source image. % % o rotations: Specifies the number of 90 degree rotations. % % */ static void IntegralRotation(image,source_columns,source_rows,rotated_image, X rotated_columns,x,y,rotations) Image X *image; X unsigned int X source_columns, X source_rows; X ColorPacket X *rotated_image; X unsigned int X rotated_columns, X x, X y, X rotations; { X ColorPacket X *q; X X register RunlengthPacket X *p; X X register int X i, X j; X X /* X Expand runlength packets into a rectangular array of pixels. X */ X p=image->pixels; X image->runlength=p->length+1; X switch (rotations) X { X case 0: X { X /* X Rotate 0 degrees. X */ X for (j=0; j < source_rows; j++) X { X q=rotated_image+rotated_columns*(y+j)+x; X for (i=0; i < source_columns; i++) X { X if (image->runlength > 0) X image->runlength--; X else X { X p++; X image->runlength=p->length; X } X q->red=p->red; X q->green=p->green; X q->blue=p->blue; X q->index=p->index; X q++; X } X } X break; X } X case 1: X { X /* X Rotate 90 degrees. X */ X for (j=source_columns-1; j >= 0; j--) X { X q=rotated_image+rotated_columns*y+x+j; X for (i=0; i < source_rows; i++) X { X if (image->runlength > 0) X image->runlength--; X else X { X p++; X image->runlength=p->length; X } X q->red=p->red; X q->green=p->green; X q->blue=p->blue; X q->index=p->index; X q+=rotated_columns; X } X } X break; X } X case 2: X { X /* X Rotate 180 degrees. X */ X q=rotated_image; X for (j=source_rows-1; j >= 0; j--) X { X q=rotated_image+rotated_columns*(y+j)+x+source_columns; X for (i=0; i < source_columns; i++) X { X if (image->runlength > 0) X image->runlength--; X else X { X p++; X image->runlength=p->length; X } X q--; X q->red=p->red; X q->green=p->green; X q->blue=p->blue; X q->index=p->index; X } X } X break; X } X case 3: X { X /* X Rotate 270 degrees. X */ X for (j=0; j < source_columns; j++) X { X q=rotated_image+rotated_columns*(y+source_rows)+x+j-rotated_columns; X for (i=0; i < source_rows; i++) X { X if (image->runlength > 0) X image->runlength--; X else X { X p++; X image->runlength=p->length; X } X q->red=p->red; X q->green=p->green; X q->blue=p->blue; X q->index=p->index; X q-=rotated_columns; X } X } X break; X } X default: X break; X } } X /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % R o w S h e a r % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Procedure RowShear displaces a subrow of pixels a specified number of % pixels. % % The format of the RowShear routine is: % % RowShear(source_image,source_columns,row,y,length,displacement, % background) % % A description of each parameter follows. % % o source_image: A pointer to a ColorPacket structure. % % o source_columns: Specifies the number of columns in the source image. % % o row: Specifies which row in the image to move. % % o y: Specifies the offset in the source image. % % o length: Specifies the number of pixels to move. % % o displacement: Specifies the number of pixels to displace the row of % pixels. % % o background: Specifies the background color. % % */ static void RowShear(source_image,source_columns,row,x,length,displacement, X background) ColorPacket X *source_image; X unsigned int X source_columns, X row, X x, X length; X double X displacement; X ColorPacket X background; { X ColorPacket X last_pixel; X X double X fractional_step; X X enum {LEFT,RIGHT} X direction; X X long int X blue, X green, X int_fractional_step, X red, X step; X X register ColorPacket X *p, X *q; X X register int X i; X X if (displacement == 0.0) X return; X else X if (displacement > 0.0) X direction=RIGHT; X else X { X displacement*=(-1.0); X direction=LEFT; X } X step=(int) floor(displacement); X fractional_step=displacement-(double)step; X if (fractional_step == 0.0) X { X /* X No fractional displacement-- just copy. X */ X switch (direction) X { X case LEFT: X { X p=source_image+row*source_columns+x; X q=p-step; X for (i=0; i < length; i++) X { X *q=(*p); X q++; X p++; X } X /* X Set old row to background color. X */ X for (i=0; i < step; i++) X { X *q=background; X q++; X } X break; X } X case RIGHT: X { X /* X Right is the same as left except data is transferred backwards X to prevent deleting data we need later. X */ X p=source_image+row*source_columns+x+length; X q=p+step; X for (i=0; i < length; i++) X { X p--; X q--; X *q=(*p); X } X /* X Set old row to background color. X */ X for (i=0; i < step; i++) X { X q--; X *q=background; X } X break; X } X } X return; X } X /* X Fractional displacement. X */ X step++; X int_fractional_step=(int) (((double) (1 << 14))*fractional_step); X last_pixel=background; X switch (direction) X { X case LEFT: X { X p=source_image+row*source_columns+x; X q=p-step; X for (i=0; i < length; i++) X { X red=(last_pixel.red*((1 << 14)-int_fractional_step)+p->red* X int_fractional_step) >> 14; X if (red > MaxRgb) X q->red=MaxRgb; X else X if (red < 0) X q->red=0; X else X q->red=(unsigned char) red; X green=(last_pixel.green*((1 << 14)-int_fractional_step)+p->green* X int_fractional_step) >> 14; X if (green > MaxRgb) X q->green=MaxRgb; X else X if (green < 0) X q->green=0; X else X q->green=(unsigned char) green; X blue=(last_pixel.blue*((1 << 14)-int_fractional_step)+p->blue* X int_fractional_step) >> 14; X if (blue > MaxRgb) X q->blue=MaxRgb; X else X if (blue < 0) X q->blue=0; X else X q->blue=(unsigned char) blue; X last_pixel=(*p); X p++; X q++; X } X /* X Set old row to background color. X */ X red=(last_pixel.red*((1 << 14)-int_fractional_step)+background.red* X int_fractional_step) >> 14; X if (red > MaxRgb) X q->red=MaxRgb; X else X if (red < 0) X q->red=0; X else X q->red=(unsigned char) red; X green=(last_pixel.green*((1 << 14)-int_fractional_step)+background.green* X int_fractional_step) >> 14; X if (green > MaxRgb) X q->green=MaxRgb; X else X if (green < 0) X q->green=0; X else X q->green=(unsigned ) green; X blue=(last_pixel.blue*((1 << 14)-int_fractional_step)+background.blue* X int_fractional_step) >> 14; X if (blue > MaxRgb) X q->blue=MaxRgb; X else X if (blue < 0) X q->blue=0; X else X q->blue=(unsigned char) blue; X q++; X for (i=0; i < step-1; i++) X { X *q=background; X q++; X } X break; X } X case RIGHT: X { X p=source_image+row*source_columns+x+length; X q=p+step; X for (i=0; i < length; i++) X { X p--; X q--; X red=(last_pixel.red*((1 << 14)-int_fractional_step)+p->red* X int_fractional_step) >> 14; X if (red > MaxRgb) X q->red=MaxRgb; X else X if (red < 0) X q->red=0; X else X q->red=(unsigned char) red; X green=(last_pixel.green*((1 << 14)-int_fractional_step)+p->green* X int_fractional_step) >> 14; X if (green > MaxRgb) X q->green=MaxRgb; X else X if (green < 0) X q->green=0; X else X q->green=(unsigned char) green; X blue=(last_pixel.blue*((1 << 14)-int_fractional_step)+p->blue* X int_fractional_step) >> 14; X if (blue > MaxRgb) X blue=MaxRgb; X else X if (blue < 0) X blue=0; X else X q->blue=(unsigned char) blue; X last_pixel=(*p); X } X /* X Set old row to background color. X */ X q--; X red=(last_pixel.red*((1 << 14)-int_fractional_step)+background.red* X int_fractional_step) >> 14; X if (red > MaxRgb) X red=MaxRgb; X else X if (red < 0) X red=0; X else X q->red=(unsigned char) red; X green=(last_pixel.green*((1 << 14)-int_fractional_step)+background.green* X int_fractional_step) >> 14; X if (green > MaxRgb) X green=MaxRgb; X else X if (green < 0) X green=0; X else X q->green=(unsigned char) green; X blue=(last_pixel.blue*((1 << 14)-int_fractional_step)+background.blue* X int_fractional_step) >> 14; X if (blue > MaxRgb) X blue=MaxRgb; X else X if (blue < 0) X blue=0; X else X q->blue=(unsigned char) blue; X for (i=0; i < step-1; i++) X { X q--; X *q=background; X } X break; X } X } X return; } X /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % R o t a t e I m a g e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Function RotateImage creates a new image that is a rotated copy of an % existing one. It allocates the memory necessary for the new Image structure % and returns a pointer to the new image. % % Function RotateImage is based on the paper "A Fast Algorithm for General % Raster Rotatation" by Alan W. Paeth. RotateImage is adapted from a similiar % routine based on the Paeth paper written by Michael Halle of the Spatial % Imaging Group, MIT Media Lab. % % The format of the RotateImage routine is: % % RotateImage(image,degrees,clip) % % A description of each parameter follows. % % o status: Function RotateImage returns a pointer to the image after % rotating. A null image is returned if there is a memory shortage. % % o image: The address of a structure of type Image; returned from % ReadImage. % % o degrees: Specifies the number of degrees to rotate the image. % % o clip: A value other than zero clips the corners of the rotated % image and retains the original image size. % % */ Image *RotateImage(image,degrees,clip) Image X *image; X double X degrees; X int X clip; { #define DegreesToRadians(x) ((x)/180.0*3.14159265359) X X ColorPacket X background, X *rotated_pixels; X X double X x_shear, X y_shear; X X extern Image X *CopyImage(); X X extern void X DestroyImage(); X X Image X *rotated_image; X X register ColorPacket X *p; X X register int X i, X x, X y; X X register RunlengthPacket X *q; X X unsigned int X number_rows, X number_columns, X rotations, X x_offset, X y_offset, X y_width; X X /* X Adjust rotation angle. X */ X while (degrees < -45.0) X degrees+=360.0; X rotations=0; X while (degrees > 45.0) X { X degrees-=90.0; X rotations++; X } X rotations%=4; X /* X Calculate shear equations. X */ X x_shear=(-tan(DegreesToRadians(degrees)/2.0)); X y_shear=sin(DegreesToRadians(degrees)); X if ((rotations == 1) || (rotations == 3)) X { X /* X Invert image size. X */ X y_width=image->rows+ X (int) ceil(fabs(x_shear)*(double) (image->columns-1)); X number_columns=image->rows+2* X (int) ceil(fabs(x_shear)*(double) (image->columns-1)); X number_rows=image->columns+ X (int) ceil(fabs(y_shear)*(double) (y_width-1)); X rotated_image=CopyImage(image,number_columns,number_rows); X if (rotated_image == (Image *) NULL) X { X Warning("unable to rotate image","memory allocation failed"); X return((Image *) NULL); X } X rotated_image->columns=image->rows; X rotated_image->rows=image->columns; X } X else X { X y_width=image->columns+ X (int) ceil(fabs(x_shear)*(double) (image->rows-1)); X number_columns=image->columns+2* X (int) ceil(fabs(x_shear)*(double) (image->rows-1)); X number_rows=image->rows+ X (int) ceil(fabs(y_shear)*(double) (y_width-1)); X rotated_image=CopyImage(image,number_columns,number_rows); X if (rotated_image == (Image *) NULL) X { X Warning("unable to rotate image","memory allocation failed"); X return((Image *) NULL); X } X rotated_image->columns=image->columns; X rotated_image->rows=image->rows; X } X /* X Initialize rotated image attributes. X */ X rotated_pixels=(ColorPacket *) X malloc(number_columns*(number_rows+2)*sizeof(ColorPacket)); X if (rotated_pixels == (ColorPacket *) NULL) X { X Warning("unable to rotate image","memory allocation failed"); X return((Image *) NULL); X } X if ((x_shear == 0.0) || (y_shear == 0.0)) X { X /* X No shearing required; do integral rotation. X */ X x_offset=0; X y_offset=0; X IntegralRotation(image,rotated_image->columns,rotated_image->rows, X rotated_pixels+number_columns,number_columns,x_offset,y_offset, X rotations); X } X else X { X typedef struct Point X { X double X x, X y; X } Point; X X double X x_max, X x_min, X y_max, X y_min; X X Point X corners[4]; X X unsigned int X column, X row; X X /* X Initialize rotated image buffer to background color. X */ X rotated_image->class=DirectClass; X background.red=image->pixels[0].red; X background.green=image->pixels[0].green; X background.blue=image->pixels[0].blue; X p=rotated_pixels; X for (i=0; i < (number_columns*(number_rows+2)); i++) X { X *p=background; X p++; X } X /* X Perform an initial integral 90 degree rotation. X */ X x_offset=(number_columns-rotated_image->columns)/2; X y_offset=(number_rows-rotated_image->rows)/2; X IntegralRotation(image,rotated_image->columns,rotated_image->rows, X rotated_pixels+number_columns,number_columns,x_offset,y_offset, X rotations); X /* X Perform a fractional rotation. First, shear the image rows. X */ X row=(number_rows-rotated_image->rows)/2; X for (i=0; i < rotated_image->rows; i++) X { X RowShear(rotated_pixels+number_columns,number_columns,row,x_offset, X rotated_image->columns,x_shear* X (((double) i)-(rotated_image->rows-1)/2.0),background); X row++; X } X /* X Shear the image columns. X */ X column=(number_columns-y_width)/2; X for (i=0; i < y_width; i++) X { X ColumnShear(rotated_pixels+number_columns,number_columns,column, X y_offset,rotated_image->rows,y_shear*(((double) i)-(y_width-1)/2.0), X background); X column++; X } X /* X Shear the image rows again. X */ X for (i=0; i < number_rows; i++) X RowShear(rotated_pixels+number_columns,number_columns,(unsigned int) i, X (number_columns-y_width)/2,y_width,x_shear* X (((double) i)-(number_rows-1)/2.0),background); X /* X Calculate the rotated image size. X */ X corners[0].x=(-((int) rotated_image->columns)/2.0); X corners[0].y=(-((int) rotated_image->rows)/2.0); X corners[1].x=((int) rotated_image->columns)/2.0; X corners[1].y=(-((int) rotated_image->rows)/2.0); X corners[2].x=(-((int) rotated_image->columns)/2.0); X corners[2].y=((int) rotated_image->rows)/2.0; X corners[3].x=((int) rotated_image->columns)/2.0; X corners[3].y=((int) rotated_image->rows)/2.0; X for (i=0; i < 4; i++) X { X corners[i].x+=x_shear*corners[i].y; X corners[i].y+=y_shear*corners[i].x; X corners[i].x+=x_shear*corners[i].y; X corners[i].x+=(number_columns-1)/2.0; X corners[i].y+=(number_rows-1)/2.0; X } X x_min=corners[0].x; X y_min=corners[0].y; X x_max=corners[0].x; X y_max=corners[0].y; X for (i=1; i < 4; i++) X { X if (x_min > corners[i].x) X x_min=corners[i].x; X if (y_min > corners[i].y) X y_min=corners[i].y; X if (x_max < corners[i].x) X x_max=corners[i].x; X if (y_max < corners[i].y) X y_max=corners[i].y; X } X x_min=floor((double) x_min); X x_max=ceil((double) x_max); X y_min=floor((double) y_min); X y_max=ceil((double) y_max); X if (!clip) X { X /* X Rotated image is not clipped. X */ X rotated_image->columns=(unsigned int) (x_max-x_min); X rotated_image->rows=(unsigned int) (y_max-y_min); X } X x_offset=(int) x_min+((int) (x_max-x_min)-rotated_image->columns)/2; X y_offset=(int) y_min+((int) (y_max-y_min)-rotated_image->rows)/2; X } X /* X Convert the rectangular array of pixels to runlength packets. X */ X rotated_image->packets=0; X q=rotated_image->pixels; X q->length=MaxRunlength; X for (y=0; y < rotated_image->rows; y++) X { X p=rotated_pixels+number_columns+(y+y_offset)*number_columns+x_offset; X for (x=0; x < rotated_image->columns; x++) X { X if ((p->red == q->red) && (p->green == q->green) && X (p->blue == q->blue) && (q->length < MaxRunlength)) X q->length++; X else X { X if (rotated_image->packets > 0) X q++; X rotated_image->packets++; X q->red=p->red; X q->green=p->green; X q->blue=p->blue; X q->index=p->index; X q->length=0; X } X p++; X } X } X (void) free((char *) rotated_pixels); X rotated_image->pixels=(RunlengthPacket *) realloc((char *) X rotated_image->pixels,rotated_image->packets*sizeof(RunlengthPacket)); X return(rotated_image); } SHAR_EOF echo 'File ImageMagick/rotate.c is complete' && chmod 0755 ImageMagick/rotate.c || echo 'restore of ImageMagick/rotate.c failed' Wc_c="`wc -c < 'ImageMagick/rotate.c'`" test 32713 -eq "$Wc_c" || echo 'ImageMagick/rotate.c: original size 32713, current size' "$Wc_c" rm -f _shar_wnt_.tmp fi # ============= ImageMagick/compress.c ============== if test -f 'ImageMagick/compress.c' -a X"$1" != X"-c"; then echo 'x - skipping ImageMagick/compress.c (File already exists)' rm -f _shar_wnt_.tmp else > _shar_wnt_.tmp echo 'x - extracting ImageMagick/compress.c (Text)' sed 's/^X//' << 'SHAR_EOF' > 'ImageMagick/compress.c' && /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % CCCC OOO M M PPPP RRRR EEEEE SSSSS SSSSS % % C O O MM MM P P R R E SS SS % % C O O M M M PPPP RRRR EEE SSS SSS % % C O O M M P R R E SS SS % % CCCC OOO M M P R R EEEEE SSSSS SSSSS % % % % % % Q-Coder Image Compression Algorithm % % % % % % % % Software Design % % John Cristy % % January 1991 % % % % % % Copyright 1991 E. I. Dupont de Nemours & Company % % % % Permission to use, copy, modify, distribute, and sell this software and % % its documentation for any purpose is hereby granted without fee, % % provided that the above Copyright notice appear in all copies and that % % both that Copyright notice and this permission notice appear in % % supporting documentation, and that the name of E. I. Dupont de Nemours % % & Company not be used in advertising or publicity pertaining to % % distribution of the software without specific, written prior % % permission. E. I. Dupont de Nemours & Company makes no representations % % about the suitability of this software for any purpose. It is provided % % "as is" without express or implied warranty. % % % % E. I. Dupont de Nemours & Company disclaims all warranties with regard % % to this software, including all implied warranties of merchantability % % and fitness, in no event shall E. I. Dupont de Nemours & Company be % % liable for any special, indirect or consequential damages or any % % damages whatsoever resulting from loss of use, data or profits, whether % % in an action of contract, negligence or other tortious action, arising % % out of or in connection with the use or performance of this software. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Procedures QEncodeImage and QDecodeImage is based on the document % "JPEG-9-R6 Working Draft for Develpment of JPEG CD", 14 January 1991. % These routines do not yet fully implement the lossless JPEG compression, % but will some time in the future. % % */ X /* X Include declarations. */ #include "display.h" /* X Define declarations. */ #define LowerBound 0 #define MaxContextStates 121 #define MinimumIntervalD (unsigned short) 0xf000 /* ~-0.75 */ #define MinimumIntervalE (unsigned short) 0x1000 /* ~0.75 */ #define No 0 #define UpperBound 2 #define Yes 1 /* X State classification. */ #define ZeroState 0 #define SmallPostitiveState 1 #define SmallNegativeState 2 #define LargePostitiveState 3 #define LargeNegativeState 4 /* X Typedef declarations. */ typedef struct _ScanlinePacket { X unsigned char X pixel; X X int X state; } ScanlinePacket; /* X Initialized declarations. */ int decrement_less_probable[]= { X 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, X 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 2, 3, 2, 3, 2 }; X int increment_more_probable[]= { X 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, X 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 }; X int more_probable_exchange[]= { X 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, X 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; X int statistics[][5]= { X 0, 4, 8, 12, 16, X 20, 24, 28, 32, 36, X 40, 44, 48, 52, 56, X 60, 64, 68, 72, 76, X 80, 84, 88, 92, 96, }; X unsigned short probability[]= { X 0x0ac1, 0x0a81, 0x0a01, 0x0901, 0x0701, 0x0681, X 0x0601, 0x0501, 0x0481, 0x0441, 0x0381, 0x0301, X 0x02c1, 0x0281, 0x0241, 0x0181, 0x0121, 0x00e1, X 0x00a1, 0x0071, 0x0059, 0x0053, 0x0027, 0x0017, X 0x0013, 0x000b, 0x0007, 0x0005, 0x0003, 0x0001 }; /* X Declarations and initializations for q-coder. */ int X code, X less_probable[MaxContextStates], X more_probable[MaxContextStates], X probability_estimate[MaxContextStates]; X unsigned char X *q; X unsigned short X interval; X /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % D e c o d e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Function Decode uncompresses a string. % % The format of the Decode routine is: % % (void) Decode(state,decision) % % A description of each parameter follows: % % o state: An integer value representing the current state. % % o decision: A pointer to an integer. The output of the binary % decision (Yes/No) is returned in this value. % % */ void Decode(state,decision) register int X state, X *decision; { X interval+=probability[probability_estimate[state]]; X if (((code >> 16) & 0xffff) < interval) X { X code-=(interval << 16); X interval=(-probability[probability_estimate[state]]); X *decision=less_probable[state]; X } X else X { X *decision=more_probable[state]; X if (interval <= MinimumIntervalD) X return; X } X do X { X if ((code & 0xff) == 0) X { X code&=0xffff0000; X if ((*q++) == 0xff) X code+=((*q) << 9)+0x02; X else X code+=((*q) << 8)+0x01; X } X interval<<=1; X code<<=1; X } while (interval > MinimumIntervalD); X /* X Update probability estimates X */ X if (*decision == more_probable[state]) X probability_estimate[state]+= X increment_more_probable[probability_estimate[state]]; X else X probability_estimate[state]-= X decrement_less_probable[probability_estimate[state]]; X if (more_probable_exchange[probability_estimate[state]] != 0) X { X /* X Exchange sense of most probable and least probable. X */ X less_probable[state]=more_probable[state]; X more_probable[state]=1-more_probable[state]; X } } X /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % E n c o d e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Function Encode generate compressed data string by encoding yes-no decision % given state s. % % The format of the Encode routine is: % % (void) Encode(state,decision) % % A description of each parameter follows: % % o state: An integer value representing the current state. % % o decision: An integer value representing a binary decision. % % */ void Encode(state,decision) register int X state, X decision; { X /* X Test on "most-probable-symbol" for state s(more_probable[state]) X */ X interval-=probability[probability_estimate[state]]; X if (more_probable[state] != decision) X { X code-=interval; X interval=probability[probability_estimate[state]]; X } X else X if (interval >= MinimumIntervalE) X return; X /* X Encoder renormalization. X */ X do X { X interval<<=1; X if (code >= 0) X code<<=1; X else X { X /* X Shift unsigned char of data from Code register to compressed string. X */ X code<<=1; X if (code > 0) X { X /* X Add eight bits from Code register to compressed data string. X */ X (*q++)--; X *q=(unsigned char) (code >> 16); X code&=0x0000ffff; X code|=0x01800000; X } X else X { X code&=0x01ffffff; X if (interval > code) X { X /* X Add eight bits from Code register to compressed data string. X */ X (*q++)--; X *q=0xff; X code|=0x01810000; X } X else X if ((*q++) == 0xff) X { X /* X Add seven bits from Code register plus one stuffed bit to X compressed data string. X */ X *q=(unsigned char) (code >> 17); X code&=0x0001ffff; X code|=0x03000000; X } X else X { X /* X Add eight bits from Code register to compressed data string. X */ X *q=(unsigned char) (code >> 16); X code&=0x0000ffff; X code|=0x01800000; X } X } X } X } while (interval < MinimumIntervalE); X /* X Update probability estimates X */ X if (decision == more_probable[state]) X probability_estimate[state]+= X increment_more_probable[probability_estimate[state]]; X else X probability_estimate[state]-= X decrement_less_probable[probability_estimate[state]]; X if (more_probable_exchange[probability_estimate[state]] != 0) X more_probable[state]=1-more_probable[state]; } X /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % F l u s h % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Function Flush flushes the final bits of data from the Code register to the % compressed data string. % % The format of the Flush routine is: % % (void) Flush() % % */ void Flush() { X register int X extra_bits; X X code-=interval; X extra_bits=24; X extra_bits--; X while (code >= 0) X { X code<<=1; X extra_bits--; X } X code<<=1; X if (code > 0) X (*q)--; X /* X Add the final compressed data unsigned chars to the compressed data string. X */ X do X { X if ((*q++) == 0xff) X { X /* X Add seven bits of data plus one stuffed bit to the compressed data X string during final Flush of Code register. X */ X *q=(unsigned char) (code >> 17); X code&=0x0001ffff; X code<<=7; X extra_bits-=7; X } X else X { X /* X Add eight bits of data to the compressed data string during final X flush of Code register. X */ X *q=(unsigned char) (code >> 16); X code&=0x0000ffff; X code<<=8; X extra_bits-=8; X } X } while (extra_bits > 0); X q++; } X /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % Q D e c o d e I m a g e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Function QDecodeImage uncompresses an image via Q-coding. % % The format of the QDecodeImage routine is: % % count=QDecodeImage(compressed_pixels,pixels,number_columns,number_rows) % % A description of each parameter follows: % % o count: The QDecodeImage routine returns this integer value. It is % the actual number of pixels created by the decompression process. % % o compressed_pixels: The address of a byte (8 bits) array of compressed % pixel data. % % o pixels: The address of a byte (8 bits) array of pixel data created by % the uncompression process. The number of bytes in this array % must be at least equal to the number columns times the number of rows % of the source pixels. % % o number_columns: An integer value that is the number of columns or % width in pixels of your source image. % % o number_rows: An integer value that is the number of rows or % heigth in pixels of your source image. % % */ unsigned int QDecodeImage(compressed_pixels,pixels,number_columns,number_rows) unsigned char X *compressed_pixels, X *pixels; X unsigned int X number_columns, X number_rows; { X int X decision, X i, X prediction, X row; X X register int X column, X magnitude, X sign, X state, X value; X X register ScanlinePacket X *cs, X *ls; X X register unsigned char X *p; X X ScanlinePacket X *scanline; X X for (i=0; i < MaxContextStates; i++) X { X probability_estimate[i]=0; X more_probable[i]=0; X less_probable[i]=1; X } X /* X Allocate scanline for row values and states X */ X scanline=(ScanlinePacket *) X malloc((unsigned int) (2*(number_columns+1)*sizeof(ScanlinePacket))); X if (scanline == (ScanlinePacket *) NULL) X { X Warning("unable to compress image, unable to allocate memory", X (char *) NULL); X exit(1); X } X cs=scanline; X for (i=0; i < 2*(number_columns+1); i++) X { X cs->pixel=0; X cs->state=ZeroState; X cs++; X } X interval=MinimumIntervalD; X p=pixels; X q=compressed_pixels+1; X /* X Add a new unsigned char of compressed data to the Code register. X */ X code=(*q) << 16; X if ((*q++) == 0xff) X code+=((*q) << 9)+0x02; X else X code+=((*q) << 8)+0x01; X code<<=4; X code+=(interval << 16); X /* X Decode each image scanline. X */ X for (row=0; row < number_rows; row++) X { X ls=scanline+(number_columns+1)*((row+0) % 2); X cs=scanline+(number_columns+1)*((row+1) % 2); X for (column=0; column < number_columns; column++) X { X prediction=(int) cs->pixel-(int) ls->pixel; X ls++; X prediction+=(int) ls->pixel; X state=statistics[cs->state][ls->state]; X cs++; X cs->state=ZeroState; X /* X Branch for zero code value X */ X (void) Decode(state,&decision); X if (decision == No) X value=0; X else X { X /* X Decode sign information X */ X state++; X (void) Decode(state,&decision); X if (decision == Yes) X sign=(-1); X else X { X sign=1; X state++; X } X state++; X /* X Branch for value=+-1 X */ X (void) Decode(state,&decision); X if (decision == No) X value=1; X else X { X /* X Establish magnitude of value. X */ X magnitude=2; X state=100; X (void) Decode(state,&decision); X while (decision != No) X { X if (state < 107) X state++; X magnitude<<=1; X (void) Decode(state,&decision); X } X /* X Code remaining bits. X */ X state+=7; X value=1; X magnitude>>=2; X if (magnitude != 0) X { X (void) Decode(state,&decision); X state+=6; X value=(value << 1) | decision; X magnitude>>=1; X while (magnitude != 0) X { X (void) Decode(state,&decision); X value=(value << 1) | decision; X magnitude>>=1; X } X } X value++; X } X if (value > LowerBound) X if (value <= UpperBound) X cs->state= X (sign < ZeroState ? SmallPostitiveState : SmallNegativeState); X else X cs->state= X (sign < ZeroState ? LargePostitiveState : LargeNegativeState); X if (sign < 0) X value=(-value); X } X cs->pixel=(unsigned char) (value+prediction); X *p++=cs->pixel; X } X } X (void) free((char *) scanline); X return((unsigned int) (p-pixels)); } X /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % Q E n c o d e I m a g e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Function QEncodeImage compresses an image via q-coding. % % The format of the QEncodeImage routine is: % % count=QEncodeImage(pixels,compressed_pixels,number_columns, % number_rows) % % A description of each parameter follows: % % o count: The QEncodeImage routine returns this integer value. It is % the actual number of compressed pixels created by the compression % process. % % o pixels: The address of a byte (8 bits) array of pixel data. % % o compressed_pixels: The address of a byte (8 bits) array of pixel data % created by the compression process. The number of bytes in this array % must be at least equal to the number columns times the number of rows % of the source pixels to allow for the possibility that no compression % is possible. The actual number of bytes used is reflected by the % count parameter. % % o number_columns: An integer value that is the number of columns or % width in pixels of your source image. % % o number_rows: An integer value that is the number of rows or % heigth in pixels of your source image. % % % */ unsigned int QEncodeImage(pixels,compressed_pixels,number_columns,number_rows) unsigned char X *pixels, X *compressed_pixels; X unsigned int X number_columns, X number_rows; { X int X i, X prediction, X row; X X register int X column, X magnitude, X sign, X state, X value; X X register ScanlinePacket X *cs, X *ls; X X register unsigned char X *p; X X ScanlinePacket X *scanline; X X void X Encode(), X Flush(); X X for (i=0; i < MaxContextStates; i++) X { X probability_estimate[i]=0; X more_probable[i]=0; X } X /* X Allocate scanline for row values and states. X */ X scanline=(ScanlinePacket *) X malloc((unsigned int) (2*(number_columns+1)*sizeof(ScanlinePacket))); X if (scanline == (ScanlinePacket *) NULL) X { X Warning("unable to compress image, unable to allocate memory", X (char *) NULL); X exit(1); X } X cs=scanline; X for (i=0; i < 2*(number_columns+1); i++) X { X cs->pixel=0; X cs->state=ZeroState; X cs++; X } X interval=MinimumIntervalE; X p=pixels; X q=compressed_pixels; X (*q)++; X code=0x00180000; X /* X Encode each scanline. X */ X for (row=0; row < number_rows; row++) X { X ls=scanline+(number_columns+1)*((row+0) % 2); X cs=scanline+(number_columns+1)*((row+1) % 2); X for (column=0; column < number_columns; column++) X { X prediction=(int) cs->pixel-(int) ls->pixel; X ls++; X prediction+=(int) ls->pixel; X state=statistics[cs->state][ls->state]; X cs++; X cs->pixel=(*p++); X cs->state=ZeroState; X value=(int) cs->pixel-prediction; X Encode(state,(value == 0 ? No : Yes)); X if (value != 0) X { X /* X Code sign information X */ X state++; X sign=(value < 0 ? -1 : 1); X Encode(state,(sign >= 0 ? No : Yes)); X if (sign < 0) X value=(-value); X else X state++; X state++; X value--; X /* X Branch for code=+-1 X */ X Encode(state,(value == 0 ? No : Yes)); X if (value != 0) X { X /* X Establish magnitude of value. X */ X state=100; X magnitude=2; X while (value >= magnitude) X { X (void) Encode(state,Yes); X if (state < 107) X state++; X magnitude<<=1; X } X (void) Encode(state,No); X /* X Code remaining bits X */ X state+=7; X magnitude>>=2; X if (magnitude != 0) X { X (void) Encode(state,((magnitude & value) == 0 ? No : Yes)); X state+=6; X magnitude>>=1; X while (magnitude != 0) X { X (void) Encode(state,((magnitude & value) == 0 ? No : Yes)); X magnitude>>=1; X } X } X } X if (value >= LowerBound) X if (value < UpperBound) X cs->state= X (sign < ZeroState ? SmallPostitiveState : SmallNegativeState); X else X cs->state= X (sign < ZeroState ? LargePostitiveState : LargeNegativeState); X } X } X } X (void) Flush(); X (void) free((char *) scanline); X return((unsigned int) (q-compressed_pixels)); } SHAR_EOF chmod 0755 ImageMagick/compress.c || echo 'restore of ImageMagick/compress.c failed' Wc_c="`wc -c < 'ImageMagick/compress.c'`" test 23716 -eq "$Wc_c" || echo 'ImageMagick/compress.c: original size 23716, current size' "$Wc_c" rm -f _shar_wnt_.tmp fi # ============= ImageMagick/image.h ============== if test -f 'ImageMagick/image.h' -a X"$1" != X"-c"; then echo 'x - skipping ImageMagick/image.h (File already exists)' rm -f _shar_wnt_.tmp else > _shar_wnt_.tmp echo 'x - extracting ImageMagick/image.h (Text)' sed 's/^X//' << 'SHAR_EOF' > 'ImageMagick/image.h' && X /* X Define declarations. */ #ifdef vms #define pclose(file) exit(1) #define popen(command,mode) exit(1) #endif /* X Image utilities routines. */ extern Image X *CopyImage(), X *ClipImage(), X *EnhanceImage(), X *NoisyImage(), X *ReadImage(), X *ReduceImage(), X *ReflectImage(), X *RotateImage(), X *ScaleImage(), X *TransformImage(), X *ZoomImage(); X extern unsigned int X NumberColors(), X PrintImage(), X ReadData(), X WriteImage(); X extern void X DestroyImage(), X GammaImage(), X GrayImage(), X InverseImage(), X QuantizationError(), X QuantizeImage(); SHAR_EOF chmod 0755 ImageMagick/image.h || echo 'restore of ImageMagick/image.h failed' Wc_c="`wc -c < 'ImageMagick/image.h'`" test 563 -eq "$Wc_c" || echo 'ImageMagick/image.h: original size 563, current size' "$Wc_c" rm -f _shar_wnt_.tmp fi # ============= ImageMagick/filters/Makefile ============== if test ! -d 'ImageMagick/filters'; then echo 'x - creating directory ImageMagick/filters' mkdir 'ImageMagick/filters' fi if test -f 'ImageMagick/filters/Makefile' -a X"$1" != X"-c"; then echo 'x - skipping ImageMagick/filters/Makefile (File already exists)' rm -f _shar_wnt_.tmp else > _shar_wnt_.tmp echo 'x - extracting ImageMagick/filters/Makefile (Text)' sed 's/^X//' << 'SHAR_EOF' > 'ImageMagick/filters/Makefile' && # Makefile generated by imake - do not edit! # $XConsortium: imake.c,v 1.51 89/12/12 12:37:30 jim Exp $ # # The cpp used on this machine replaces all newlines and multiple tabs and # spaces in a macro expansion with a single space. Imake tries to compensate # for this, but is not always successful. # X ########################################################################### # Makefile generated from "Imake.tmpl" and <Imakefile> # $XConsortium: Imake.tmpl,v 1.77 89/12/18 17:01:37 jim Exp $ # # Platform-specific parameters may be set in the appropriate .cf # configuration files. Site-wide parameters may be set in the file # site.def. Full rebuilds are recommended if any parameters are changed. # # If your C preprocessor doesn't define any unique symbols, you'll need # to set BOOTSTRAPCFLAGS when rebuilding imake (usually when doing # "make Makefile", "make Makefiles", or "make World"). # # If you absolutely can't get imake to work, you'll need to set the # variables at the top of each Makefile as well as the dependencies at the # bottom (makedepend will do this automatically). # X ########################################################################### # platform-specific configuration parameters - edit sun.cf to change X # platform: $XConsortium: sun.cf,v 1.38 89/12/23 16:10:10 jim Exp $ # operating system: SunOS 4.0.3 X ########################################################################### # site-specific configuration parameters - edit site.def to change X # site: $XConsortium: site.def,v 1.21 89/12/06 11:46:50 jim Exp $ X X SHELL = /bin/sh X X TOP = . X CURRENT_DIR = . X X AR = ar cq X BOOTSTRAPCFLAGS = X CC = cc X X COMPRESS = compress X CPP = /lib/cpp $(STD_CPP_DEFINES) X PREPROCESSCMD = cc -E $(STD_CPP_DEFINES) X INSTALL = install X LD = ld X LINT = lint X LINTLIBFLAG = -C X LINTOPTS = -axz X LN = ln -s X MAKE = make X MV = mv X CP = cp X RANLIB = ranlib X RANLIBINSTFLAGS = X RM = rm -f X STD_INCLUDES = X STD_CPP_DEFINES = X STD_DEFINES = X EXTRA_LOAD_FLAGS = X EXTRA_LIBRARIES = X TAGS = ctags X X SHAREDCODEDEF = -DSHAREDCODE X SHLIBDEF = -DSUNSHLIB X X PROTO_DEFINES = X X INSTPGMFLAGS = X X INSTBINFLAGS = -m 0755 X INSTUIDFLAGS = -m 4755 X INSTLIBFLAGS = -m 0664 X INSTINCFLAGS = -m 0444 X INSTMANFLAGS = -m 0444 X INSTDATFLAGS = -m 0444 X INSTKMEMFLAGS = -m 4755 X X DESTDIR = X X TOP_INCLUDES = -I$(INCROOT) X X CDEBUGFLAGS = -O X CCOPTIONS = X COMPATFLAGS = X X ALLINCLUDES = $(STD_INCLUDES) $(TOP_INCLUDES) $(INCLUDES) $(EXTRA_INCLUDES) X ALLDEFINES = $(ALLINCLUDES) $(STD_DEFINES) $(PROTO_DEFINES) $(DEFINES) $(COMPATFLAGS) X CFLAGS = $(CDEBUGFLAGS) $(CCOPTIONS) $(ALLDEFINES) X LINTFLAGS = $(LINTOPTS) -DLINT $(ALLDEFINES) X LDLIBS = $(SYS_LIBRARIES) $(EXTRA_LIBRARIES) X LDOPTIONS = $(CDEBUGFLAGS) $(CCOPTIONS) X LDCOMBINEFLAGS = -X -r X X MACROFILE = sun.cf X RM_CMD = $(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a .emacs_* tags TAGS make.log MakeOut X X IMAKE_DEFINES = X X IRULESRC = $(CONFIGDIR) X IMAKE_CMD = $(IMAKE) -DUseInstalled -I$(IRULESRC) $(IMAKE_DEFINES) X X ICONFIGFILES = $(IRULESRC)/Imake.tmpl $(IRULESRC)/Imake.rules \ X $(IRULESRC)/Project.tmpl $(IRULESRC)/site.def \ X $(IRULESRC)/$(MACROFILE) $(EXTRA_ICONFIGFILES) X ########################################################################### # X Window System Build Parameters # $XConsortium: Project.tmpl,v 1.63 89/12/18 16:46:44 jim Exp $ X ########################################################################### # X Window System make variables; this need to be coordinated with rules # $XConsortium: Project.tmpl,v 1.63 89/12/18 16:46:44 jim Exp $ X X PATHSEP = / X USRLIBDIR = $(DESTDIR)/usr/lib X BINDIR = $(DESTDIR)/usr/bin/X11 X INCROOT = $(DESTDIR)/usr/include X BUILDINCROOT = $(TOP) X BUILDINCDIR = $(BUILDINCROOT)/X11 X BUILDINCTOP = .. X INCDIR = $(INCROOT)/X11 X ADMDIR = $(DESTDIR)/usr/adm X LIBDIR = $(USRLIBDIR)/X11 X CONFIGDIR = $(LIBDIR)/config X LINTLIBDIR = $(USRLIBDIR)/lint X X FONTDIR = $(LIBDIR)/fonts X XINITDIR = $(LIBDIR)/xinit X XDMDIR = $(LIBDIR)/xdm X AWMDIR = $(LIBDIR)/awm X TWMDIR = $(LIBDIR)/twm X GWMDIR = $(LIBDIR)/gwm X MANPATH = $(DESTDIR)/usr/man X MANSOURCEPATH = $(MANPATH)/man X MANDIR = $(MANSOURCEPATH)n X LIBMANDIR = $(MANSOURCEPATH)3 X XAPPLOADDIR = $(LIBDIR)/app-defaults X X SOXLIBREV = 4.2 X SOXTREV = 4.0 X SOXAWREV = 4.0 X SOOLDXREV = 4.0 X SOXMUREV = 4.0 X SOXEXTREV = 4.0 X X FONTCFLAGS = -t X X INSTAPPFLAGS = $(INSTDATFLAGS) X X IMAKE = imake X DEPEND = makedepend X RGB = rgb X FONTC = bdftosnf X MKFONTDIR = mkfontdir X MKDIRHIER = /bin/sh $(BINDIR)/mkdirhier.sh X X CONFIGSRC = $(TOP)/config X CLIENTSRC = $(TOP)/clients X DEMOSRC = $(TOP)/demos X LIBSRC = $(TOP)/lib X FONTSRC = $(TOP)/fonts X INCLUDESRC = $(TOP)/X11 X SERVERSRC = $(TOP)/server X UTILSRC = $(TOP)/util X SCRIPTSRC = $(UTILSRC)/scripts X EXAMPLESRC = $(TOP)/examples X CONTRIBSRC = $(TOP)/../contrib X DOCSRC = $(TOP)/doc X RGBSRC = $(TOP)/rgb X DEPENDSRC = $(UTILSRC)/makedepend X IMAKESRC = $(CONFIGSRC) X XAUTHSRC = $(LIBSRC)/Xau X XLIBSRC = $(LIBSRC)/X X XMUSRC = $(LIBSRC)/Xmu X TOOLKITSRC = $(LIBSRC)/Xt X AWIDGETSRC = $(LIBSRC)/Xaw X OLDXLIBSRC = $(LIBSRC)/oldX X XDMCPLIBSRC = $(LIBSRC)/Xdmcp X BDFTOSNFSRC = $(FONTSRC)/bdftosnf X MKFONTDIRSRC = $(FONTSRC)/mkfontdir X EXTENSIONSRC = $(TOP)/extensions X X DEPEXTENSIONLIB = $(USRLIBDIR)/libXext.a X EXTENSIONLIB = -lXext X X DEPXLIB = $(DEPEXTENSIONLIB) X XLIB = $(EXTENSIONLIB) -lX11 X X DEPXAUTHLIB = $(USRLIBDIR)/libXau.a X XAUTHLIB = -lXau X X DEPXMULIB = X XMULIB = -lXmu X X DEPOLDXLIB = X OLDXLIB = -loldX X X DEPXTOOLLIB = X XTOOLLIB = -lXt X X DEPXAWLIB = X XAWLIB = -lXaw X X LINTEXTENSIONLIB = $(USRLIBDIR)/llib-lXext.ln X LINTXLIB = $(USRLIBDIR)/llib-lX11.ln X LINTXMU = $(USRLIBDIR)/llib-lXmu.ln X LINTXTOOL = $(USRLIBDIR)/llib-lXt.ln X LINTXAW = $(USRLIBDIR)/llib-lXaw.ln X X DEPLIBS = $(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) $(DEPXLIB) X X DEPLIBS1 = $(DEPLIBS) X DEPLIBS2 = $(DEPLIBS) X DEPLIBS3 = $(DEPLIBS) X ########################################################################### # Imake rules for building libraries, programs, scripts, and data files # rules: $XConsortium: Imake.rules,v 1.67 89/12/18 17:14:15 jim Exp $ X ########################################################################### # start of Imakefile X EXTRA_INCLUDES= -I/usr/local/include -I.. EXTRA_LIBRARIES= -lX11 -lm PPM_LIBRARIES= /usr/local/lib/libppm.a /usr/local/lib/libpgm.a \ X /usr/local/lib/libpbm.a TIFF_LIBRARIES= /usr/local/lib/libtiff.a X AVStoMIFFSources= AVStoMIFF.c AVStoMIFFObjects= AVStoMIFF.o image.o compress.o GIFtoMIFFSources= GIFtoMIFF.c GIFtoMIFFObjects= GIFtoMIFF.o image.o compress.o GRAYtoMIFFSources= GRAYtoMIFF.c GRAYtoMIFFObjects= GRAYtoMIFF.o image.o compress.o MIFFtoAVSSources= MIFFtoAVS.c MIFFtoAVSObjects= MIFFtoAVS.o image.o compress.o MIFFtoGIFSources= MIFFtoGIF.c MIFFtoGIFObjects= MIFFtoGIF.o image.o kolb.o quantize.o compress.o MIFFtoGRAYSources= MIFFtoGRAY.c MIFFtoGRAYObjects= MIFFtoGRAY.o image.o kolb.o quantize.o compress.o MIFFtoPPMSources= MIFFtoPPM.c MIFFtoPPMObjects= MIFFtoPPM.o image.o compress.o MIFFtoRGBSources= MIFFtoRGB.c MIFFtoRGBObjects= MIFFtoRGB.o image.o compress.o MIFFtoSUNSources= MIFFtoSUN.c MIFFtoSUNObjects= MIFFtoSUN.o image.o compress.o MIFFtoTIFFSources= MIFFtoTIFF.c MIFFtoTIFFObjects= MIFFtoTIFF.o image.o compress.o MIFFtoXBMSources= MIFFtoXBM.c MIFFtoXBMObjects= MIFFtoXBM.o image.o kolb.o quantize.o compress.o MIFFtoXWDSources= MIFFtoXWD.c MIFFtoXWDObjects= MIFFtoXWD.o image.o compress.o MTVtoMIFFSources= MTVtoMIFF.c MTVtoMIFFObjects= MTVtoMIFF.o image.o compress.o SUNtoMIFFSources= SUNtoMIFF.c SUNtoMIFFObjects= SUNtoMIFF.o image.o compress.o RGBtoMIFFSources= RGBtoMIFF.c RGBtoMIFFObjects= RGBtoMIFF.o image.o compress.o PPMtoMIFFSources= PPMtoMIFF.c PPMtoMIFFObjects= PPMtoMIFF.o image.o kolb.o quantize.o colors.o compress.o TIFFtoMIFFSources= TIFFtoMIFF.c TIFFtoMIFFObjects= TIFFtoMIFF.o image.o kolb.o quantize.o compress.o XXBMtoMIFFSources= XBMtoMIFF.c XXBMtoMIFFObjects= XBMtoMIFF.o image.o compress.o XXWDtoMIFFSources= XWDtoMIFF.c XXWDtoMIFFObjects= XWDtoMIFF.o image.o compress.o X PROGRAMS= AVStoMIFF MIFFtoAVS GIFtoMIFF MIFFtoGIF GRAYtoMIFF MIFFtoGRAY \ X MTVtoMIFF RGBtoMIFF MIFFtoRGB SUNtoMIFF MIFFtoSUN XBMtoMIFF MIFFtoXBM \ X XWDtoMIFF MIFFtoXWD PPMtoMIFF MIFFtoPPM TIFFtoMIFF MIFFtoTIFF X all:: $(PROGRAMS) X AVStoMIFF: $(AVStoMIFFObjects) X $(RM) $@ X $(CC) -o $@ $(AVStoMIFFObjects) $(LDOPTIONS) $(LDLIBS) $(EXTRA_LOAD_FLAGS) X clean:: X $(RM) AVStoMIFF X install:: AVStoMIFF X $(INSTALL) -c $(INSTPGMFLAGS) AVStoMIFF $(BINDIR) X MIFFtoAVS: $(MIFFtoAVSObjects) X $(RM) $@ X $(CC) -o $@ $(MIFFtoAVSObjects) $(LDOPTIONS) $(LDLIBS) $(EXTRA_LOAD_FLAGS) X clean:: X $(RM) MIFFtoAVS X install:: MIFFtoAVS X $(INSTALL) -c $(INSTPGMFLAGS) MIFFtoAVS $(BINDIR) X GIFtoMIFF: $(GIFtoMIFFObjects) X $(RM) $@ X $(CC) -o $@ $(GIFtoMIFFObjects) $(LDOPTIONS) $(LDLIBS) $(EXTRA_LOAD_FLAGS) X clean:: X $(RM) GIFtoMIFF X install:: GIFtoMIFF X $(INSTALL) -c $(INSTPGMFLAGS) GIFtoMIFF $(BINDIR) X MIFFtoGIF: $(MIFFtoGIFObjects) X $(RM) $@ X $(CC) -o $@ $(MIFFtoGIFObjects) $(LDOPTIONS) $(LDLIBS) $(EXTRA_LOAD_FLAGS) X clean:: X $(RM) MIFFtoGIF X install:: MIFFtoGIF X $(INSTALL) -c $(INSTPGMFLAGS) MIFFtoGIF $(BINDIR) X GRAYtoMIFF: $(GRAYtoMIFFObjects) X $(RM) $@ X $(CC) -o $@ $(GRAYtoMIFFObjects) $(LDOPTIONS) $(LDLIBS) $(EXTRA_LOAD_FLAGS) X clean:: X $(RM) GRAYtoMIFF X install:: GRAYtoMIFF X $(INSTALL) -c $(INSTPGMFLAGS) GRAYtoMIFF $(BINDIR) X MIFFtoGRAY: $(MIFFtoGRAYObjects) X $(RM) $@ X $(CC) -o $@ $(MIFFtoGRAYObjects) $(LDOPTIONS) $(LDLIBS) $(EXTRA_LOAD_FLAGS) X clean:: X $(RM) MIFFtoGRAY X install:: MIFFtoGRAY X $(INSTALL) -c $(INSTPGMFLAGS) MIFFtoGRAY $(BINDIR) X MTVtoMIFF: $(MTVtoMIFFObjects) X $(RM) $@ X $(CC) -o $@ $(MTVtoMIFFObjects) $(LDOPTIONS) $(LDLIBS) $(EXTRA_LOAD_FLAGS) X clean:: X $(RM) MTVtoMIFF X install:: MTVtoMIFF X $(INSTALL) -c $(INSTPGMFLAGS) MTVtoMIFF $(BINDIR) X RGBtoMIFF: $(RGBtoMIFFObjects) X $(RM) $@ X $(CC) -o $@ $(RGBtoMIFFObjects) $(LDOPTIONS) $(LDLIBS) $(EXTRA_LOAD_FLAGS) X clean:: X $(RM) RGBtoMIFF X install:: RGBtoMIFF X $(INSTALL) -c $(INSTPGMFLAGS) RGBtoMIFF $(BINDIR) X MIFFtoRGB: $(MIFFtoRGBObjects) X $(RM) $@ X $(CC) -o $@ $(MIFFtoRGBObjects) $(LDOPTIONS) $(LDLIBS) $(EXTRA_LOAD_FLAGS) X clean:: X $(RM) MIFFtoRGB X install:: MIFFtoRGB X $(INSTALL) -c $(INSTPGMFLAGS) MIFFtoRGB $(BINDIR) X SUNtoMIFF: $(SUNtoMIFFObjects) X $(RM) $@ X $(CC) -o $@ $(SUNtoMIFFObjects) $(LDOPTIONS) $(LDLIBS) $(EXTRA_LOAD_FLAGS) X clean:: X $(RM) SUNtoMIFF X install:: SUNtoMIFF X $(INSTALL) -c $(INSTPGMFLAGS) SUNtoMIFF $(BINDIR) X MIFFtoSUN: $(MIFFtoSUNObjects) X $(RM) $@ X $(CC) -o $@ $(MIFFtoSUNObjects) $(LDOPTIONS) $(LDLIBS) $(EXTRA_LOAD_FLAGS) X clean:: X $(RM) MIFFtoSUN X install:: MIFFtoSUN X $(INSTALL) -c $(INSTPGMFLAGS) MIFFtoSUN $(BINDIR) X XXBMtoMIFF: $(XBMtoMIFFObjects) X $(RM) $@ X $(CC) -o $@ $(XBMtoMIFFObjects) $(LDOPTIONS) $(LDLIBS) $(EXTRA_LOAD_FLAGS) X clean:: X $(RM) XBMtoMIFF X install:: XBMtoMIFF X $(INSTALL) -c $(INSTPGMFLAGS) XBMtoMIFF $(BINDIR) X MIFFtoXBM: $(MIFFtoXBMObjects) X $(RM) $@ X $(CC) -o $@ $(MIFFtoXBMObjects) $(LDOPTIONS) $(LDLIBS) $(EXTRA_LOAD_FLAGS) X clean:: X $(RM) MIFFtoXBM X install:: MIFFtoXBM X $(INSTALL) -c $(INSTPGMFLAGS) MIFFtoXBM $(BINDIR) X XXWDtoMIFF: $(XWDtoMIFFObjects) X $(RM) $@ X $(CC) -o $@ $(XWDtoMIFFObjects) $(LDOPTIONS) $(LDLIBS) $(EXTRA_LOAD_FLAGS) X clean:: X $(RM) XWDtoMIFF X install:: XWDtoMIFF X $(INSTALL) -c $(INSTPGMFLAGS) XWDtoMIFF $(BINDIR) X MIFFtoXWD: $(MIFFtoXWDObjects) X $(RM) $@ X $(CC) -o $@ $(MIFFtoXWDObjects) $(LDOPTIONS) $(LDLIBS) $(EXTRA_LOAD_FLAGS) X clean:: X $(RM) MIFFtoXWD X install:: MIFFtoXWD X $(INSTALL) -c $(INSTPGMFLAGS) MIFFtoXWD $(BINDIR) X PPMtoMIFF: $(PPMtoMIFFObjects) X $(RM) $@ X $(CC) -o $@ $(PPMtoMIFFObjects) $(LDOPTIONS) $(PPM_LIBRARIES) $(LDLIBS) $(EXTRA_LOAD_FLAGS) X clean:: X $(RM) PPMtoMIFF X install:: PPMtoMIFF X $(INSTALL) -c $(INSTPGMFLAGS) PPMtoMIFF $(BINDIR) X MIFFtoPPM: $(MIFFtoPPMObjects) X $(RM) $@ X $(CC) -o $@ $(MIFFtoPPMObjects) $(LDOPTIONS) $(PPM_LIBRARIES) $(LDLIBS) $(EXTRA_LOAD_FLAGS) X clean:: X $(RM) MIFFtoPPM X install:: MIFFtoPPM X $(INSTALL) -c $(INSTPGMFLAGS) MIFFtoPPM $(BINDIR) X TIFFtoMIFF: $(TIFFtoMIFFObjects) X $(RM) $@ X $(CC) -o $@ $(TIFFtoMIFFObjects) $(LDOPTIONS) $(TIFF_LIBRARIES) $(LDLIBS) $(EXTRA_LOAD_FLAGS) SHAR_EOF true || echo 'restore of ImageMagick/filters/Makefile failed' fi echo 'End of ImageMagick part 11' echo 'File ImageMagick/filters/Makefile is continued in part 12' echo 12 > _shar_seq_.tmp exit 0 -- Dan Heller O'Reilly && Associates Z-Code Software Comp-sources-x: Senior Writer President comp-sources-x@uunet.uu.net argv@ora.com argv@zipcode.com