Theo's Forum

Legacy Software (PBWIN 9.0+/PBCC 5.0+) => Source Code => Graphics and Multimedia => GDI+ (GDI Plus) => Topic started by: José Roca on June 23, 2008, 02:04:18 AM

Title: GDI+: GdipDrawImage
Post by: José Roca on June 23, 2008, 02:04:18 AM

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

C++

Code: [Select]
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

Code: [Select]
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

(http://www.jose.it-berater.org/captures/GdipDrawImage.png)