|
From: andrew7 <bd...@us...> - 2007-02-18 01:00:15
|
Update of /cvsroot/smartwin/SmartWin/tests/Canvas In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv968/tests/Canvas Modified Files: canvas_all.cpp Log Message: Demonstrate how to use Gdiplus::Bitmap Index: canvas_all.cpp =================================================================== RCS file: /cvsroot/smartwin/SmartWin/tests/Canvas/canvas_all.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- canvas_all.cpp 30 Nov 2006 00:57:12 -0000 1.11 +++ canvas_all.cpp 18 Feb 2007 01:00:10 -0000 1.12 @@ -23,7 +23,7 @@ #include "encircle.h" // Remove the comment part below to use GdiPlus and view an Image in addition to the other cool stuff you see... ;) -// #define UseGdiPlus 1 +#define UseGdiPlus 1 #ifdef UseGdiPlus #include <gdiplus.h> using namespace Gdiplus; @@ -113,6 +113,10 @@ void painting( SmartWin::Canvas & c ) { + // BufferedCanvas< Canvas > c( this->handle() ); + + + // rc.pos is the upper left point, rc.size is the lower right point. SmartWin::Rectangle rc( getClientAreaSize() ); RECT kokko = rc; @@ -222,6 +226,7 @@ // Draw a JPG file using Window's GDI classes. GdiPlus( c.getDc(), 0, y, x2, y + yinc ); // GDI+ Logic #endif + // c.blast( rc ); } #ifdef UseGdiPlus @@ -235,8 +240,18 @@ Image image( L"sample.jpg" ); graphics.DrawImage( & image, x, y ); + + int width= 20, height= 30; + Gdiplus::Bitmap checker( width, height, &graphics ); + for ( int w=0; w < width; w += 2 ) { + for ( int h=0; h < height; h += 4 ) { + checker.SetPixel( w, h, Color( 255, 0, 0, 255 ) ); + } + } + graphics.DrawImage( & checker, x+image.GetWidth(), y ); } #endif + // There are new dimensions to the window because the user resized the window. void isResized( const SmartWin::WidgetSizedEventResult & sz ) { @@ -363,6 +378,7 @@ // Application entry point just like all other SmartWin applications... int SmartWinMain( Application & app ) { - CanvasWidget * cw = new CanvasWidget(); cw->init(); + CanvasWidget * cw = new CanvasWidget(); + cw->init(); return ( app.run() ); } |