Posted: Wed Aug 06, 2008 6:15 pm
Can always use gdi+ (windows XP, 2003 , Vista).
The following uses some of Netmaestro's code taken from http://www.purebasic.fr/english/viewtop ... lusstartup
The following uses some of Netmaestro's code taken from http://www.purebasic.fr/english/viewtop ... lusstartup
Code: Select all
#GDIPLUS_OK = 0
;-Structures.
Structure GdiplusStartupInput ;{
GdiPlusVersion.l
*DebugEventCallback.DebugEventProc
SuppressBackgroundThread.l
SuppressExternalCodecs.l
EndStructure
;-Imports.
Import "gdiplus.lib"
GdiplusStartup(token, *input.GdiplusStartupInput, output)
GdipCreateBitmapFromFile(filename.p-unicode, *bitmap)
GdipGetImageWidth(*image, *width)
GdipGetImageHeight(*image, *height)
GdipCreateFromHDC(hdc.l, *graphics)
GdipDrawImageRectI(*graphics, *image, x.l, y.l, width.l, height.l)
GdipDeleteGraphics(*graphics)
GdipDisposeImage(image)
GdiplusShutdown(token)
EndImport
;Returns zero if an error or the PB image#.
Procedure.l LoadGif(filename$)
Protected result, width, height
Protected input.GdiplusStartupInput, token, image, imageID, hdc, graphics
;First initialise gdi+.
input\GdiPlusVersion = 1
GdiplusStartup(@token, @input, #Null)
;Was the initialisation successful?
If token
If GdipCreateBitmapFromFile(filename$, @image) = #GDIPLUS_OK
GdipGetImageWidth(image, @width)
GdipGetImageHeight(image, @height)
imageID = CreateImage(#PB_Any, Width, Height, 32)
If imageID
hdc = StartDrawing(ImageOutput(imageID))
If hdc
GdipCreateFromHDC(hdc, @graphics)
If graphics
GdipDrawImageRectI(graphics, image, 0, 0, width, height)
GdipDeleteGraphics(graphics)
result = imageID
EndIf
StopDrawing()
EndIf
EndIf
GdipDisposeImage(image)
EndIf
;Tidy up.
GdiplusShutdown(token)
EndIf
ProcedureReturn result
EndProcedure
;Test.
imageNum = LoadGif("test.gif")