Page 1 of 1

Another Image Plugin (Support PNG)

Posted: Mon Mar 20, 2006 12:30 pm
by ward
This plugin is similar to El_Choni's EC_ImagePluginOLE. But it also support PNG format, and can use CatchImage() to read image in the exe resource. (Testing under PureBasic 3.94.)

To use this plugin, copy wxCmmImgPlugin to UserLibraries folder, and add the following line in your program:

Code: Select all

UseWxCmmImageDecoder()
You can test it under El_Choni's example, just replace UseOLEImageDecoder() to UseWxCmmImageDecoder(), add "*.png" in OpenFileRequester, and then try to open some PNG file.

To use CatchImage(), you must add image file as a Raw Data Resource. For example (jaPBe), select Project menu -> Project Options -> Resources -> New. Type: Raw Data, Name: Image1, and use code:

Code: Select all

 CatchImage(0, "Image1") 

(For now, PNG file is not support by CatchImage())

Thanks to El_Choni for the idea and the example.

About wxCmm: wxCmm is an opensource framework for C-- language. This plugin is just a shell of wxCmm's wxBitmap.LoadFile() method.

Download wxCmmImgPlugin
El_Choni's version and example here

Posted: Mon Mar 20, 2006 9:23 pm
by Pantcho!!
Waiting for animated GIF ;)

good job.

Posted: Mon Mar 20, 2006 9:51 pm
by netmaestro
(For now, PNG file is not support by CatchImage())
Sure it is! :wink:

Posted: Mon Mar 20, 2006 9:59 pm
by Polo
With 4.0b7, I get :
POLINK: error: Unresolved external symbol '_lstrlenA'.
POLINK: error: Unresolved external symbol '_lstrcpyA'.
POLINK: fatal error: 2 unresolved external(s).

Posted: Mon Mar 20, 2006 10:04 pm
by netmaestro
That looks like you don't have a stable install of the beta. This can happen if old libs get mixed in somehow, perhaps because of not installing to a clean empty folder. Dunno about the error you're getting but believe me, it works, I've been using it for the better part of a year without problems.

Another thing you may need to do is pass the length of the PNG file to the CatchImage() command, see if that fixes it for you. This is occasionally necessary with decoders for compressed images such as jpg and png.

Code: Select all

Catchimage(0, ?MyImage, 34766)

Posted: Tue Mar 21, 2006 4:16 am
by ward
netmaestro wrote:That looks like you don't have a stable install of the beta. This can happen if old libs get mixed in somehow, perhaps because of not installing to a clean empty folder. Dunno about the error you're getting but believe me, it works, I've been using it for the better part of a year without problems.

Another thing you may need to do is pass the length of the PNG file to the CatchImage() command, see if that fixes it for you. This is occasionally necessary with decoders for compressed images such as jpg and png.

Code: Select all

Catchimage(0, ?MyImage, 34766)
Thanks, but this may not work.

This library (wxCmm) decode JPG/GIF/WMF/ICO by IPicture (just link El_Choni's plugin). IPicture can decode image in memory, so when you use CatchImage(0, "Image1"), the loader of wxCmm will find "Image1" in raw data resource, and then decode it. (Why not use IncludeBinary ? Because IPicture need the file size)

Because of IPicture can't decode PNG file, so PNG is decoded by IImgCtx. IImgCtx support PNG file but don't decode image in memory. So CatchImage() can't work in this situation.

Posted: Tue Mar 21, 2006 4:19 am
by netmaestro
OK, I see what you mean. I was considering it from the point of view of using the built-in PNG decoder, but this one does more than that.

Posted: Tue Mar 21, 2006 4:28 am
by ward
In fact, there still one solution to use IImgCtx to decode PNG file in the memory. But I have no time to test the idea for now, maybe later.

Posted: Tue Mar 21, 2006 5:36 pm
by Polo
Sorry to say that, but my beta is a stable install, and it does NOT work.