Skip to content

Commit

Permalink
Reverted transparency fix, was problem with CMYK negate.
Browse files Browse the repository at this point in the history
  • Loading branch information
dirk committed Nov 11, 2014
1 parent 0b76375 commit d9795a1
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions coders/psd.c
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,17 @@ static const char *ModeToString(PSDImageType type)
}
}

static void NegateCMYK(Image *image,ExceptionInfo *exception)
{
ChannelType
channel_mask;

channel_mask=SetImageChannelMask(image,(ChannelType)(AllChannels &~
AlphaChannel));
NegateImage(image,MagickFalse,exception);
(void) SetImageChannelMask(image,channel_mask);
}

static MagickBooleanType ParseImageResourceBlocks(Image *image,
const unsigned char *blocks,size_t length,
MagickBooleanType *has_merged_image,ExceptionInfo *exception)
Expand Down Expand Up @@ -689,7 +700,7 @@ static MagickStatusType ReadPSDChannelPixels(Image *image,
{
case -1:
{
SetPixelOpacity(image,pixel,q);
SetPixelAlpha(image,pixel,q);
break;
}
case 0:
Expand Down Expand Up @@ -732,15 +743,15 @@ static MagickStatusType ReadPSDChannelPixels(Image *image,
case 1:
{
if (image->storage_class == PseudoClass)
SetPixelOpacity(image,pixel,q);
SetPixelAlpha(image,pixel,q);
else
SetPixelGreen(image,pixel,q);
break;
}
case 2:
{
if (image->storage_class == PseudoClass)
SetPixelOpacity(image,pixel,q);
SetPixelAlpha(image,pixel,q);
else
SetPixelBlue(image,pixel,q);
break;
Expand All @@ -751,7 +762,7 @@ static MagickStatusType ReadPSDChannelPixels(Image *image,
SetPixelBlack(image,pixel,q);
else
if (image->alpha_trait != UndefinedPixelTrait)
SetPixelOpacity(image,pixel,q);
SetPixelAlpha(image,pixel,q);
break;
}
case 4:
Expand All @@ -760,7 +771,7 @@ static MagickStatusType ReadPSDChannelPixels(Image *image,
(channels > 3))
break;
if (image->alpha_trait != UndefinedPixelTrait)
SetPixelOpacity(image,pixel,q);
SetPixelAlpha(image,pixel,q);
break;
}
default:
Expand Down Expand Up @@ -1146,6 +1157,7 @@ static MagickStatusType ReadPSDLayer(Image *image,const PSDInfo *psd_info,
layer_info->image->compression=ConvertPSDCompression(compression);
if (layer_info->channel_info[j].type == -1)
layer_info->image->alpha_trait=BlendPixelTrait;

status=ReadPSDChannel(layer_info->image,psd_info,layer_info,j,
compression,exception);

Expand All @@ -1157,7 +1169,7 @@ static MagickStatusType ReadPSDLayer(Image *image,const PSDInfo *psd_info,
status=CorrectPSDOpacity(layer_info,exception);

if (status != MagickFalse && layer_info->image->colorspace == CMYKColorspace)
(void) NegateImage(layer_info->image,MagickFalse,exception);
(void) NegateCMYK(layer_info->image,exception);

return(status);
}
Expand Down Expand Up @@ -1556,7 +1568,7 @@ static MagickStatusType ReadPSDMergedImage(Image* image,
}

if (image->colorspace == CMYKColorspace)
(void) NegateImage(image,MagickFalse,exception);
(void) NegateCMYK(image,exception);

if (offsets != (MagickOffsetType *) NULL)
offsets=(MagickOffsetType *) RelinquishMagickMemory(offsets);
Expand Down Expand Up @@ -2230,7 +2242,7 @@ static MagickBooleanType WriteImageChannels(const PSDInfo *psd_info,
else
{
if (next_image->colorspace == CMYKColorspace)
(void) NegateImage(next_image,MagickFalse,exception);
(void) NegateCMYK(next_image,exception);
if (next_image->compression == RLECompression)
{
/*
Expand Down Expand Up @@ -2274,7 +2286,7 @@ static MagickBooleanType WriteImageChannels(const PSDInfo *psd_info,
MagickFalse,exception);
(void) SetImageProgress(image,SaveImagesTag,5,6);
if (next_image->colorspace == CMYKColorspace)
(void) NegateImage(next_image,MagickFalse,exception);
(void) NegateCMYK(next_image,exception);
}
if (next_image->compression == RLECompression)
compact_pixels=(unsigned char *) RelinquishMagickMemory(compact_pixels);
Expand Down

0 comments on commit d9795a1

Please sign in to comment.