comparison 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
comparison
equal deleted inserted replaced
559:9e61b0ac12f1 560:aaeec7be8fb7
34 cairo_surface_t* surface_; 34 cairo_surface_t* surface_;
35 unsigned int width_; 35 unsigned int width_;
36 unsigned int height_; 36 unsigned int height_;
37 unsigned int pitch_; 37 unsigned int pitch_;
38 void* buffer_; 38 void* buffer_;
39 bool hasAlpha_;
39 40
40 void Release(); 41 void Release();
41 42
42 void Allocate(unsigned int width, 43 void Allocate(unsigned int width,
43 unsigned int height); 44 unsigned int height,
45 bool hasAlpha);
44 46
45 public: 47 public:
46 CairoSurface() : 48 CairoSurface() :
47 surface_(NULL) 49 surface_(NULL)
48 { 50 {
49 Allocate(0, 0); 51 Allocate(0, 0, false);
50 } 52 }
51 53
52 CairoSurface(unsigned int width, 54 CairoSurface(unsigned int width,
53 unsigned int height) : 55 unsigned int height,
56 bool hasAlpha) :
54 surface_(NULL) 57 surface_(NULL)
55 { 58 {
56 Allocate(width, height); 59 Allocate(width, height, hasAlpha);
57 } 60 }
58 61
59 private: 62 CairoSurface(Orthanc::ImageAccessor& accessor,
60 CairoSurface(Orthanc::ImageAccessor& accessor); 63 bool hasAlpha);
61 64
62 public:
63 ~CairoSurface() 65 ~CairoSurface()
64 { 66 {
65 Release(); 67 Release();
66 } 68 }
67 69
68 void SetSize(unsigned int width, 70 void SetSize(unsigned int width,
69 unsigned int height); 71 unsigned int height,
72 bool hasAlpha);
70 73
71 void Copy(const CairoSurface& other); 74 void Copy(const CairoSurface& other);
72 75
73 void Copy(const Orthanc::ImageAccessor& source); 76 void Copy(const Orthanc::ImageAccessor& source,
77 bool hasAlpha);
74 78
75 unsigned int GetWidth() const 79 unsigned int GetWidth() const
76 { 80 {
77 return width_; 81 return width_;
78 } 82 }
100 cairo_surface_t* GetObject() 104 cairo_surface_t* GetObject()
101 { 105 {
102 return surface_; 106 return surface_;
103 } 107 }
104 108
109 bool HasAlpha() const
110 {
111 return hasAlpha_;
112 }
113
105 void GetReadOnlyAccessor(Orthanc::ImageAccessor& target) const; 114 void GetReadOnlyAccessor(Orthanc::ImageAccessor& target) const;
106 115
107 void GetWriteableAccessor(Orthanc::ImageAccessor& target); 116 void GetWriteableAccessor(Orthanc::ImageAccessor& target);
108 }; 117 };
109 } 118 }