8 #include "../win32bitmapbase.h" 10 #if WINDOWS && VSTGUI_DIRECT2D_SUPPORT 12 #include "../../../cpoint.h" 14 struct IWICBitmapSource;
16 struct ID2D1RenderTarget;
18 struct IWICBitmapLock;
25 class D2DBitmap :
public Win32BitmapBase
29 D2DBitmap (
const CPoint& size);
32 bool load (
const CResourceDescription& desc)
override;
33 const CPoint& getSize ()
const override {
return size; }
34 SharedPointer<IPlatformBitmapPixelAccess> lockPixels (
bool alphaPremultiplied)
override;
35 void setScaleFactor (
double factor)
override { scaleFactor = factor; }
36 double getScaleFactor ()
const override {
return scaleFactor; }
38 HBITMAP createHBitmap ()
override;
39 bool loadFromStream (IStream* stream)
override;
41 IWICBitmapSource* getSource ()
const {
return source; }
42 IWICBitmap* getBitmap ();
43 PNGBitmapBuffer createMemoryPNGRepresentation ()
override;
46 void replaceBitmapSource (IWICBitmapSource* newSourceBitmap);
48 class PixelAccess :
public IPlatformBitmapPixelAccess
54 bool init (D2DBitmap* bitmap,
bool alphaPremultiplied);
56 uint8_t* getAddress ()
const {
return (uint8_t*)ptr; }
57 uint32_t getBytesPerRow ()
const {
return bytesPerRow; }
58 PixelFormat getPixelFormat ()
const {
return kBGRA; }
61 static void premultiplyAlpha (BYTE* ptr, UINT bytesPerRow,
const CPoint& size);
62 static void unpremultiplyAlpha (BYTE* ptr, UINT bytesPerRow,
const CPoint& size);
65 IWICBitmapLock* bLock;
68 bool alphaPremultiplied;
73 IWICBitmapSource* source;
80 ID2D1Bitmap* getBitmap (D2DBitmap* bitmap, ID2D1RenderTarget* renderTarget);
82 void removeBitmap (D2DBitmap* bitmap);
83 void removeRenderTarget (ID2D1RenderTarget* renderTarget);
85 static D2DBitmapCache* instance ();
90 ID2D1Bitmap* createBitmap (D2DBitmap* bitmap, ID2D1RenderTarget* renderTarget);
91 using RenderTargetBitmapMap = std::map<ID2D1RenderTarget*, ID2D1Bitmap*>;
92 using BitmapCache = std::map<D2DBitmap*, RenderTargetBitmapMap>;
100 #endif // __d2dbitmap__ Definition: customcontrols.cpp:8