Browse Source

CoreGraphics alpha-channel clipping fix.

tags/2021-05-28
Julian Storer 15 years ago
parent
commit
88ca4b9901
3 changed files with 15 additions and 10 deletions
  1. +8
    -5
      juce_amalgamated.cpp
  2. +6
    -5
      src/gui/graphics/imaging/juce_Image.cpp
  3. +1
    -0
      src/native/mac/juce_mac_CoreGraphicsContext.mm

+ 8
- 5
juce_amalgamated.cpp View File

@@ -95464,7 +95464,8 @@ const Image Image::convertedToFormat (PixelFormat newFormat) const
if (image == 0 || newFormat == image->format)
return *this;

Image newImage (newFormat, image->width, image->height, false, image->getType());
const int w = image->width, h = image->height;
Image newImage (newFormat, w, h, false, image->getType());

if (newFormat == SingleChannel)
{
@@ -95474,15 +95475,15 @@ const Image Image::convertedToFormat (PixelFormat newFormat) const
}
else
{
const BitmapData destData (newImage, 0, 0, image->width, image->height, true);
const BitmapData srcData (*this, 0, 0, image->width, image->height);
const BitmapData destData (newImage, 0, 0, w, h, true);
const BitmapData srcData (*this, 0, 0, w, h);

for (int y = 0; y < image->height; ++y)
for (int y = 0; y < h; ++y)
{
const PixelARGB* src = (const PixelARGB*) srcData.getLinePointer(y);
uint8* dst = destData.getLinePointer (y);

for (int x = image->width; --x >= 0;)
for (int x = w; --x >= 0;)
{
*dst++ = src->getAlpha();
++src;
@@ -266125,6 +266126,7 @@ public:
applyTransform (t.inverted());
flip();

CGContextFlush (context);
CGImageRelease (image);
lastClipRectIsValid = false;
}
@@ -270821,6 +270823,7 @@ public:
applyTransform (t.inverted());
flip();

CGContextFlush (context);
CGImageRelease (image);
lastClipRectIsValid = false;
}


+ 6
- 5
src/gui/graphics/imaging/juce_Image.cpp View File

@@ -209,7 +209,8 @@ const Image Image::convertedToFormat (PixelFormat newFormat) const
if (image == 0 || newFormat == image->format)
return *this;
Image newImage (newFormat, image->width, image->height, false, image->getType());
const int w = image->width, h = image->height;
Image newImage (newFormat, w, h, false, image->getType());
if (newFormat == SingleChannel)
{
@@ -219,15 +220,15 @@ const Image Image::convertedToFormat (PixelFormat newFormat) const
}
else
{
const BitmapData destData (newImage, 0, 0, image->width, image->height, true);
const BitmapData srcData (*this, 0, 0, image->width, image->height);
const BitmapData destData (newImage, 0, 0, w, h, true);
const BitmapData srcData (*this, 0, 0, w, h);
for (int y = 0; y < image->height; ++y)
for (int y = 0; y < h; ++y)
{
const PixelARGB* src = (const PixelARGB*) srcData.getLinePointer(y);
uint8* dst = destData.getLinePointer (y);
for (int x = image->width; --x >= 0;)
for (int x = w; --x >= 0;)
{
*dst++ = src->getAlpha();
++src;


+ 1
- 0
src/native/mac/juce_mac_CoreGraphicsContext.mm View File

@@ -277,6 +277,7 @@ public:
applyTransform (t.inverted());
flip();
CGContextFlush (context);
CGImageRelease (image);
lastClipRectIsValid = false;
}


Loading…
Cancel
Save