Neither Ward's WxCmmImageDecoder nor El_Choni's EC_ImagePluginOLE seem to be able to decode .GIF files under PB 4.20.
See: www.purebasic.fr/english/viewtopic.php?t=20618
EC_ImagePluginOLE used to be able to decode them under PB 3.90.
Does anyone know of a GIF decoder routine/source/librar/etc that will handle [non-animated] .GIFs correctly in the current version of Pure Basic?
Does Anyone have a GIF Decoder?
Does Anyone have a GIF Decoder?
Last edited by akj on Wed Aug 06, 2008 6:21 pm, edited 1 time in total.
Anthony Jordan
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")
I may look like a mule, but I'm not a complete ass.
The code here is the best:
http://www.purebasic.fr/german/viewtopic.php?t=12155
It loads BMP, JPG, PNG and GIF files without using any third-party libraries
or PureBasic's in-built decoders. Saves on executable size immensely!
http://www.purebasic.fr/german/viewtopic.php?t=12155
It loads BMP, JPG, PNG and GIF files without using any third-party libraries
or PureBasic's in-built decoders. Saves on executable size immensely!
Thank you for all the suggestions.
I am using Windows ME and this has led me to adopt PB's advice of using the routine[s] posted on the German Forum.
Incidently I notice some small errors in the routines CatchSpriteEx() and CatchImageEx() which are posted there:
should be:
The statement order and indendation both need correcting.
(I have not posted this in the German forum.)
I am using Windows ME and this has led me to adopt PB's advice of using the routine[s] posted on the German Forum.
Incidently I notice some small errors in the routines CatchSpriteEx() and CatchImageEx() which are posted there:
Code: Select all
dxsf\Release()
EndIf
Stream\Release()
EndIf
dxtf\Release()
EndIf
Code: Select all
Stream\Release()
EndIf
dxsf\Release()
EndIf
dxtf\Release()
EndIf
(I have not posted this in the German forum.)
Anthony Jordan
-
- Enthusiast
- Posts: 665
- Joined: Fri Sep 12, 2003 10:40 pm
- Location: Tallahassee, Florida
here you go. 100% PB source for loading a GIF:
http://www.purebasic.fr/english/viewtop ... if+decoder
http://www.purebasic.fr/english/viewtop ... if+decoder
Code: Select all
!.WHILE status != dwPassedOut
! Invoke AllocateDrink, dwBeerAmount
!MOV Mug, Beer
!Invoke Drink, Mug, dwBeerAmount
!.endw