• Welcome to Jose's Read Only Forum 2023.
 

GDI+: GdipImageRotateFlip

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

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

José Roca



The following example creates an Image object based on a JPEG file. The code calls the GdipImageRotateFlip function to rotate the image clockwise 90 degrees and then flip the image vertically. The code draws the image twice: once before and once after the call to GdipImageRotateFlip.

C++


VOID Example_RotateFlip(HDC hdc)
{
   Graphics graphics(hdc);
   Image image(L"Crayons.jpg");

   graphics.DrawImage(&image, 10, 10, image.GetWidth(), image.GetHeight());
   image.RotateFlip(Rotate90FlipY);
   graphics.DrawImage(&image, 160, 10, image.GetWidth(), image.GetHeight()); 
}


PowerBASIC


SUB GDIP_ImageRotateFlip (BYVAL hdc AS DWORD)

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

   hStatus = GdipCreateFromHDC(hdc, pGraphics)

   ' // Create an image and a thumbnail of the image.
   strFileName = UCODE$("climber.jpg")
   hStatus = GdipLoadImageFromFile(STRPTR(strFileName), pImage)

   hStatus = GdipGetImageWidth(pImage, nWidth)
   hStatus = GdipGetImageHeight(pImage, nHeight)
   hStatus = GdipDrawImageRect(pGraphics, pImage, 10, 10, nWidth, nHeight)

   hStatus = GdipImageRotateFlip(pImage, %Rotate90FlipY)
   hStatus = GdipGetImageWidth(pImage, nWidth)
   hStatus = GdipGetImageHeight(pImage, nHeight)
   hStatus = GdipDrawImageRect(pGraphics, pImage, 200, 10, nWidth, nHeight)

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

END SUB