class ImageDrawTest : public TopWindow { public: typedef ImageDrawTest CLASSNAME; Image img; ImageDrawTest() { Sizeable(); GenerateImage(); } void GenerateImage() { Size sz(100, 100); ImageDraw w(sz); // w.Alpha().DrawRect(sz, Black()); w.Alpha().DrawRect(30, 30, 40, 40, White()); w.DrawRect(sz, Red); img = w; } virtual void Paint(Draw &w) { w.DrawRect(GetSize(), SColorFace()); w.DrawImage(0, 0, img); } virtual void LeftUp(Point p, dword keyflags) { GenerateImage(); Refresh(); } };
class ImageDrawTest : public TopWindow { public: typedef ImageDrawTest CLASSNAME; Image img; ImageDrawTest() { Sizeable(); GenerateImage(); } void GenerateImage() { Size sz(100, 100); ImageDraw w(sz); // w.Alpha().DrawRect(sz, Black()); w.Alpha().DrawRect(30, 30, 40, 40, White()); w.DrawRect(sz, Red); img = w; } virtual void Paint(Draw &w) { w.DrawRect(GetSize(), SColorFace()); w.DrawImage(0, 0, img); } virtual void LeftUp(Point p, dword keyflags) { GenerateImage(); Refresh(); } };
Quote: |
ImageDraw::alpha should be initialized to 0. Perhaps this could be done on the first call to Alpha() so there is no additional overhead for none-alpha situations? |
luzr wrote on Wed, 30 April 2008 10:55 |
Should not it be rather 255? |
Draw& ImageDraw::Alpha() { if(!has_alpha) { alpha.DrawRect(size, GrayColor(0)); has_alpha = true; } return alpha; }
luzr wrote on Wed, 30 April 2008 11:55 |
Should I draw random data into alpha? Win32 clears it for me. |
mr_ped wrote on Wed, 30 April 2008 15:00 | ||
In case it is supposed to be uninitialized, and the OS does initialize it for you, I suggest to use random bytes in DEBUG mode trough #ifdef. That will make such errors to appear in debug mode, yet it will not slow down release. |