JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
juce_Image.cpp
Go to the documentation of this file.
1 /*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 By using JUCE, you agree to the terms of both the JUCE 7 End-User License
11 Agreement and JUCE Privacy Policy.
12
13 End User License Agreement: www.juce.com/juce-7-licence
14 Privacy Policy: www.juce.com/juce-privacy-policy
15
16 Or: You may also use this code under the terms of the GPL v3 (see
17 www.gnu.org/licenses).
18
19 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
20 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
21 DISCLAIMED.
22
23 ==============================================================================
24*/
25
26namespace juce
27{
28
29ImagePixelData::ImagePixelData (Image::PixelFormat format, int w, int h)
30 : pixelFormat (format), width (w), height (h)
31{
32 jassert (format == Image::RGB || format == Image::ARGB || format == Image::SingleChannel);
33 jassert (w > 0 && h > 0); // It's illegal to create a zero-sized image!
34}
35
36ImagePixelData::~ImagePixelData()
37{
38 listeners.call ([this] (Listener& l) { l.imageDataBeingDeleted (this); });
39}
40
41void ImagePixelData::sendDataChangeMessage()
42{
43 listeners.call ([this] (Listener& l) { l.imageDataChanged (this); });
44}
45
46int ImagePixelData::getSharedCount() const noexcept
47{
48 return getReferenceCount();
49}
50
51//==============================================================================
52ImageType::ImageType() {}
53ImageType::~ImageType() {}
54
55Image ImageType::convert (const Image& source) const
56{
57 if (source.isNull() || getTypeID() == source.getPixelData()->createType()->getTypeID())
58 return source;
59
60 const Image::BitmapData src (source, Image::BitmapData::readOnly);
61
62 Image newImage (create (src.pixelFormat, src.width, src.height, false));
63 Image::BitmapData dest (newImage, Image::BitmapData::writeOnly);
64
65 if (src.pixelStride == dest.pixelStride && src.pixelFormat == dest.pixelFormat)
66 {
67 for (int y = 0; y < dest.height; ++y)
68 memcpy (dest.getLinePointer (y), src.getLinePointer (y), (size_t) dest.lineStride);
69 }
70 else
71 {
72 for (int y = 0; y < dest.height; ++y)
73 for (int x = 0; x < dest.width; ++x)
74 dest.setPixelColour (x, y, src.getPixelColour (x, y));
75 }
76
77 return newImage;
78}
79
80//==============================================================================
82{
83public:
84 SoftwarePixelData (Image::PixelFormat formatToUse, int w, int h, bool clearImage)
85 : ImagePixelData (formatToUse, w, h),
86 pixelStride (formatToUse == Image::RGB ? 3 : ((formatToUse == Image::ARGB) ? 4 : 1)),
87 lineStride ((pixelStride * jmax (1, w) + 3) & ~3)
88 {
89 imageData.allocate ((size_t) lineStride * (size_t) jmax (1, h), clearImage);
90 }
91
93 {
94 sendDataChangeMessage();
95 return std::make_unique<LowLevelGraphicsSoftwareRenderer> (Image (*this));
96 }
97
98 void initialiseBitmapData (Image::BitmapData& bitmap, int x, int y, Image::BitmapData::ReadWriteMode mode) override
99 {
100 const auto offset = (size_t) x * (size_t) pixelStride + (size_t) y * (size_t) lineStride;
101 bitmap.data = imageData + offset;
102 bitmap.size = (size_t) (height * lineStride) - offset;
103 bitmap.pixelFormat = pixelFormat;
104 bitmap.lineStride = lineStride;
105 bitmap.pixelStride = pixelStride;
106
107 if (mode != Image::BitmapData::readOnly)
108 sendDataChangeMessage();
109 }
110
112 {
113 auto s = new SoftwarePixelData (pixelFormat, width, height, false);
114 memcpy (s->imageData, imageData, (size_t) lineStride * (size_t) height);
115 return *s;
116 }
117
118 std::unique_ptr<ImageType> createType() const override { return std::make_unique<SoftwareImageType>(); }
119
120private:
121 HeapBlock<uint8> imageData;
122 const int pixelStride, lineStride;
123
125};
126
127SoftwareImageType::SoftwareImageType() {}
128SoftwareImageType::~SoftwareImageType() {}
129
130ImagePixelData::Ptr SoftwareImageType::create (Image::PixelFormat format, int width, int height, bool clearImage) const
131{
132 return *new SoftwarePixelData (format, width, height, clearImage);
133}
134
135int SoftwareImageType::getTypeID() const
136{
137 return 2;
138}
139
140//==============================================================================
141NativeImageType::NativeImageType() {}
142NativeImageType::~NativeImageType() {}
143
144int NativeImageType::getTypeID() const
145{
146 return 1;
147}
148
149#if JUCE_WINDOWS || JUCE_LINUX || JUCE_BSD
150ImagePixelData::Ptr NativeImageType::create (Image::PixelFormat format, int width, int height, bool clearImage) const
151{
152 return new SoftwarePixelData (format, width, height, clearImage);
153}
154#endif
155
156//==============================================================================
158{
159public:
161 : ImagePixelData (source->pixelFormat, r.getWidth(), r.getHeight()),
162 sourceImage (std::move (source)), area (r)
163 {
164 }
165
167 {
168 auto g = sourceImage->createLowLevelContext();
169 g->clipToRectangle (area);
170 g->setOrigin (area.getPosition());
171 return g;
172 }
173
174 void initialiseBitmapData (Image::BitmapData& bitmap, int x, int y, Image::BitmapData::ReadWriteMode mode) override
175 {
176 sourceImage->initialiseBitmapData (bitmap, x + area.getX(), y + area.getY(), mode);
177
178 if (mode != Image::BitmapData::readOnly)
179 sendDataChangeMessage();
180 }
181
183 {
184 jassert (getReferenceCount() > 0); // (This method can't be used on an unowned pointer, as it will end up self-deleting)
185 auto type = createType();
186
187 Image newImage (type->create (pixelFormat, area.getWidth(), area.getHeight(), pixelFormat != Image::RGB));
188
189 {
190 Graphics g (newImage);
191 g.drawImageAt (Image (*this), 0, 0);
192 }
193
194 return *newImage.getPixelData();
195 }
196
197 std::unique_ptr<ImageType> createType() const override { return sourceImage->createType(); }
198
199 /* as we always hold a reference to image, don't double count */
200 int getSharedCount() const noexcept override { return getReferenceCount() + sourceImage->getSharedCount() - 1; }
201
202private:
203 friend class Image;
204 const ImagePixelData::Ptr sourceImage;
205 const Rectangle<int> area;
206
208};
209
210Image Image::getClippedImage (const Rectangle<int>& area) const
211{
212 if (area.contains (getBounds()))
213 return *this;
214
215 auto validArea = area.getIntersection (getBounds());
216
217 if (validArea.isEmpty())
218 return {};
219
220 return Image (*new SubsectionPixelData (image, validArea));
221}
222
223
224//==============================================================================
225Image::Image() noexcept
226{
227}
228
229Image::Image (ReferenceCountedObjectPtr<ImagePixelData> instance) noexcept
230 : image (std::move (instance))
231{
232}
233
234Image::Image (PixelFormat format, int width, int height, bool clearImage)
235 : image (NativeImageType().create (format, width, height, clearImage))
236{
237}
238
239Image::Image (PixelFormat format, int width, int height, bool clearImage, const ImageType& type)
240 : image (type.create (format, width, height, clearImage))
241{
242}
243
244Image::Image (const Image& other) noexcept
245 : image (other.image)
246{
247}
248
250{
251 image = other.image;
252 return *this;
253}
254
256 : image (std::move (other.image))
257{
258}
259
261{
262 image = std::move (other.image);
263 return *this;
264}
265
267{
268}
269
270int Image::getReferenceCount() const noexcept { return image == nullptr ? 0 : image->getSharedCount(); }
271int Image::getWidth() const noexcept { return image == nullptr ? 0 : image->width; }
272int Image::getHeight() const noexcept { return image == nullptr ? 0 : image->height; }
273Rectangle<int> Image::getBounds() const noexcept { return image == nullptr ? Rectangle<int>() : Rectangle<int> (image->width, image->height); }
274Image::PixelFormat Image::getFormat() const noexcept { return image == nullptr ? UnknownFormat : image->pixelFormat; }
275bool Image::isARGB() const noexcept { return getFormat() == ARGB; }
276bool Image::isRGB() const noexcept { return getFormat() == RGB; }
277bool Image::isSingleChannel() const noexcept { return getFormat() == SingleChannel; }
278bool Image::hasAlphaChannel() const noexcept { return getFormat() != RGB; }
279
281{
282 if (image != nullptr)
283 return image->createLowLevelContext();
284
285 return {};
286}
287
289{
290 if (getReferenceCount() > 1)
291 image = image->clone();
292}
293
295{
296 if (image != nullptr)
297 return Image (image->clone());
298
299 return {};
300}
301
303{
304 if (image == nullptr || (image->width == newWidth && image->height == newHeight))
305 return *this;
306
307 auto type = image->createType();
308 Image newImage (type->create (image->pixelFormat, newWidth, newHeight, hasAlphaChannel()));
309
310 Graphics g (newImage);
311 g.setImageResamplingQuality (quality);
312 g.drawImageTransformed (*this, AffineTransform::scale ((float) newWidth / (float) image->width,
313 (float) newHeight / (float) image->height), false);
314 return newImage;
315}
316
318{
319 if (image == nullptr || newFormat == image->pixelFormat)
320 return *this;
321
322 auto w = image->width, h = image->height;
323
324 auto type = image->createType();
325 Image newImage (type->create (newFormat, w, h, false));
326
328 {
329 if (! hasAlphaChannel())
330 {
331 newImage.clear (getBounds(), Colours::black);
332 }
333 else
334 {
335 const BitmapData destData (newImage, 0, 0, w, h, BitmapData::writeOnly);
336 const BitmapData srcData (*this, 0, 0, w, h);
337
338 for (int y = 0; y < h; ++y)
339 {
340 auto src = reinterpret_cast<const PixelARGB*> (srcData.getLinePointer (y));
341 auto dst = destData.getLinePointer (y);
342
343 for (int x = 0; x < w; ++x)
344 dst[x] = src[x].getAlpha();
345 }
346 }
347 }
348 else if (image->pixelFormat == SingleChannel && newFormat == Image::ARGB)
349 {
350 const BitmapData destData (newImage, 0, 0, w, h, BitmapData::writeOnly);
351 const BitmapData srcData (*this, 0, 0, w, h);
352
353 for (int y = 0; y < h; ++y)
354 {
355 auto src = reinterpret_cast<const PixelAlpha*> (srcData.getLinePointer (y));
356 auto dst = reinterpret_cast<PixelARGB*> (destData.getLinePointer (y));
357
358 for (int x = 0; x < w; ++x)
359 dst[x].set (src[x]);
360 }
361 }
362 else
363 {
364 if (hasAlphaChannel())
365 newImage.clear (getBounds());
366
367 Graphics g (newImage);
368 g.drawImageAt (*this, 0, 0);
369 }
370
371 return newImage;
372}
373
375{
376 return image == nullptr ? nullptr : &(image->userData);
377}
378
379//==============================================================================
380Image::BitmapData::BitmapData (Image& im, int x, int y, int w, int h, BitmapData::ReadWriteMode mode)
381 : width (w), height (h)
382{
383 // The BitmapData class must be given a valid image, and a valid rectangle within it!
384 jassert (im.image != nullptr);
385 jassert (x >= 0 && y >= 0 && w > 0 && h > 0 && x + w <= im.getWidth() && y + h <= im.getHeight());
386
387 im.image->initialiseBitmapData (*this, x, y, mode);
388 jassert (data != nullptr && pixelStride > 0 && lineStride != 0);
389}
390
391Image::BitmapData::BitmapData (const Image& im, int x, int y, int w, int h)
392 : width (w), height (h)
393{
394 // The BitmapData class must be given a valid image, and a valid rectangle within it!
395 jassert (im.image != nullptr);
396 jassert (x >= 0 && y >= 0 && w > 0 && h > 0 && x + w <= im.getWidth() && y + h <= im.getHeight());
397
398 im.image->initialiseBitmapData (*this, x, y, readOnly);
399 jassert (data != nullptr && pixelStride > 0 && lineStride != 0);
400}
401
402Image::BitmapData::BitmapData (const Image& im, BitmapData::ReadWriteMode mode)
403 : width (im.getWidth()),
404 height (im.getHeight())
405{
406 // The BitmapData class must be given a valid image!
407 jassert (im.image != nullptr);
408
409 im.image->initialiseBitmapData (*this, 0, 0, mode);
410 jassert (data != nullptr && pixelStride > 0 && lineStride != 0);
411}
412
413Image::BitmapData::~BitmapData()
414{
415}
416
417Colour Image::BitmapData::getPixelColour (int x, int y) const noexcept
418{
419 jassert (isPositiveAndBelow (x, width) && isPositiveAndBelow (y, height));
420
421 auto pixel = getPixelPointer (x, y);
422
423 switch (pixelFormat)
424 {
425 case Image::ARGB: return Colour ( ((const PixelARGB*) pixel)->getUnpremultiplied());
426 case Image::RGB: return Colour (*((const PixelRGB*) pixel));
427 case Image::SingleChannel: return Colour (*((const PixelAlpha*) pixel));
428 case Image::UnknownFormat:
429 default: jassertfalse; break;
430 }
431
432 return {};
433}
434
435void Image::BitmapData::setPixelColour (int x, int y, Colour colour) const noexcept
436{
437 jassert (isPositiveAndBelow (x, width) && isPositiveAndBelow (y, height));
438
439 auto pixel = getPixelPointer (x, y);
440 auto col = colour.getPixelARGB();
441
442 switch (pixelFormat)
443 {
444 case Image::ARGB: ((PixelARGB*) pixel)->set (col); break;
445 case Image::RGB: ((PixelRGB*) pixel)->set (col); break;
446 case Image::SingleChannel: ((PixelAlpha*) pixel)->set (col); break;
447 case Image::UnknownFormat:
448 default: jassertfalse; break;
449 }
450}
451
452//==============================================================================
454{
455 if (image != nullptr)
456 {
457 auto g = image->createLowLevelContext();
458 g->setFill (colourToClearTo);
459 g->fillRect (area, true);
460 }
461}
462
463//==============================================================================
464Colour Image::getPixelAt (int x, int y) const
465{
467 {
468 const BitmapData srcData (*this, x, y, 1, 1);
469 return srcData.getPixelColour (0, 0);
470 }
471
472 return {};
473}
474
475void Image::setPixelAt (int x, int y, Colour colour)
476{
478 {
479 const BitmapData destData (*this, x, y, 1, 1, BitmapData::writeOnly);
480 destData.setPixelColour (0, 0, colour);
481 }
482}
483
484void Image::multiplyAlphaAt (int x, int y, float multiplier)
485{
487 && hasAlphaChannel())
488 {
489 const BitmapData destData (*this, x, y, 1, 1, BitmapData::readWrite);
490
491 if (isARGB())
492 reinterpret_cast<PixelARGB*> (destData.data)->multiplyAlpha (multiplier);
493 else
494 *(destData.data) = (uint8) (*(destData.data) * multiplier);
495 }
496}
497
498template <class PixelType>
500{
501 template <class PixelOperation>
502 static void iterate (const Image::BitmapData& data, const PixelOperation& pixelOp)
503 {
504 for (int y = 0; y < data.height; ++y)
505 {
506 auto p = data.getLinePointer (y);
507
508 for (int x = 0; x < data.width; ++x)
509 {
510 pixelOp (*reinterpret_cast<PixelType*> (p));
511 p += data.pixelStride;
512 }
513 }
514 }
515};
516
517template <class PixelOperation>
518static void performPixelOp (const Image::BitmapData& data, const PixelOperation& pixelOp)
519{
520 switch (data.pixelFormat)
521 {
525 case Image::UnknownFormat:
526 default: jassertfalse; break;
527 }
528}
529
531{
532 float alpha;
533
534 template <class PixelType>
535 void operator() (PixelType& pixel) const
536 {
537 pixel.multiplyAlpha (alpha);
538 }
539};
540
542{
544
545 const BitmapData destData (*this, 0, 0, getWidth(), getHeight(), BitmapData::readWrite);
546 performPixelOp (destData, AlphaMultiplyOp { amountToMultiplyBy });
547}
548
550{
551 template <class PixelType>
552 void operator() (PixelType& pixel) const
553 {
554 pixel.desaturate();
555 }
556};
557
559{
560 if (isARGB() || isRGB())
561 {
562 const BitmapData destData (*this, 0, 0, getWidth(), getHeight(), BitmapData::readWrite);
563 performPixelOp (destData, DesaturateOp());
564 }
565}
566
567void Image::createSolidAreaMask (RectangleList<int>& result, float alphaThreshold) const
568{
569 if (hasAlphaChannel())
570 {
571 auto threshold = (uint8) jlimit (0, 255, roundToInt (alphaThreshold * 255.0f));
573
574 const BitmapData srcData (*this, 0, 0, getWidth(), getHeight());
575
576 for (int y = 0; y < srcData.height; ++y)
577 {
578 pixelsOnRow.clear();
579 auto lineData = srcData.getLinePointer (y);
580
581 if (isARGB())
582 {
583 for (int x = 0; x < srcData.width; ++x)
584 {
585 if (reinterpret_cast<const PixelARGB*> (lineData)->getAlpha() >= threshold)
586 pixelsOnRow.addRange (Range<int> (x, x + 1));
587
588 lineData += srcData.pixelStride;
589 }
590 }
591 else
592 {
593 for (int x = 0; x < srcData.width; ++x)
594 {
595 if (*lineData >= threshold)
596 pixelsOnRow.addRange (Range<int> (x, x + 1));
597
598 lineData += srcData.pixelStride;
599 }
600 }
601
602 for (int i = 0; i < pixelsOnRow.getNumRanges(); ++i)
603 {
604 auto range = pixelsOnRow.getRange (i);
605 result.add (Rectangle<int> (range.getStart(), y, range.getLength(), 1));
606 }
607
608 result.consolidate();
609 }
610 }
611 else
612 {
613 result.add (0, 0, getWidth(), getHeight());
614 }
615}
616
617void Image::moveImageSection (int dx, int dy,
618 int sx, int sy,
619 int w, int h)
620{
621 if (dx < 0)
622 {
623 w += dx;
624 sx -= dx;
625 dx = 0;
626 }
627
628 if (dy < 0)
629 {
630 h += dy;
631 sy -= dy;
632 dy = 0;
633 }
634
635 if (sx < 0)
636 {
637 w += sx;
638 dx -= sx;
639 sx = 0;
640 }
641
642 if (sy < 0)
643 {
644 h += sy;
645 dy -= sy;
646 sy = 0;
647 }
648
649 const int minX = jmin (dx, sx);
650 const int minY = jmin (dy, sy);
651
652 w = jmin (w, getWidth() - jmax (sx, dx));
653 h = jmin (h, getHeight() - jmax (sy, dy));
654
655 if (w > 0 && h > 0)
656 {
657 auto maxX = jmax (dx, sx) + w;
658 auto maxY = jmax (dy, sy) + h;
659
660 const BitmapData destData (*this, minX, minY, maxX - minX, maxY - minY, BitmapData::readWrite);
661
662 auto dst = destData.getPixelPointer (dx - minX, dy - minY);
663 auto src = destData.getPixelPointer (sx - minX, sy - minY);
664
665 auto lineSize = (size_t) destData.pixelStride * (size_t) w;
666
667 if (dy > sy)
668 {
669 while (--h >= 0)
670 {
671 const int offset = h * destData.lineStride;
672 memmove (dst + offset, src + offset, lineSize);
673 }
674 }
675 else if (dst != src)
676 {
677 while (--h >= 0)
678 {
679 memmove (dst, src, lineSize);
680 dst += destData.lineStride;
681 src += destData.lineStride;
682 }
683 }
684 }
685}
686
687//==============================================================================
688#if JUCE_ALLOW_STATIC_NULL_VARIABLES
689
690JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wdeprecated-declarations")
691JUCE_BEGIN_IGNORE_WARNINGS_MSVC (4996)
692
693const Image Image::null;
694
695JUCE_END_IGNORE_WARNINGS_GCC_LIKE
696JUCE_END_IGNORE_WARNINGS_MSVC
697
698#endif
699
700} // namespace juce
static AffineTransform scale(float factorX, float factorY) noexcept
Returns a new transform which is a re-scale about the origin.
Represents a colour, also including a transparency value.
Definition juce_Colour.h:38
A graphics context, used for drawing a component or image.
void setImageResamplingQuality(ResamplingQuality newQuality)
Changes the quality that will be used when resampling images.
ResamplingQuality
Types of rendering quality that can be specified when drawing images.
void drawImageAt(const Image &imageToDraw, int topLeftX, int topLeftY, bool fillAlphaChannelWithCurrentBrush=false) const
Draws an image.
void drawImageTransformed(const Image &imageToDraw, const AffineTransform &transform, bool fillAlphaChannelWithCurrentBrush=false) const
Draws an image, having applied an affine transform to it.
Very simple container class to hold a pointer to some data on the heap.
This is a base class for holding image data in implementation-specific ways.
Definition juce_Image.h:446
virtual std::unique_ptr< ImageType > createType() const =0
Creates an instance of the type of this image.
This base class is for handlers that control a type of image manipulation format, e....
Definition juce_Image.h:504
Retrieves a section of an image as raw pixel data, so it can be read or written to.
Definition juce_Image.h:310
int pixelStride
The number of bytes between each pixel.
Definition juce_Image.h:355
uint8 * getPixelPointer(int x, int y) const noexcept
Returns a pointer to a pixel in the image.
Definition juce_Image.h:334
int lineStride
The number of bytes between each line.
Definition juce_Image.h:354
uint8 * getLinePointer(int y) const noexcept
Returns a pointer to the start of a line in the image.
Definition juce_Image.h:328
void setPixelColour(int x, int y, Colour colour) const noexcept
Sets the colour of a given pixel.
Colour getPixelColour(int x, int y) const noexcept
Returns the colour of a given pixel.
PixelFormat pixelFormat
The format of the data.
Definition juce_Image.h:353
uint8 * data
The raw pixel data, packed according to the image's pixel format.
Definition juce_Image.h:351
size_t size
The number of valid/allocated bytes after data.
Definition juce_Image.h:352
Holds a fixed-size bitmap.
Definition juce_Image.h:58
int getWidth() const noexcept
Returns the image's width (in pixels).
bool isRGB() const noexcept
True if the image's format is RGB.
std::unique_ptr< LowLevelGraphicsContext > createLowLevelContext() const
Creates a context suitable for drawing onto this image.
Image() noexcept
Creates a null image.
Image & operator=(const Image &)
Makes this image refer to the same underlying image as another object.
void clear(const Rectangle< int > &area, Colour colourToClearTo=Colour(0x00000000))
Clears a section of the image with a given colour.
bool isARGB() const noexcept
True if the image's format is ARGB.
void desaturate()
Changes all the colours to be shades of grey, based on their current luminosity.
bool hasAlphaChannel() const noexcept
True if the image contains an alpha-channel.
~Image()
Destructor.
Colour getPixelAt(int x, int y) const
Returns the colour of one of the pixels in the image.
PixelFormat getFormat() const noexcept
Returns the image's pixel format.
void moveImageSection(int destX, int destY, int sourceX, int sourceY, int width, int height)
Copies a section of the image to somewhere else within itself.
void multiplyAllAlphas(float amountToMultiplyBy)
Changes the overall opacity of the image.
int getHeight() const noexcept
Returns the image's height (in pixels).
Rectangle< int > getBounds() const noexcept
Returns a rectangle with the same size as this image.
void multiplyAlphaAt(int x, int y, float multiplier)
Changes the opacity of a pixel.
void setPixelAt(int x, int y, Colour colour)
Sets the colour of one of the image's pixels.
void createSolidAreaMask(RectangleList< int > &result, float alphaThreshold) const
Creates a RectangleList containing rectangles for all non-transparent pixels of the image.
Image convertedToFormat(PixelFormat newFormat) const
Returns a version of this image with a different image format.
bool isSingleChannel() const noexcept
True if the image's format is a single-channel alpha map.
bool isNull() const noexcept
Returns true if this image is not valid.
Definition juce_Image.h:155
Image rescaled(int newWidth, int newHeight, Graphics::ResamplingQuality quality=Graphics::mediumResamplingQuality) const
Returns a rescaled version of this image.
void duplicateIfShared()
Makes sure that no other Image objects share the same underlying data as this one.
Image createCopy() const
Creates a copy of this image.
NamedValueSet * getProperties() const
Returns a NamedValueSet that is attached to the image and which can be used for associating custom va...
@ SingleChannel
< each pixel is a 1-byte alpha channel value.
Definition juce_Image.h:68
@ ARGB
< each pixel is a 4-byte ARGB premultiplied colour value.
Definition juce_Image.h:67
@ RGB
< each pixel is a 3-byte packed RGB colour value.
Definition juce_Image.h:66
int getReferenceCount() const noexcept
Returns the number of Image objects which are currently referring to the same internal shared image d...
Holds a set of named var objects.
An image storage type which holds the pixels using whatever is the default storage format on the curr...
Definition juce_Image.h:548
Represents a 32-bit INTERNAL pixel with premultiplied alpha, and can perform compositing operations w...
Represents an 8-bit single-channel pixel, and can perform compositing operations on it.
Represents a 24-bit RGB pixel, and can perform compositing operations on it.
A general-purpose range object, that simply represents any linear range with a start and end point.
Definition juce_Range.h:40
Maintains a set of rectangles as a complex region.
void add(RectangleType rect)
Merges a new rectangle into the list.
void consolidate()
Optimises the list into a minimum number of constituent rectangles.
Manages a rectangle and allows geometric operations to be performed on it.
bool contains(ValueType xCoord, ValueType yCoord) const noexcept
Returns true if this coordinate is inside the rectangle.
Rectangle getIntersection(Rectangle other) const noexcept
Returns the region that is the overlap between this and another rectangle.
ValueType getWidth() const noexcept
Returns the width of the rectangle.
ValueType getHeight() const noexcept
Returns the height of the rectangle.
A smart-pointer class which points to a reference-counted object.
std::unique_ptr< ImageType > createType() const override
Creates an instance of the type of this image.
std::unique_ptr< LowLevelGraphicsContext > createLowLevelContext() override
Creates a context that will draw into this image.
void initialiseBitmapData(Image::BitmapData &bitmap, int x, int y, Image::BitmapData::ReadWriteMode mode) override
Initialises a BitmapData object.
ImagePixelData::Ptr clone() override
Creates a copy of this image.
Holds a set of primitive values, storing them as a set of ranges.
void initialiseBitmapData(Image::BitmapData &bitmap, int x, int y, Image::BitmapData::ReadWriteMode mode) override
Initialises a BitmapData object.
std::unique_ptr< ImageType > createType() const override
Creates an instance of the type of this image.
int getSharedCount() const noexcept override
Returns the number of Image objects which are currently referring to the same internal shared image d...
std::unique_ptr< LowLevelGraphicsContext > createLowLevelContext() override
Creates a context that will draw into this image.
ImagePixelData::Ptr clone() override
Creates a copy of this image.
T format(T... args)
#define JUCE_LEAK_DETECTOR(OwnerClass)
This macro lets you embed a leak-detecting object inside a class.
#define jassert(expression)
Platform-independent assertion macro.
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
This is a shorthand way of writing both a JUCE_DECLARE_NON_COPYABLE and JUCE_LEAK_DETECTOR macro for ...
#define jassertfalse
This will always cause an assertion failure.
memcpy
memmove
JUCE Namespace.
constexpr Type jmin(Type a, Type b)
Returns the smaller of two values.
constexpr Type jmax(Type a, Type b)
Returns the larger of two values.
Type jlimit(Type lowerLimit, Type upperLimit, Type valueToConstrain) noexcept
Constrains a value to keep it within a given range.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
Definition juce_Memory.h:88
bool isPositiveAndBelow(Type1 valueToTest, Type2 upperLimit) noexcept
Returns true if a value is at least zero, and also below a specified upper limit.
unsigned char uint8
A platform-independent 8-bit unsigned integer type.
int roundToInt(const FloatType value) noexcept
Fast floating-point-to-integer conversion.
typedef size_t