GdiplusCodecs library - Alpha 0.6 Updated New Commands

Developed or developing a new product in PureBasic? Tell the world about it.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

GdiplusCodecs library - Alpha 0.6 Updated New Commands

Post by netmaestro »

I'm doing some lib work with Gdiplus and one of the areas I'm covering is that of image decoding/encoding using Gdiplus. Decoding and encoding are done but encoding has no optional parameters as yet- all encodings are done with Gdiplus default values for now. If people could do some test encoding and see how it goes, I'd appreciate it. Here's how to call the function:

Loading or Catching images:

LoadDecodedImage(ImageNumber, Filename$)

CatchDecodedImage(ImageNumber, Address, Length)

Example: CatchDecodedImage(0, ?pic1, ?pic2-pic1)

Both Load and Catch accept #PB_Any and will return same values as corresponding PureBasic native commands.

SaveEncoded(ImageID, codec, filename$)

Where 'codec' is one of the following options:

#GdipCodecs_Bmp = 0
#GdipCodecs_Jpeg = 1
#GdipCodecs_Gif = 2
#GdipCodecs_Tiff = 3
#GdipCodecs_Png = 4

Here is an example test I did during development:

Code: Select all

LoadImage(0,"d:\_tax\kate_moss_gallery_29.bmp")

Debug SaveEncoded(ImageID(0), #GdipCodecs_gif, "d:\gotmilk.gif")
A return value of #True indicates success, and #False is failed.

Here's the resulting gif from that test:

Image

And finally, here is the lib:

http://www.networkmaestro.com/GdiplusCodecs.zip

A disadvantage of this library is that it requires Gdiplus.dll, which will be present on all WinXP machines, but you'll have to provide the redistributable dll from MS for other target OS's. Not a huge deal imho.

A real advantage of this lib is it will encode all these formats while only adding 3k to the size of your exe!
Last edited by netmaestro on Mon Oct 30, 2006 10:43 pm, edited 3 times in total.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

I have LoadImage and CatchImage written for all codecs, I'll upload an update tomorrow. For now, try this demo and see one of the things you'll be able to do easily with this lib:

http://www.networkmaestro.com/GdipDemo.exe

Right-click the wheel to close it. Notice the 0% CPU usage, high quality of rotation display, and it continues to turn while being moved.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

8)

That's pretty cool. Great work.

How easy is the windows gdi+ library to use? It's something I've not had time to look at yet.
I may look like a mule, but I'm not a complete ass.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

Once you understand the lay of the land, it's really pretty straightforward. The Gdiplus image objects are not standard bitmaps, and you just have to get the hang of drawing them onto PB images and creating them from a variety of sources. CatchImage took a bit of fooling with, but in the end I managed it with GdipCreateBitmapFromStream and it's working well now. I love the no-decoder-footprint feature of using it, and it handles gifs, wmfs and ico's in addition to the standard formats. Once you get into it, I guarantee you'll never use standard GDI again.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Interesting.

One for the 'must look at very soon' pile.

It's quite a big pile mind! :)
I may look like a mule, but I'm not a complete ass.
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3942
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Post by wilbert »

I started on a Gdi+ userlib a few years ago but abandoned the project
http://www.purebasic.fr/english/viewtopic.php?t=12434
It doesn't include a save function like this lib does but a lot of drawing functions. If someone would be interested in the asm sources to develop it further, please let me know.
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

Post by Flype »

a french guy - Denis (MoreListIcon) - is working on a large implementation of the GDIPlus for PB4 since some weeks. it's a huge work as there are hundred of functions (about 610).

some infos here (in french) and some interesting examples :
http://purebasic.forum-gratuit.com/view ... highlight=

i also started a wrapper for PB4 (Denis started his own implementation upon this one) which is available here :
http://purebasic.myftp.org/?filename=fi ... diplus.zip
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

As promised, Load and Catch image are done. See first post. No decoders required for BMP, JPEG, GIF, ICO, PNG, TIFF, WMF images. Adds 3k to the size of your exe.
Post Reply