ASPiK SDK
gdiplusbitmap.h
1 // This file is part of VSTGUI. It is subject to the license terms
2 // in the LICENSE file found in the top-level directory of this
3 // distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
4 
5 #ifndef __gdiplusbitmap__
6 #define __gdiplusbitmap__
7 
8 #include "win32bitmapbase.h"
9 
10 #if WINDOWS
11 
12 #include "../../cpoint.h"
13 #include "win32support.h"
14 
15 namespace VSTGUI {
16 
17 //-----------------------------------------------------------------------------
18 class GdiplusBitmap : public Win32BitmapBase
19 {
20 public:
21  GdiplusBitmap ();
22  GdiplusBitmap (const CPoint& size);
23  ~GdiplusBitmap () noexcept;
24 
25  bool load (const CResourceDescription& desc) override;
26  const CPoint& getSize () const override { return size; }
27  SharedPointer<IPlatformBitmapPixelAccess> lockPixels (bool alphaPremultiplied) override;
28  void setScaleFactor (double factor) override {}
29  double getScaleFactor () const override { return 1.; }
30 
31  Gdiplus::Bitmap* getBitmap () const { return bitmap; }
32  HBITMAP createHBitmap () override;
33  bool loadFromStream (IStream* stream) override;
34  PNGBitmapBuffer createMemoryPNGRepresentation () override;
35 
36 //-----------------------------------------------------------------------------
37 protected:
38  class PixelAccess : public IPlatformBitmapPixelAccess
39  {
40  public:
41  PixelAccess ();
42  ~PixelAccess () noexcept;
43 
44  bool init (GdiplusBitmap* bitmap, bool alphaPremulitplied);
45 
46  uint8_t* getAddress () const { return (uint8_t*)data.Scan0; }
47  uint32_t getBytesPerRow () const { return static_cast<uint32_t> (data.Stride); }
48  PixelFormat getPixelFormat () const { return kBGRA; }
49  protected:
50  GdiplusBitmap* bitmap;
51  Gdiplus::BitmapData data;
52  };
53  Gdiplus::Bitmap* bitmap;
54  CPoint size;
55  bool allocatedByGdi;
56 };
57 
58 } // namespace
59 
60 #endif // WINDOWS
61 
62 #endif // __gdiplusbitmap__
63 
Definition: customcontrols.cpp:8