Tk Source Code

Check-in [d2fc5a3c]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:[06c3fcb136] ImgGetPhoto() had some code misplaced in an earlier commit so that it failed to tell all callers when the alpha channel was fully opaque. This triggered another bug in the PNG writer where the alpha vs. non-alpha format choice was broken and confused, leading to corrupt png image files.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: d2fc5a3c29c75351f52f0afb6a92fcd238a7ce68
User & Date: dgp 2015-05-05 19:38:12
Context
2015-05-15
12:03
Use assertion to prevent writing pixel lines beyond end of Photo image block. check-in: 76765f50 user: dgp tags: trunk
2015-05-05
19:38
[06c3fcb136] ImgGetPhoto() had some code misplaced in an earlier commit so that it failed to tell all callers when the alpha channel was fully opaque. This triggered another bug in the PNG writer where the alpha vs. non-alpha format choice was broken and confused, leading to corrupt png image files. check-in: d2fc5a3c user: dgp tags: trunk
19:30
[3603436][06c3fcb136] Correction to earlier bugfix. When alpha values are all opaque, so that image format writers may use non-alpha supporting formats losslessly, make sure that message always gets back to the caller. check-in: 8d981ccf user: dgp tags: core-8-5-branch
2015-04-28
18:46
merge mark check-in: 90f5a7ac user: fvogel tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/tkImgPNG.c.

3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
    }

    if ((greenOffset != 0) || (blueOffset != 0)) {
	if (alphaOffset) {
	    pngPtr->colorType = PNG_COLOR_RGBA;
	    pngPtr->bytesPerPixel = 4;
	} else {
	    pngPtr->colorType = PNG_COLOR_RGBA;
	    pngPtr->bytesPerPixel = 3;
	}
    } else {
	if (alphaOffset) {
	    pngPtr->colorType = PNG_COLOR_GRAYALPHA;
	    pngPtr->bytesPerPixel = 2;
	} else {







|







3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
    }

    if ((greenOffset != 0) || (blueOffset != 0)) {
	if (alphaOffset) {
	    pngPtr->colorType = PNG_COLOR_RGBA;
	    pngPtr->bytesPerPixel = 4;
	} else {
	    pngPtr->colorType = PNG_COLOR_RGB;
	    pngPtr->bytesPerPixel = 3;
	}
    } else {
	if (alphaOffset) {
	    pngPtr->colorType = PNG_COLOR_GRAYALPHA;
	    pngPtr->bytesPerPixel = 2;
	} else {

Changes to generic/tkImgPhoto.c.

3679
3680
3681
3682
3683
3684
3685



3686
3687
3688
3689
3690
3691
3692
	    }
	    pixelPtr += blockPtr->pixelSize;
	}
	if (alphaOffset) {
	    break;
	}
    }



    greenOffset = blockPtr->offset[1] - blockPtr->offset[0];
    blueOffset = blockPtr->offset[2] - blockPtr->offset[0];
    if (((optPtr->options & OPT_BACKGROUND) && alphaOffset) ||
	    ((optPtr->options & OPT_GRAYSCALE) && (greenOffset||blueOffset))) {
	int newPixelSize,x,y;
	unsigned char *srcPtr, *destPtr;
	char *data;







>
>
>







3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
	    }
	    pixelPtr += blockPtr->pixelSize;
	}
	if (alphaOffset) {
	    break;
	}
    }
    if (!alphaOffset) {
	blockPtr->offset[3]= -1; /* Tell caller alpha need not be read */
    }
    greenOffset = blockPtr->offset[1] - blockPtr->offset[0];
    blueOffset = blockPtr->offset[2] - blockPtr->offset[0];
    if (((optPtr->options & OPT_BACKGROUND) && alphaOffset) ||
	    ((optPtr->options & OPT_GRAYSCALE) && (greenOffset||blueOffset))) {
	int newPixelSize,x,y;
	unsigned char *srcPtr, *destPtr;
	char *data;
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
	    blockPtr->offset[2] = 2;
	    blockPtr->offset[3]= 3;
	} else {
	    blockPtr->offset[1] = 0;
	    blockPtr->offset[2] = 0;
	    blockPtr->offset[3]= 1;
	}
	if (!alphaOffset) {
	  blockPtr->offset[3]= -1;
	}
	return data;
    }
    return NULL;
}

/*
 *----------------------------------------------------------------------







<
<
<







3802
3803
3804
3805
3806
3807
3808



3809
3810
3811
3812
3813
3814
3815
	    blockPtr->offset[2] = 2;
	    blockPtr->offset[3]= 3;
	} else {
	    blockPtr->offset[1] = 0;
	    blockPtr->offset[2] = 0;
	    blockPtr->offset[3]= 1;
	}



	return data;
    }
    return NULL;
}

/*
 *----------------------------------------------------------------------