11 #include "cresourcedescription.h" 12 #include "platform/iplatformbitmap.h" 27 CBitmap (CCoord width, CCoord height);
30 ~
CBitmap () noexcept
override =
default;
42 bool isLoaded ()
const {
return getPlatformBitmap () ? true :
false; }
46 PlatformBitmapPtr getPlatformBitmap ()
const;
47 void setPlatformBitmap (
const PlatformBitmapPtr& bitmap);
49 bool addBitmap (
const PlatformBitmapPtr& platformBitmap);
50 PlatformBitmapPtr getBestPlatformBitmapForScaleFactor (
double scaleFactor)
const;
57 CResourceDescription resourceDesc;
58 using BitmapVector = std::vector<PlatformBitmapPtr>;
86 : left (left), top (top), right (right), bottom (bottom) {}
89 inline void calcRects (
const CRect& inBitmapRect,
CRect outRect[kPartCount])
const 92 CRect myCenter = outRect[kPartCenter] (inBitmapRect.left + left,
93 inBitmapRect.top + top,
94 inBitmapRect.right - right,
95 inBitmapRect.bottom - bottom);
98 outRect[kPartTop] (myCenter.left, inBitmapRect.top, myCenter.right, myCenter.top);
99 outRect[kPartLeft] (inBitmapRect.left, myCenter.top, myCenter.left, myCenter.bottom);
100 outRect[kPartRight] (myCenter.right, myCenter.top, inBitmapRect.right, myCenter.bottom);
101 outRect[kPartBottom] (myCenter.left, myCenter.bottom, myCenter.right, inBitmapRect.bottom);
104 outRect[kPartTopLeft] (inBitmapRect.left, inBitmapRect.top, myCenter.left, myCenter.top);
105 outRect[kPartTopRight] (myCenter.right, inBitmapRect.top, inBitmapRect.right, myCenter.top);
106 outRect[kPartBottomLeft] (inBitmapRect.left, myCenter.bottom, myCenter.left, inBitmapRect.bottom);
107 outRect[kPartBottomRight] (myCenter.right, myCenter.bottom, inBitmapRect.right, inBitmapRect.bottom);
149 inline uint32_t
getX ()
const {
return x; }
150 inline uint32_t
getY ()
const {
return y; }
154 inline void getValue (uint32_t& value);
155 inline void setValue (uint32_t value);
157 inline uint32_t getBitmapWidth ()
const {
return maxX+1; }
158 inline uint32_t getBitmapHeight ()
const {
return maxY+1; }
160 inline IPlatformBitmapPixelAccess* getPlatformBitmapPixelAccess ()
const {
return pixelAccess; }
164 static CBitmapPixelAccess*
create (CBitmap* bitmap,
bool alphaPremultiplied =
true);
167 CBitmapPixelAccess ();
168 ~CBitmapPixelAccess () noexcept override = default;
169 void init (CBitmap* bitmap, IPlatformBitmapPixelAccess* pixelAccess);
172 SharedPointer<IPlatformBitmapPixelAccess> pixelAccess;
175 uint32_t bytesPerRow;
195 currentPos = address + y * bytesPerRow;
204 if (_x > maxX || _y > maxY)
208 currentPos = address + y * bytesPerRow + x * 4;
215 value = *(uint32_t*) (currentPos);
221 *(uint32_t*) (currentPos) = value;
Describes a resource by name or by ID.
Definition: cresourcedescription.h:16
CPoint getSize() const
get size of image
Definition: cbitmap.cpp:107
Rect structure.
Definition: crect.h:17
a nine-part tiled bitmap
Definition: cbitmap.h:117
uint32_t getY() const
return current y position
Definition: cbitmap.h:150
Definition: vstguibase.h:299
virtual void setColor(const CColor &c)=0
set color of current pixel
void setValue(uint32_t value)
set native color value
Definition: cbitmap.h:219
A drawing context encapsulates the drawing context of the underlying OS.
Definition: cdrawcontext.h:29
RGBA Color structure.
Definition: ccolor.h:15
bool isLoaded() const
check if image is loaded
Definition: cbitmap.h:42
void getValue(uint32_t &value)
get native color value
Definition: cbitmap.h:213
bool operator++()
advance position
Definition: cbitmap.h:183
static CBitmapPixelAccess * create(CBitmap *bitmap, bool alphaPremultiplied=true)
Definition: cbitmap.cpp:285
direct pixel access to a CBitmap
Definition: cbitmap.h:144
Encapsulates various platform depended kinds of bitmaps.
Definition: cbitmap.h:21
Definition: customcontrols.cpp:8
bool setPosition(uint32_t x, uint32_t y)
set current position
Definition: cbitmap.h:202
CCoord getHeight() const
get the height of the image
Definition: cbitmap.cpp:99
uint32_t getX() const
return current x position
Definition: cbitmap.h:149
Definition: vstguibase.h:247
virtual void getColor(CColor &c) const =0
get color of current pixel
Point structure.
Definition: cpoint.h:17
CCoord getWidth() const
get the width of the image
Definition: cbitmap.cpp:91