- Added and Modified by RASHAD
- It can use GDI+ directly to load the image but not TGA
- I hate to see some questions not answered
Have fun
Code: Select all
UsePNGImageDecoder()
UseJPEGImageDecoder()
UseJPEG2000ImageDecoder()
UseTIFFImageDecoder()
UseTGAImageDecoder()
#GDIPLUS_OK = 0
Structure GdiplusStartupInput
GdiPlusVersion.l
*DebugEventCallback.DebugEventProc
SuppressBackgroundThread.l
SuppressExternalCodecs.l
EndStructure
Import "gdiplus.lib"
GdiplusStartup(token, *input.GdiplusStartupInput, output)
GdiplusShutdown(token)
GdipCreateBitmapFromFile(filename.p-unicode, *bitmap)
GdipCreateBitmapFromHBITMAP(hbm, hpal, *bitmap)
GdipSaveImageToFile(image, filename.p-unicode, *clsidEncoder.CLSID, *encoderParams)
GdipDisposeImage(image)
EndImport
pattern$ = "PNG, BMP, JPEG, TIFF|*.png;*.bmp;*.jpg;*.jpeg;*.tiff|PNG (*.png)|*.png|BMP (*.bmp)|*.bmp|JPEG (*.jpg)|*.jpg|TIFF (*.tif)|*.tif"
Filename$ = OpenFileRequester("Choose an image to convert to GIF:","",pattern$, 0)
If Filename$
If LoadImage(0,Filename$) = 0
MessageRequester("Error","Image not loaded",#MB_OK)
End
EndIf
EndIf
input.GdiplusStartupInput
input\GdiPlusVersion = 1
GdiplusStartup(@token, @input, #Null)
If token
If GdipCreateBitmapFromHBITMAP(ImageID(0),0, @image) = #GDIPLUS_OK
GdipSaveImageToFile(image, GetTemporaryDirectory()+"test.gif", ?clsid_giff, 0)
GdipDisposeImage(image)
EndIf
If IsImage(0)
FreeImage(0)
EndIf
GdiplusShutdown(token)
EndIf
End
DataSection
clsid_giff:
Data.l $557CF402
Data.w $1A04, $11D3
Data.b $9A, $73, $00, $00, $F8, $1E, $F3, $2E
EndDataSection