25 #ifndef JUCE_PIXELFORMATS_H_INCLUDED
26 #define JUCE_PIXELFORMATS_H_INCLUDED
31 #pragma pack (push, 1)
39 return (x >> 8) & 0x00ff00ff;
80 return (
uint32) ((components.a << 24) | (components.r << 16) | (components.g << 8) | (components.b << 0));
82 return getNativeARGB();
91 return getInARGBMaskOrder();
93 return (
uint32) ((components.b << 24) | (components.g << 16) | (components.r << 8) | components.a);
111 #if JUCE_GCC && ! JUCE_CLANG
129 template <
class Pixel>
132 internal = src.getNativeARGB();
151 template <
class Pixel>
154 uint32 rb = src.getEvenBytes();
155 uint32 ag = src.getOddBytes();
157 const uint32 alpha = 0x100 - (ag >> 16);
178 template <
class Pixel>
184 const uint32 alpha = 0x100 - (ag >> 16);
195 template <
class Pixel>
198 uint32 dEvenBytes = getEvenBytes();
199 dEvenBytes += (((src.getEvenBytes() - dEvenBytes) * amount) >> 8);
200 dEvenBytes &= 0x00ff00ff;
202 uint32 dOddBytes = getOddBytes();
203 dOddBytes += (((src.getOddBytes() - dOddBytes) * amount) >> 8);
204 dOddBytes &= 0x00ff00ff;
207 dOddBytes |= dEvenBytes;
208 internal = dOddBytes;
215 components.a = newAlpha;
225 internal = ((((
uint32) multiplier) * getOddBytes()) & 0xff00ff00)
226 | (((((
uint32) multiplier) * getEvenBytes()) >> 8) & 0x00ff00ff);
231 multiplyAlpha ((
int) (multiplier * 255.0f));
240 const uint32 alpha = components.a;
252 components.b = (
uint8) ((components.b * alpha + 0x7f) >> 8);
253 components.g = (
uint8) ((components.g * alpha + 0x7f) >> 8);
254 components.r = (
uint8) ((components.r * alpha + 0x7f) >> 8);
262 const uint32 alpha = components.a;
274 components.b = (
uint8)
jmin ((
uint32) 0xffu, (components.b * 0xffu) / alpha);
275 components.g = (
uint8)
jmin ((
uint32) 0xffu, (components.g * 0xffu) / alpha);
276 components.r = (
uint8)
jmin ((
uint32) 0xffu, (components.r * 0xffu) / alpha);
283 if (components.a < 0xff && components.a > 0)
285 const int newUnpremultipliedLevel = (0xff * ((
int) components.r + (
int) components.g + (
int) components.b) / (3 * components.a));
287 components.r = components.g = components.b
288 = (
uint8) ((newUnpremultipliedLevel * components.a + 0x7f) >> 8);
292 components.r = components.g = components.b
293 = (
uint8) (((
int) components.r + (
int) components.g + (
int) components.b) / 3);
301 enum { indexA = 0, indexR = 3, indexG = 2, indexB = 1 };
303 enum { indexA = 3, indexR = 0, indexG = 1, indexB = 2 };
307 enum { indexA = 0, indexR = 1, indexG = 2, indexB = 3 };
309 enum { indexA = 3, indexR = 2, indexG = 1, indexB = 0 };
316 :
internal (internalValue)
376 return (
uint32) ((0xff << 24) | r | (g << 8) | (
b << 16));
378 return (
uint32) ((0xff << 24) |
b | (g << 8) | (r << 16));
387 return (
uint32) ((0xff << 24) | (r << 16) | (g << 8) | (
b << 0));
389 return getNativeARGB();
398 return getInARGBMaskOrder();
400 return (
uint32) ((
b << 24) | (g << 16) | (r << 8) | 0xff);
412 return (
uint32) (r | (
b << 16));
414 return (
uint32) (
b | (r << 16));
442 template <
class Pixel>
464 template <
class Pixel>
474 g = (
uint8) (ag & 0xff);
478 r = (
uint8) (rb & 0xff);
480 r = (
uint8) (rb >> 16);
495 template <
class Pixel>
501 const uint32 alpha = 0x100 - (ag >> 16);
506 g = (
uint8) (ag & 0xff);
510 r = (
uint8) (rb & 0xff);
512 r = (
uint8) (rb >> 16);
520 template <
class Pixel>
523 uint32 dEvenBytes = getEvenBytes();
524 dEvenBytes += (((src.getEvenBytes() - dEvenBytes) * amount) >> 8);
526 uint32 dOddBytes = getOddBytes();
527 dOddBytes += (((src.getOddBytes() - dOddBytes) * amount) >> 8);
529 g = (
uint8) (dOddBytes & 0xff);
532 r = (
uint8) (dEvenBytes & 0xff);
533 b = (
uint8) (dEvenBytes >> 16);
535 b = (
uint8) (dEvenBytes & 0xff);
536 r = (
uint8) (dEvenBytes >> 16);
558 r = g =
b = (
uint8) (((
int) r + (
int) g + (
int)
b) / 3);
564 enum { indexR = 0, indexG = 1, indexB = 2 };
566 enum { indexR = 2, indexG = 1, indexB = 0 };
574 b = (
uint8) (
internal >> 16);
575 g = (
uint8) (
internal >> 8);
576 r = (
uint8) (
internal);
578 r = (
uint8) (
internal >> 16);
579 g = (
uint8) (
internal >> 8);
659 template <
class Pixel>
677 template <
class Pixel>
680 const int srcA = src.getAlpha();
681 a = (
uint8) ((a * (0x100 - srcA) >> 8) + srcA);
689 template <
class Pixel>
693 const int srcAlpha = (
int) ((extraAlpha * src.getAlpha()) >> 8);
694 a = (
uint8) ((a * (0x100 - srcAlpha) >> 8) + srcAlpha);
700 template <
class Pixel>
703 a += ((src.getAlpha() - a) * amount) >> 8;
717 a = (
uint8) ((a * multiplier) >> 8);
722 a = (
uint8) (a * multiplier);
741 a = (
uint8) (
internal >> 24);
756 #endif // JUCE_PIXELFORMATS_H_INCLUDED
forcedinline uint32 getNativeARGB() const noexcept
Definition: juce_PixelFormats.h:622
forcedinline uint32 getEvenBytes() const noexcept
Definition: juce_PixelFormats.h:99
forcedinline uint8 & getAlpha() noexcept
Definition: juce_PixelFormats.h:648
forcedinline uint8 & getGreen() noexcept
Definition: juce_PixelFormats.h:120
forcedinline uint8 & getBlue() noexcept
Definition: juce_PixelFormats.h:433
~PixelARGB() noexcept
Definition: juce_PixelFormats.h:61
forcedinline uint8 & getBlue() noexcept
Definition: juce_PixelFormats.h:121
png_structrp int png_fixed_point red
Definition: juce_PNGLoader.cpp:1173
forcedinline uint8 getRed() const noexcept
Definition: juce_PixelFormats.h:650
#define noexcept
Definition: juce_CompilerSupport.h:141
forcedinline void blend(const Pixel &src) noexcept
Definition: juce_PixelFormats.h:152
forcedinline uint8 getBlue() const noexcept
Definition: juce_PixelFormats.h:652
Type jmin(const Type a, const Type b)
Definition: juce_core.h:113
forcedinline void multiplyAlpha(int multiplier) noexcept
Definition: juce_PixelFormats.h:219
forcedinline void blend(const Pixel &src, uint32 extraAlpha) noexcept
Definition: juce_PixelFormats.h:496
forcedinline uint8 getGreen() const noexcept
Definition: juce_PixelFormats.h:651
TOUCHINPUT int
Definition: juce_win32_Windowing.cpp:123
forcedinline void multiplyAlpha(int) noexcept
Definition: juce_PixelFormats.h:545
forcedinline void blend(const Pixel &src, uint32 extraAlpha) noexcept
Definition: juce_PixelFormats.h:179
forcedinline void blend(const Pixel &src, uint32 extraAlpha) noexcept
Definition: juce_PixelFormats.h:690
forcedinline uint8 getBlue() const noexcept
Definition: juce_PixelFormats.h:429
forcedinline uint8 getAlpha() const noexcept
Definition: juce_PixelFormats.h:647
forcedinline void premultiply() noexcept
Definition: juce_PixelFormats.h:551
forcedinline uint32 getInARGBMaskOrder() const noexcept
Definition: juce_PixelFormats.h:626
forcedinline void tween(const Pixel &src, const uint32 amount) noexcept
Definition: juce_PixelFormats.h:196
long b
Definition: jpegint.h:371
forcedinline void unpremultiply() noexcept
Definition: juce_PixelFormats.h:729
forcedinline uint8 & getRed() noexcept
Definition: juce_PixelFormats.h:119
uint32 getInARGBMemoryOrder() const noexcept
Definition: juce_PixelFormats.h:630
#define JUCE_API
Definition: juce_StandardHeader.h:139
PixelARGB(const uint8 a, const uint8 r, const uint8 g, const uint8 b) noexcept
Definition: juce_PixelFormats.h:63
forcedinline void tween(const Pixel &src, const uint32 amount) noexcept
Definition: juce_PixelFormats.h:521
forcedinline void multiplyAlpha(int multiplier) noexcept
Definition: juce_PixelFormats.h:714
forcedinline void blend(const PixelRGB src) noexcept
Definition: juce_PixelFormats.h:485
forcedinline void set(const Pixel &src) noexcept
Definition: juce_PixelFormats.h:443
forcedinline uint8 & getRed() noexcept
Definition: juce_PixelFormats.h:431
forcedinline uint8 & getGreen() noexcept
Definition: juce_PixelFormats.h:432
forcedinline uint32 getNativeARGB() const noexcept
Definition: juce_PixelFormats.h:73
void setARGB(const uint8 a, const uint8 r, const uint8 g, const uint8 b) noexcept
Definition: juce_PixelFormats.h:137
PixelRGB() noexcept
Definition: juce_PixelFormats.h:365
forcedinline uint32 getOddBytes() const noexcept
Definition: juce_PixelFormats.h:644
forcedinline uint32 getOddBytes() const noexcept
Definition: juce_PixelFormats.h:103
unsigned int uint32
Definition: juce_MathsFunctions.h:51
forcedinline void setAlpha(const uint8 newAlpha) noexcept
Definition: juce_PixelFormats.h:708
forcedinline void multiplyAlpha(float) noexcept
Definition: juce_PixelFormats.h:548
forcedinline uint8 & getAlpha() noexcept
Definition: juce_PixelFormats.h:118
Components components
Definition: juce_PixelFormats.h:341
Definition: juce_PixelFormats.h:610
forcedinline uint32 getInARGBMaskOrder() const noexcept
Definition: juce_PixelFormats.h:77
forcedinline uint32 getOddBytes() const noexcept
Definition: juce_PixelFormats.h:423
forcedinline uint32 getEvenBytes() const noexcept
Definition: juce_PixelFormats.h:409
forcedinline uint8 getBlue() const noexcept
Definition: juce_PixelFormats.h:109
forcedinline uint32 getEvenBytes() const noexcept
Definition: juce_PixelFormats.h:637
forcedinline void setAlpha(const uint8) noexcept
Definition: juce_PixelFormats.h:542
PixelAlpha() noexcept
Definition: juce_PixelFormats.h:614
forcedinline uint8 getRed() const noexcept
Definition: juce_PixelFormats.h:107
~PixelAlpha() noexcept
Definition: juce_PixelFormats.h:615
forcedinline void setARGB(const uint8 a_, const uint8, const uint8, const uint8) noexcept
Definition: juce_PixelFormats.h:666
forcedinline uint32 getInARGBMaskOrder() const noexcept
Definition: juce_PixelFormats.h:384
forcedinline uint8 getRed() const noexcept
Definition: juce_PixelFormats.h:427
forcedinline void premultiply() noexcept
Definition: juce_PixelFormats.h:726
forcedinline void setAlpha(const uint8 newAlpha) noexcept
Definition: juce_PixelFormats.h:213
forcedinline uint8 getGreen() const noexcept
Definition: juce_PixelFormats.h:108
~PixelRGB() noexcept
Definition: juce_PixelFormats.h:366
Definition: juce_PixelFormats.h:56
forcedinline uint8 getGreen() const noexcept
Definition: juce_PixelFormats.h:428
forcedinline void desaturate() noexcept
Definition: juce_PixelFormats.h:731
forcedinline void blend(const Pixel &src) noexcept
Definition: juce_PixelFormats.h:678
forcedinline void multiplyAlpha(const float multiplier) noexcept
Definition: juce_PixelFormats.h:229
void setARGB(const uint8, const uint8 red, const uint8 green, const uint8 blue) noexcept
Definition: juce_PixelFormats.h:451
PixelARGB() noexcept
Definition: juce_PixelFormats.h:60
uint32 getInARGBMemoryOrder() const noexcept
Definition: juce_PixelFormats.h:395
forcedinline void multiplyAlpha(const float multiplier) noexcept
Definition: juce_PixelFormats.h:720
uint32 getInARGBMemoryOrder() const noexcept
Definition: juce_PixelFormats.h:88
forcedinline void desaturate() noexcept
Definition: juce_PixelFormats.h:281
forcedinline void blend(const Pixel &src) noexcept
Definition: juce_PixelFormats.h:465
forcedinline uint32 getNativeARGB() const noexcept
Definition: juce_PixelFormats.h:373
PixelARGB getUnpremultiplied() const noexcept
Definition: juce_PixelFormats.h:235
unsigned char uint8
Definition: juce_MathsFunctions.h:43
forcedinline void unpremultiply() noexcept
Definition: juce_PixelFormats.h:260
forcedinline void unpremultiply() noexcept
Definition: juce_PixelFormats.h:554
forcedinline void tween(const Pixel &src, const uint32 amount) noexcept
Definition: juce_PixelFormats.h:701
forcedinline void set(const Pixel &src) noexcept
Definition: juce_PixelFormats.h:130
forcedinline void desaturate() noexcept
Definition: juce_PixelFormats.h:556
forcedinline uint8 getAlpha() const noexcept
Definition: juce_PixelFormats.h:106
forcedinline void set(const Pixel &src) noexcept
Definition: juce_PixelFormats.h:660
Definition: juce_PixelFormats.h:361
forcedinline void premultiply() noexcept
Definition: juce_PixelFormats.h:238
forcedinline uint8 getAlpha() const noexcept
Definition: juce_PixelFormats.h:426