The following example creates a rotation matrix and passes the address of that matrix to the
GdipSetWorldTransform function. The code calls the
GdipDrawRectangle function to draw a rotated rectangle.
C++
VOID Example_GetThumbnail(HDC hdc)
{
Graphics graphics(hdc);
// Create an image and a thumbnail of the image.
Image image(L"Crayons.jpg");
Image* pThumbnail = image.GetThumbnailImage(40, 40, NULL, NULL);
// Draw the original and the thumbnail images.
graphics.DrawImage(&image, 10, 10, image.GetWidth(), image.GetHeight());
graphics.DrawImage(
pThumbnail,
150,
10,
pThumbnail->GetWidth(),
pThumbnail->GetHeight());
delete pThumbnail;
}
PowerBASIC
SUB GDIP_GetImageThumbnail (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
LOCAL pThumbnail AS DWORD
LOCAL nThumbnailWidth AS DWORD
LOCAL nThumbnailHeight 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 = GdipGetImageThumbnail(pImage, 40, 40, pThumbnail, %NULL, %NULL)
' // Draw the original and the thumbnail images.
hStatus = GdipGetImageWidth(pImage, nWidth)
hStatus = GdipGetImageHeight(pImage, nHeight)
hStatus = GdipDrawImageRect(pGraphics, pImage, 10, 10, nWidth, nHeight)
hStatus = GdipGetImageWidth(pThumbnail, nThumbnailWidth)
hStatus = GdipGetImageHeight(pThumbnail, nThumbnailHeight)
hStatus = GdipDrawImageRect(pGraphics, pThumbnail, 200, 10, nThumbnailWidth, nThumbnailHeight)
' // Cleanup
IF pThumbnail THEN GdipDisposeImage(pThumbnail)
IF pImage THEN GdipDisposeImage(pImage)
IF pGraphics THEN GdipDeleteGraphics(pGraphics)
END SUB
(http://www.jose.it-berater.org/captures/GdipGetImageThumbnail.png)