diff Framework/Viewport/CairoSurface.h @ 560:aaeec7be8fb7

add support for alpha channel in CairoSurface
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 17 Apr 2019 17:57:50 +0200
parents b1e1eccee214
children
line wrap: on
line diff
--- a/Framework/Viewport/CairoSurface.h	Wed Apr 17 16:16:47 2019 +0200
+++ b/Framework/Viewport/CairoSurface.h	Wed Apr 17 17:57:50 2019 +0200
@@ -36,41 +36,45 @@
     unsigned int     height_;
     unsigned int     pitch_;
     void*            buffer_;
+    bool             hasAlpha_;
 
     void Release();
 
     void Allocate(unsigned int width,
-                  unsigned int height);
+                  unsigned int height,
+                  bool hasAlpha);
 
   public:
     CairoSurface() :
       surface_(NULL)
     {
-      Allocate(0, 0);
+      Allocate(0, 0, false);
     }
 
     CairoSurface(unsigned int width,
-                 unsigned int height) :
+                 unsigned int height,
+                 bool hasAlpha) :
       surface_(NULL)
     {
-      Allocate(width, height);
+      Allocate(width, height, hasAlpha);
     }
 
-  private:
-    CairoSurface(Orthanc::ImageAccessor& accessor);
+    CairoSurface(Orthanc::ImageAccessor& accessor,
+                 bool hasAlpha);
 
-  public:
     ~CairoSurface()
     {
       Release();
     }
 
     void SetSize(unsigned int width,
-                 unsigned int height);
+                 unsigned int height,
+                 bool hasAlpha);
 
     void Copy(const CairoSurface& other);
 
-    void Copy(const Orthanc::ImageAccessor& source);
+    void Copy(const Orthanc::ImageAccessor& source,
+              bool hasAlpha);
 
     unsigned int GetWidth() const
     {
@@ -102,6 +106,11 @@
       return surface_;
     }
 
+    bool HasAlpha() const
+    {
+      return hasAlpha_;
+    }
+
     void GetReadOnlyAccessor(Orthanc::ImageAccessor& target) const;
 
     void GetWriteableAccessor(Orthanc::ImageAccessor& target);