X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5a566d89be51576b079dc1b7940304390d11b950..61c213fe224da24ce33c9187263e75a17ca83a04:/samples/image/image.cpp diff --git a/samples/image/image.cpp b/samples/image/image.cpp index 8dca999ea3..7bfe2db778 100644 --- a/samples/image/image.cpp +++ b/samples/image/image.cpp @@ -184,7 +184,7 @@ public: wxBMP_24BPP }; - static const wxString bppchoices[] = + const wxString bppchoices[] = { _T("1 bpp color"), _T("1 bpp B&W"), @@ -229,7 +229,7 @@ public: wxPNG_TYPE_GREY_RED, }; - static const wxString pngchoices[] = + const wxString pngchoices[] = { _T("Colour 8bpp"), _T("Colour 16bpp"), @@ -305,7 +305,7 @@ public: return; } -// data.UseAlpha(); + data.UseAlpha(); Data::Iterator p(data); @@ -319,10 +319,12 @@ public: for ( int x = 0; x < REAL_SIZE; ++x ) { - p.Red() = r; - p.Green() = g; - p.Blue() = b; - p.Alpha() = (Data::Iterator::ChannelType)((x*255.)/REAL_SIZE); + // note that RGB must be premultiplied by alpha + unsigned a = (Data::Iterator::ChannelType)((x*255.)/REAL_SIZE); + p.Red() = r * a / 256; + p.Green() = g * a / 256; + p.Blue() = b * a / 256; + p.Alpha() = a; ++p; // same as p.OffsetX(1) }