• Welcome to Powerbasic Museum 2020-B.
 

News:

Forum in repository mode. No new members allowed.

Main Menu

GDI+: GdipDrawImage

Started by José Roca, June 23, 2008, 02:04:18 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

José Roca



The following example draws an image with its upper-left corner at (10, 10).

C++


VOID Example_DrawImage14(HDC hdc)

{
   Graphics graphics(hdc);

   // Create an Image object.
   Image image(L"snow.jpg");

   // Draw the image.
   graphics.DrawImage(&image, 10.0f, 10.0f);
}


PowerBASIC


SUB GDIP_DrawImage (BYVAL hdc AS DWORD)

   LOCAL hStatus AS LONG
   LOCAL pGraphics AS DWORD
   LOCAL pImage AS DWORD
   LOCAL strFileName AS STRING

   hStatus = GdipCreateFromHDC(hdc, pGraphics)

   ' // Create the Image object
   strFileName = UCODE$("climber.jpg")
   hStatus = GdipLoadImageFromFile(STRPTR(strFileName), pImage)

   ' // Draw the image
   hStatus = GdipDrawImage(pGraphics, pImage, 10, 10)

   ' // Cleanup
   IF pImage THEN GdipDisposeImage(pImage)
   IF pGraphics THEN GdipDeleteGraphics(pGraphics)

END SUB