mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-09 23:34:20 +00:00
Component: Use Context appropriate ImageType for temporary images
Co-authored-by: Matt Gonzalez <matt@echoaudio.com>
This commit is contained in:
parent
250abe9cf4
commit
4ba01a80a0
3 changed files with 16 additions and 6 deletions
|
|
@ -216,7 +216,12 @@ public:
|
|||
|
||||
if (effectImage.getBounds() != scaledBounds)
|
||||
{
|
||||
effectImage = Image { c.isOpaque() ? Image::RGB : Image::ARGB, scaledBounds.getWidth(), scaledBounds.getHeight(), false };
|
||||
auto tempImageType = g.getInternalContext().getPreferredImageTypeForTemporaryImages();
|
||||
effectImage = Image { c.isOpaque() ? Image::RGB : Image::ARGB,
|
||||
scaledBounds.getWidth(),
|
||||
scaledBounds.getHeight(),
|
||||
false,
|
||||
*tempImageType };
|
||||
effectImage.setBackupEnabled (false);
|
||||
}
|
||||
|
||||
|
|
@ -1814,7 +1819,9 @@ bool Component::isPaintingUnclipped() const noexcept
|
|||
|
||||
//==============================================================================
|
||||
Image Component::createComponentSnapshot (Rectangle<int> areaToGrab,
|
||||
bool clipImageToComponentBounds, float scaleFactor)
|
||||
bool clipImageToComponentBounds,
|
||||
float scaleFactor,
|
||||
const ImageType& imageType)
|
||||
{
|
||||
auto r = areaToGrab;
|
||||
|
||||
|
|
@ -1827,7 +1834,7 @@ Image Component::createComponentSnapshot (Rectangle<int> areaToGrab,
|
|||
auto w = roundToInt (scaleFactor * (float) r.getWidth());
|
||||
auto h = roundToInt (scaleFactor * (float) r.getHeight());
|
||||
|
||||
Image image (flags.opaqueFlag ? Image::RGB : Image::ARGB, w, h, true);
|
||||
Image image (flags.opaqueFlag ? Image::RGB : Image::ARGB, w, h, true, imageType);
|
||||
|
||||
Graphics g (image);
|
||||
|
||||
|
|
|
|||
|
|
@ -1147,7 +1147,7 @@ public:
|
|||
|
||||
/** Generates a snapshot of part of this component.
|
||||
|
||||
This will return a new Image, the size of the rectangle specified,
|
||||
This will return a new Image of type imageType, the size of the rectangle specified,
|
||||
containing a snapshot of the specified area of the component and all
|
||||
its children.
|
||||
|
||||
|
|
@ -1162,7 +1162,8 @@ public:
|
|||
*/
|
||||
Image createComponentSnapshot (Rectangle<int> areaToGrab,
|
||||
bool clipImageToComponentBounds = true,
|
||||
float scaleFactor = 1.0f);
|
||||
float scaleFactor = 1.0f,
|
||||
const ImageType& imageType = NativeImageType{});
|
||||
|
||||
/** Draws this component and all its subcomponents onto the specified graphics
|
||||
context.
|
||||
|
|
|
|||
|
|
@ -50,11 +50,13 @@ struct StandardCachedComponentImage : public CachedComponentImage
|
|||
|
||||
if (image.isNull() || image.getBounds() != imageBounds)
|
||||
{
|
||||
auto tempImageType = g.getInternalContext().getPreferredImageTypeForTemporaryImages();
|
||||
image = Image (owner.isOpaque() ? Image::RGB
|
||||
: Image::ARGB,
|
||||
jmax (1, imageBounds.getWidth()),
|
||||
jmax (1, imageBounds.getHeight()),
|
||||
! owner.isOpaque());
|
||||
! owner.isOpaque(),
|
||||
*tempImageType);
|
||||
image.setBackupEnabled (false);
|
||||
validArea.clear();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue