Save Pixmap as BMP?

BlitzMax Forums/BlitzMax Beginners Area/Save Pixmap as BMP?

Grey Alien(Posted 2006) [#1]
OK I must be pretty dumb here, but I can load a Pixmap from BMP, JPG or PNG, and save to JPG or PNG, *BUT* I can't find a command to save the PixMap as BMP. How do I do it please or do I need to convert it to a TImage first? Thanks :-)


GfK(Posted 2006) [#2]
No idea, but all the code is there for loading a BMP file in the BMPLoader module. It wouldn't be massively difficult to write a SavePixmapBMP function based on the same code.

What do you want to use BMP format for anyway??


tonyg(Posted 2006) [#3]
Saving Images/Pixmap ?


ImaginaryHuman(Posted 2006) [#4]
SavePixmapBMP() ?


GfK(Posted 2006) [#5]
SavePixmapBMP() ?
There's no such command.


tonyg(Posted 2006) [#6]
SavePixmapBMP() ?

Have you got a native Bmax function called that?


Grey Alien(Posted 2006) [#7]
tonyg: thanks for the link.

I need it because my game has some jpg backgrounds that I want to let the user set as the desktop wallpaper BUT the API command to do that only accepts jpgs! So I need to load in a JPG bitmap and save as BMP. I was *MOST* surprised to find there is no options to save as BMP, I know it's bloaty but it's a fundamental data type!


ImaginaryHuman(Posted 2006) [#8]
Isnt the bmp format really really easy, like a raw uncompressed file dump? BMP is a pretty basic crappy format.


tonyg(Posted 2006) [#9]
your wiki friend is
Bmx version in the link posted previously.


Grey Alien(Posted 2006) [#10]
yeah I'm not reinventing the wheel here, I'm gonna use that code ... *except that it doesn't work* I've just found out.

Masks[0] gives Compile Error: Identifier 'masks' not found

oh dear.


xlsior(Posted 2006) [#11]
BMP is indeed one of the most basic graphic formats that are there, although there are several sub-formats as well. You have the option of using RLE compression (Run-Length Encoding) which can shave off a little size, but it's nowhere near as complex as the compression used for JPEG or GIF.

I wrote a PCX saver for PowerBASIC years ago, and didn't find it that difficult to implement the PCX RLE compression. Just looking at the GIF compression made my head explode, though. If you aren't too concerned about the compression thing, plain non-compressed BMP's are a very simple format, pretty much just a specified header with a raw data dump at the end. If you take a look at the BMP specifications at http://www.wotsit.org , you'll find it pretty straightforward.


BlackSp1der(Posted 2006) [#12]
Grey Alien:
yeah I'm not reinventing the wheel here, I'm gonna use that code ... *except that it doesn't work* I've just found out.

Masks[0] gives Compile Error: Identifier 'masks' not found

oh dear.



because Masks is not part of TImage. Change all masks[] with pixmaps[]


Grey Alien(Posted 2006) [#13]
It's OK I got the answer a few days ago here:

http://www.blitzbasic.com/Community/posts.php?topic=46036

Xlsior: Yeah I have loaded and saved BMP and PCX in DOS in C++ and assembly about 10 years ago. I just didn't want to code it again when I knew code for BMax must already be written.


Grisu(Posted 2006) [#14]
Why would one want to save an image as bloated ugly uncompressed bmp?


Grey Alien(Posted 2006) [#15]
I'm sure I said in one of the threads...anyway basically the API code to set the windows desktop wallpaper doesn't work with non-bmps (i.e. jpgs or pngs!) so I have to save a copy of the jpg as a bmp and set that as the wallpaper. See I had a good reason ;-)


Alessandro(Posted 2006) [#16]
Take a look to this library:

http://www.blitzcoder.com/cgi-bin/showcase/showcase_showentry.pl?id=snarty09252003024804&comments=no