Another Image Plugin (Support PNG)

Developed or developing a new product in PureBasic? Tell the world about it.
ward
User
User
Posts: 13
Joined: Mon Mar 20, 2006 8:44 am

Another Image Plugin (Support PNG)

Post 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
Pantcho!!
Enthusiast
Enthusiast
Posts: 538
Joined: Tue Feb 24, 2004 3:43 am
Location: Israel
Contact:

Post by Pantcho!! »

Waiting for animated GIF ;)

good job.
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 »

(For now, PNG file is not support by CatchImage())
Sure it is! :wink:
BERESHEIT
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Post 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).
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 »

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)
BERESHEIT
ward
User
User
Posts: 13
Joined: Mon Mar 20, 2006 8:44 am

Post 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.
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 »

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.
BERESHEIT
ward
User
User
Posts: 13
Joined: Mon Mar 20, 2006 8:44 am

Post 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.
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Post by Polo »

Sorry to say that, but my beta is a stable install, and it does NOT work.
Post Reply