Saving a PNG?
Blitz3D Forums/Blitz3D Programming/Saving a PNG?
| ||
My game need to save an image which will be uploaded and displayed on a web page. Ideally this will be PNG (the PHP library can covert this). After a quick investigation it looks like this isn't a trivial task. Has anyone got any code to do this? I notice BMAX can save to PNG. Can I create a DLL in BMAX? |
| ||
No you can't, its not allowed. |
| ||
What do you mean, not allowed? |
| ||
Making DLL with BMax |
| ||
I think it is mentioned in this thread: http://www.blitzbasic.com/Community/posts.php?topic=53607&hl=dll%20making |
| ||
...or, perhaps a little more helpfully, you could use this: http://www.blitzcoder.com/cgi-bin/showcase/showcase_showentry.pl?id=snarty09252003024804&comments=no |
| ||
Out of interest: what will the PHP library convert it to? |
| ||
Yeah, I use FreeImage with Paul Snart's Blitz3D wrapper. I cut down the wrapper to my own requirements and fixed a few minor bugs. It only saves images in 24-bit, though. Here's the code, in case it's of any use: P.S. It seems a bit strange that Blitz3D can't save PNG images natively, given that it uses FreeImage itself. :/ |
| ||
Cheers Big10p. I'll have a go with that code. Beaker, I think it gets converted to jpg. |
| ||
Big10p, Do I need a decls file to use that? I've found the dll. Also, what's the deal with the licence? Can I use this commercially? |
| ||
Sorry, forgot about the decls - you actually need 2: freeimage.decls kernel32.decls Also, what's the deal with the licence? Can I use this commercially? Well, you can certainly use FreeImage commercially. As I said, Blitz3D actually uses it as an image loader. From the FreeImage site:When using FreeImage in your open source or commercial application, you are REQUIRED to : distribute the license (GNU GPL or FIPL) you choosed with your application (i.e. the TXT file) provide a suitable acknowledgement, either in the program's "About" box or in the user's manual (or both), for example : This software uses the FreeImage open source image library. See http://freeimage.sourceforge.net for details. FreeImage is used under the (GNU GPL or FIPL), version (licence version). As for the wrapper, I can't actually remember where I sourced it. However, I'm sure it's free for commercial use, which it says in the comments at the top of the code. They're comments by the original author, not me. |
| ||
BTW John, I decided to stick with using the version of the FreeImage dll that was shipped with the wrapper, just in case a newer version of the dll caused compatibility issues with it. Using a newer version of the dll will probably be fine, but if you want the older version for the same reason, email me (addy in profile) and I'll shoot it over to you. |
| ||
Got it all working now - cheers! |
| ||
No problem. :) |
| ||
At the risk of sounding bitter and twisted, I posted a link to the Freeimage wrapper and DLL nine posts and eleven hours ago. |
| ||
Hmm, when I looked at that link earlier, I thought it was the B+ only version. My version is a bit different to that one, anyway - cut-down, bug-fixes. Ah, well. :) |
| ||
And a stellar job you've done with it too. :o) Since you're around, I'll ask: which bit does yours replace? Just the freeimage.bb (aka freeimage3D.bb) include file? All the rest works the same? |
| ||
I didn't really do much. Just combined everything into a single include file, chopped everything out I didn't need and fixed a couple minor bugs. It's still 100% Paul Snarts work, as far as I'm concerned. :) |
| ||
I find myself needing to save .pngs and have grabbed the latest FreeImage lib and this wrapper by big10p. It works save for the .png being saved upside down! Any fixe? |
| ||
What version of the FreeImage DLL are you using? Are the other image types saving correctly? |
| ||
Long time no see (again ;) ) Freeimage is version 3.10.0. .bmp's are upside down as well as .pngs. |
| ||
Please don't dredge up old posts. http://www.blitzbasic.com/codearcs/codearcs.php?code=1732 |