BMP to GIF Converter

Just starting out? Need help? Post your questions and find answers here.
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

BMP to GIF Converter

Post by Karbon »

I'm looking for a small executable or DLL library I can use to convert BMP format images to GIF.. Anyone know of anything?
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
Inf0Byt3
PureBasic Fanatic
PureBasic Fanatic
Posts: 2236
Joined: Fri Dec 09, 2005 12:15 pm
Location: Elbonia

Post by Inf0Byt3 »

Hi Karbon,

I don't know if it really helps you, but Progi1984 has created a wrapper for FreeImage. You can find more information here:

http://www.purebasic.fr/english/viewtop ... c&start=30
None are more hopelessly enslaved than those who falsely believe they are free. (Goethe)
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Aye, FreeImage is great and Progi has done a great job.

Code: Select all

IncludeFile "RW_FreeImage_Inc.pb"

dib = FreeImage_Load(#FIF_BMP, "bm1.bmp", #BMP_DEFAULT)
FreeImage_Save(#FIF_GIF, dib, "test.gif",0)
I may look like a mule, but I'm not a complete ass.
Derek
Addict
Addict
Posts: 2354
Joined: Wed Apr 07, 2004 12:51 am
Location: England

Post by Derek »

I'm pretty sure you can save GIF's using GDI+.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Derek wrote:I'm pretty sure you can save GIF's using GDI+.
You can indeed, I just tried it. :)
I may look like a mule, but I'm not a complete ass.
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Post by Karbon »

Thanks for the pointer to FreeImage.

Are there some GDI+ examples floating around for PB?
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
User avatar
einander
Enthusiast
Enthusiast
Posts: 744
Joined: Thu Jun 26, 2003 2:09 am
Location: Spain (Galicia)

Post by einander »

HI Karbon:
Do a search for GDIPLUS
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

There are some excellent PB wrappers for the gdi+ library in these forums.

However, if saving to gif is all you are after......

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) 
    GdiplusShutdown(token)
    GdipCreateBitmapFromFile(filename.p-unicode, *bitmap)
    GdipSaveImageToFile(image, filename.p-unicode, *clsidEncoder.CLSID, *encoderParams)
    GdipDisposeImage(image)
  EndImport


;First initialise gdi+.
  input.GdiplusStartupInput
  input\GdiPlusVersion = 1
  GdiplusStartup(@token, @input, #Null)
  ;Was the initialisation successful?
    If token
      If GdipCreateBitmapFromFile("bm1.bmp", @image) = #GDIPLUS_OK
        GdipSaveImageToFile(image, "test.gif", ?clsid_giff, 0)
        GdipDisposeImage(image)
      EndIf
      ;Tidy up.
        GdiplusShutdown(token)
    EndIf

End

;CLSID for the gdi+ gif encoder.
DataSection
clsid_giff:
  Data.l $557CF402
  Data.w $1A04, $11D3
  Data.b $9A, $73, $00, $00, $F8, $1E, $F3, $2E
EndDataSection
I may look like a mule, but I'm not a complete ass.
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Post by Karbon »

Thanks!

I can't get FreeImage to create a gif.. I can change FIF_GIF to FIF_JPEG (or any other format) and it works great. If I use GIF it just creates a 4k blank file.

I'm using Progi's wrapper and it looks to be up to date..
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Post by Karbon »

Karbon wrote:Thanks!

I can't get FreeImage to create a gif.. I can change FIF_GIF to FIF_JPEG (or any other format) and it works great. If I use GIF it just creates a 4k blank file.

I'm using Progi's wrapper and it looks to be up to date..
Oh, and FreeImage_IsPluginEnabled(#FIF_GIF) does return 1
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Strange - works okay here. I have found that I have to convert bitmaps to 24 bit before saving as JPEGs etc. I wonder if the gif plugin requires something similar?
I may look like a mule, but I'm not a complete ass.
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Post by Karbon »

The exact same source BMP image saves as any other format but GIF just by changing FIF_GIF to FIF_<whatever>

Very strange!
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Can you e-mail me the image in question? Switching to pm.
I may look like a mule, but I'm not a complete ass.
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Post by Karbon »

Ah, it works if I first convert the BMP to an 8 bit BMP.
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Yes, but the color table seems to be a grey scale one here! Is there a way of getting FreeImage() to create a better pallete?
I may look like a mule, but I'm not a complete ass.
Post Reply