]> git.saurik.com Git - wxWidgets.git/commitdiff
use premultiplied RGB in raw image demo
authorVadim Zeitlin <vadim@wxwidgets.org>
Fri, 15 Apr 2005 00:14:32 +0000 (00:14 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Fri, 15 Apr 2005 00:14:32 +0000 (00:14 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@33616 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

samples/image/image.cpp

index 597314a38233e82c18d58cd5bba465201e3b7a8d..c1e36cc753a2d6175851971a5eb9aecde1c56394 100644 (file)
@@ -319,10 +319,12 @@ public:
 
             for ( int x = 0; x < REAL_SIZE; ++x )
             {
 
             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 * alpha / 256;
+                p.Green() = g * alpha / 256;
+                p.Blue() = b * alpha / 256;
+                p.Alpha() = a;
 
                 ++p; // same as p.OffsetX(1)
             }
 
                 ++p; // same as p.OffsetX(1)
             }