Page 1 of 1

GdiplusCodecs library - Alpha 0.6 Updated New Commands

Posted: Thu Oct 26, 2006 1:07 pm
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!

Posted: Thu Oct 26, 2006 10:23 pm
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.

Posted: Thu Oct 26, 2006 10:27 pm
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.

Posted: Thu Oct 26, 2006 10:33 pm
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.

Posted: Thu Oct 26, 2006 10:42 pm
by srod
Interesting.

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

It's quite a big pile mind! :)

Posted: Fri Oct 27, 2006 5:31 am
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.

Posted: Fri Oct 27, 2006 6:40 am
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

Posted: Fri Oct 27, 2006 3:14 pm
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.