dbs@decpa.pa.dec.com (dan sears) (06/01/90)
Submitted-by: dbs@decpa.pa.dec.com (dan sears) Posting-number: Volume 7, Issue 80 Archive-name: xtiff/patch2 Patch-To: xtiff: Volume 7, Issue 36, 54 This patch fixes a bug in xtiff dealing with MINISWHTE images. --Dan Sears NB: xtiff.c requires libtiff version 2.2, which is currently in beta test. -- cut here (patch.01) -- diff -r -c rev1/patchlevel.h rev2/patchlevel.h *** rev1/patchlevel.h Tue May 29 19:06:26 1990 --- rev2/patchlevel.h Tue May 29 19:02:02 1990 *************** *** 1 **** ! #define PATCHLEVEL 1 --- 1 ---- ! #define PATCHLEVEL 2 diff -r -c rev1/xtiff.c rev2/xtiff.c *** rev1/xtiff.c Tue May 29 19:06:27 1990 --- rev2/xtiff.c Tue May 29 19:02:03 1990 *************** *** 4,9 **** --- 4,11 ---- * Dan Sears * Chris Sears * + * Revsion 1.2 90/05/29 + * Fixed a bug with MINISWHTE images. * Revsion 1.1 90/05/16 * Fixed a few minor bugs. * Revsion 1.0 90/05/07 *************** *** 486,493 **** xGcValues.function = GXcopy; xGcValues.plane_mask = AllPlanes; ! xGcValues.foreground = XWhitePixel(xDisplay, xScreen); ! xGcValues.background = XBlackPixel(xDisplay, xScreen); xWinGc = XCreateGC(xDisplay, xWindow, GCFunction | GCPlaneMask | GCForeground | GCBackground, &xGcValues); --- 488,500 ---- xGcValues.function = GXcopy; xGcValues.plane_mask = AllPlanes; ! if (tfPhotometricInterpretation == PHOTOMETRIC_MINISWHITE) { ! xGcValues.foreground = XWhitePixel(xDisplay, xScreen); ! xGcValues.background = XBlackPixel(xDisplay, xScreen); ! } else { ! xGcValues.foreground = XBlackPixel(xDisplay, xScreen); ! xGcValues.background = XWhitePixel(xDisplay, xScreen); ! } xWinGc = XCreateGC(xDisplay, xWindow, GCFunction | GCPlaneMask | GCForeground | GCBackground, &xGcValues); *************** *** 502,508 **** size_hints.height = size_hints.min_height = size_hints.max_height = tfImageHeight; ! XSetStandardProperties(xDisplay, xWindow, programName, programName, xTiffIconPixmap, xargv, xargc, &size_hints); if (colors != NULL) --- 509,515 ---- size_hints.height = size_hints.min_height = size_hints.max_height = tfImageHeight; ! XSetStandardProperties(xDisplay, xWindow, fileName, fileName, xTiffIconPixmap, xargv, xargc, &size_hints); if (colors != NULL) *************** *** 587,614 **** } } } else { ! /* ! * If the image is 1-bit and PHOTOMETRIC_MINISWHITE then invert ! * the image because we use the default colormap and can't change it. ! */ ! if ((tfPhotometricInterpretation == PHOTOMETRIC_MINISWHITE) ! && (tfImageDepth == 1)) { output_p = imageMemory = (u_char *) malloc(tfBytesPerRow * tfImageHeight); MCHECK(imageMemory); - for (i = 0; i < tfImageHeight; i++, output_p += tfBytesPerRow) { - if (TIFFReadScanline(tfFile, output_p, i, 0) < 0) - break; - input_p = output_p; - for (j = 0; j < tfBytesPerRow; j++, input_p++) - *input_p = ~ *input_p; - } - } else if (xImageDepth == tfImageDepth) { - output_p = imageMemory = (u_char *) - malloc(tfBytesPerRow * tfImageHeight); - MCHECK(imageMemory); - for (i = 0; i < tfImageHeight; i++, output_p += tfBytesPerRow) if (TIFFReadScanline(tfFile, output_p, i, 0) < 0) break; --- 594,604 ---- } } } else { ! if (xImageDepth == tfImageDepth) { output_p = imageMemory = (u_char *) malloc(tfBytesPerRow * tfImageHeight); MCHECK(imageMemory); for (i = 0; i < tfImageHeight; i++, output_p += tfBytesPerRow) if (TIFFReadScanline(tfFile, output_p, i, 0) < 0) break; *************** *** 705,712 **** * of depth one and use XCopyPlane(). This is idiomatic. */ if (xImageDepth == 1) { ! xBitmapGc = XCreateGC(xDisplay, xImagePixmap, GCFunction ! | GCPlaneMask | GCForeground | GCBackground, &xGcValues); XPutImage(xDisplay, xImagePixmap, xBitmapGc, xImage, 0, 0, 0, 0, xImage->width, xImage->height); } else --- 695,701 ---- * of depth one and use XCopyPlane(). This is idiomatic. */ if (xImageDepth == 1) { ! xBitmapGc = XCreateGC(xDisplay, xImagePixmap, 0, &xGcValues); XPutImage(xDisplay, xImagePixmap, xBitmapGc, xImage, 0, 0, 0, 0, xImage->width, xImage->height); } else dan ---------------------------------------------------- O'Reilly && Associates argv@sun.com / argv@ora.com Opinions expressed reflect those of the author only.