From 34d83b21d9284c84cff4126bd5fbb52369efa05c Mon Sep 17 00:00:00 2001 From: cristy Date: Mon, 30 May 2011 00:41:18 +0000 Subject: [PATCH] --- coders/dds.c | 12 ++++++------ coders/fpx.c | 2 +- coders/png.c | 4 ++-- coders/xcf.c | 35 ++++++++++++++++------------------- 4 files changed, 25 insertions(+), 28 deletions(-) diff --git a/coders/dds.c b/coders/dds.c index fa1e0c719..6e2115d68 100644 --- a/coders/dds.c +++ b/coders/dds.c @@ -641,8 +641,8 @@ static MagickBooleanType ReadDXT3(Image *image, DDSInfo *dds_info) alpha = 17U * (unsigned char) ((a0 >> (4*(4*j+i))) & 0xf); else alpha = 17U * (unsigned char) ((a1 >> (4*(4*(j-2)+i))) & 0xf); - SetOpacityPixelComponent(q,ScaleCharToQuantum((unsigned char) - (255-alpha))); + SetAlphaPixelComponent(q,ScaleCharToQuantum((unsigned char) + alpha)); q++; } } @@ -745,8 +745,8 @@ static MagickBooleanType ReadDXT5(Image *image, DDSInfo *dds_info) alpha = 255; else alpha = (((6-alpha_code) * a0 + (alpha_code-1) * a1) / 5); - SetOpacityPixelComponent(q,ScaleCharToQuantum((unsigned char) - (255-alpha))); + SetAlphaPixelComponent(q,ScaleCharToQuantum((unsigned char) + alpha)); q++; } } @@ -830,8 +830,8 @@ static MagickBooleanType ReadUncompressedRGBA(Image *image, DDSInfo *dds_info) ReadBlobByte(image))); SetRedPixelComponent(q,ScaleCharToQuantum((unsigned char) ReadBlobByte(image))); - SetOpacityPixelComponent(q,ScaleCharToQuantum((unsigned char) - (255-ReadBlobByte(image)))); + SetAlphaPixelComponent(q,ScaleCharToQuantum((unsigned char) + ReadBlobByte(image))); q++; } diff --git a/coders/fpx.c b/coders/fpx.c index 6d921990b..7d7c14a63 100644 --- a/coders/fpx.c +++ b/coders/fpx.c @@ -473,7 +473,7 @@ static Image *ReadFPXImage(const ImageInfo *image_info,ExceptionInfo *exception) } SetOpacityPixelComponent(q,OpaqueOpacity); if (image->matte != MagickFalse) - SetOpacityPixelComponent(q,ScaleCharToQuantum(255-*a)); + SetAlphaPixelComponent(q,ScaleCharToQuantum(*a)); q++; r+=red_component->columnStride; g+=green_component->columnStride; diff --git a/coders/png.c b/coders/png.c index 93a28d484..3f12048c4 100644 --- a/coders/png.c +++ b/coders/png.c @@ -3070,8 +3070,8 @@ static Image *ReadOnePNGImage(MngInfo *mng_info, * In a PNG datastream, Opaque is QuantumRange * and Transparent is 0. */ - SetOpacityPixelComponent(q, - ScaleCharToQuantum((unsigned char) (255-(*p++)))); + SetAlphaPixelComponent(q,ScaleCharToQuantum((unsigned char) + *p++)); if (GetOpacityPixelComponent(q) != OpaqueOpacity) found_transparent_pixel = MagickTrue; q++; diff --git a/coders/xcf.c b/coders/xcf.c index b0cea2877..f34483245 100644 --- a/coders/xcf.c +++ b/coders/xcf.c @@ -377,8 +377,8 @@ static MagickBooleanType load_tile(Image *image,Image *tile_image, SetRedPixelComponent(q,ScaleCharToQuantum(*graydata)); SetGreenPixelComponent(q,GetRedPixelComponent(q)); SetBluePixelComponent(q,GetRedPixelComponent(q)); - SetOpacityPixelComponent(q,ScaleCharToQuantum( - (unsigned char) (255-inLayerInfo->opacity))); + SetAlphaPixelComponent(q,ScaleCharToQuantum((unsigned char) + inLayerInfo->opacity)); graydata++; q++; } @@ -391,9 +391,8 @@ static MagickBooleanType load_tile(Image *image,Image *tile_image, SetRedPixelComponent(q,ScaleCharToQuantum(xcfdata->red)); SetGreenPixelComponent(q,ScaleCharToQuantum(xcfdata->green)); SetBluePixelComponent(q,ScaleCharToQuantum(xcfdata->blue)); - SetOpacityPixelComponent(q,xcfdata->opacity == 0U ? - TransparentOpacity : ScaleCharToQuantum((unsigned char) (255- - inLayerInfo->opacity))); + SetAlphaPixelComponent(q,xcfdata->opacity == 0U ? OpaqueOpacity : + ScaleCharToQuantum((unsigned char) inLayerInfo->opacity)); xcfdata++; q++; } @@ -480,15 +479,15 @@ static MagickBooleanType load_tile_rle(Image *image,Image *tile_image, { SetGreenPixelComponent(q,ScaleCharToQuantum(data)); SetBluePixelComponent(q,ScaleCharToQuantum(data)); - SetOpacityPixelComponent(q,ScaleCharToQuantum( - (unsigned char) (255-inLayerInfo->opacity))); + SetAlphaPixelComponent(q,ScaleCharToQuantum( + (unsigned char) inLayerInfo->opacity)); } else { SetGreenPixelComponent(q,GetRedPixelComponent(q)); SetBluePixelComponent(q,GetRedPixelComponent(q)); - SetOpacityPixelComponent(q,ScaleCharToQuantum( - (unsigned char) (255-inLayerInfo->opacity))); + SetAlphaPixelComponent(q,ScaleCharToQuantum( + (unsigned char) inLayerInfo->opacity)); } break; } @@ -504,9 +503,8 @@ static MagickBooleanType load_tile_rle(Image *image,Image *tile_image, } case 3: { - SetOpacityPixelComponent(q,data == 0 ? TransparentOpacity : - ScaleCharToQuantum((unsigned char) (255- - inLayerInfo->opacity))); + SetAlphaPixelComponent(q,data == 0 ? OpaqueOpacity : + ScaleCharToQuantum((unsigned char) inLayerInfo->opacity)); break; } } @@ -541,15 +539,15 @@ static MagickBooleanType load_tile_rle(Image *image,Image *tile_image, { SetGreenPixelComponent(q,ScaleCharToQuantum(data)); SetBluePixelComponent(q,ScaleCharToQuantum(data)); - SetOpacityPixelComponent(q,ScaleCharToQuantum( - (unsigned char) (255-inLayerInfo->opacity))); + SetAlphaPixelComponent(q,ScaleCharToQuantum( + (unsigned char) inLayerInfo->opacity)); } else { SetGreenPixelComponent(q,GetRedPixelComponent(q)); SetBluePixelComponent(q,GetRedPixelComponent(q)); - SetOpacityPixelComponent(q,ScaleCharToQuantum( - (unsigned char) (255-inLayerInfo->opacity))); + SetAlphaPixelComponent(q,ScaleCharToQuantum( + (unsigned char) inLayerInfo->opacity)); } break; } @@ -565,9 +563,8 @@ static MagickBooleanType load_tile_rle(Image *image,Image *tile_image, } case 3: { - SetOpacityPixelComponent(q,data == 0 ? TransparentOpacity : - ScaleCharToQuantum((unsigned char) (255- - inLayerInfo->opacity))); + SetAlphaPixelComponent(q,data == 0 ? OpaqueOpacity : + ScaleCharToQuantum((unsigned char) inLayerInfo->opacity)); break; } } -- 2.40.0