Date: 02-16-2022
Return to Index
created by gbSnippets
'Compilable Example: (Jose Includes)
%Unicode = 1
#Include "Win32API.inc"
#Include "gdiplus.inc"
Function PBMain() As Long
AnytoBMP "rooftop.jpg", "rooftop.bmp"
End Function
Sub AnytoBMP(jpgFileName As WStringZ * %Max_Path, bmpFileName As WStringZ * %Max_Path)
Local wImg, hImg As Long, hBMP, hDC As Dword
Local pImage,pGraphics,token As Dword
Local StartupInput As GdiplusStartupInput
'initialize
StartupInput.GdiplusVersion = 1
GdiplusStartup(token, StartupInput, ByVal %NULL)
'load JPG/GIF/PNG image to memory bitmap from file
GdipLoadImageFromFile(jpgFileName, pImage) 'pImage - image object
GdipGetImageWidth(pImage,wImg) 'get width
GdipGetImageHeight(pImage,hImg) 'get height
'create memory bitmap for holding the image
Graphic Bitmap New wImg,hImg To hBMP
Graphic Attach hBMP,0
Graphic Get DC To hDC 'hDC is for memory bitmap
GdipCreateFromHDC(hDC, pGraphics) 'create graphic object
GdipDrawImageRect(pGraphics, pImage, 0,0,wImg,hImg) 'draw image at 0,0
'shutdown GDI
If pImage Then GdipDisposeImage(pImage) 'cleanup
If pGraphics Then GdipDeleteGraphics(pGraphics) 'cleanup
'save the image
Graphic Save bmpFileName
End Sub
http://www.garybeene.com/sw/gbsnippets.htm