Importing troubles

ModKeen mods Tiles and Sprites in all episodes of Commander Keen.
Post Reply
Herry Jerry
Posts: 18
Joined: Sat Mar 29, 2008 10:54 pm

Importing troubles

Post by Herry Jerry »

Hello,
I'm trying to make a Keen 4 mod, but when I modify any of the 4BMPxxxx files and import them, Modkeen crashes and tells me it can't open whichever one I modified!
I'm under Ubuntu Linux, running Modkeen 2.0.1 with DOSBox, and editing the images with mtPaint. I've tried editing them with MS Paint, but it won't execute under Wine. The sprites are working okay (even though I only have about 5 frames of Keen done), but then I'm using KeenGrout.

Any ideas?
User avatar
Tulip
Posts: 394
Joined: Mon Jun 16, 2008 2:40 pm
Location: Heidelberg, Germany
Contact:

Post by Tulip »

Be sure that the color format of your bitmap is 16 colors. Some painting programs (like Paint.NET, I don't know about yours) change the color depth when saving.
If that is problem and your program can't save in 16 Colors, Gimp can.
Herry Jerry
Posts: 18
Joined: Sat Mar 29, 2008 10:54 pm

Post by Herry Jerry »

Tulip wrote:Be sure that the color format of your bitmap is 16 colors. Some painting programs (like Paint.NET, I don't know about yours) change the color depth when saving.
If that is problem and your program can't save in 16 Colors, Gimp can.
Actually, the reason I use mtpaint is because it can save in 16 colours. :P When I used KolourPaint (no palette support) the images were screwed up in-game, but they were still import-able. :/
levellass
Posts: 3001
Joined: Wed Oct 11, 2006 12:03 pm
Location: Ngaruawahia New Zealand

Post by levellass »

I believe then that what you may want is LModkeen, which can run by itself on linux systems: http://www.shikadi.net/keenwiki/ModKeen
User avatar
CommanderSpleen
Posts: 1017
Joined: Sun Aug 31, 2003 12:11 pm
Location: The Land of Sparkly Things
Contact:

Post by CommanderSpleen »

Hmm, thought I responded to this.

I have encountered the same problem in my Linux Keen modding adventures, but found a workaround. For Keen 1, at least, but since the symptom is similar the solution is likely to work. Open the exported bitmap in GIMP, and create 24-bit copy to edit in mxPaint or KolourPaint. When you save the changes, select all and copy into GIMP. Save the file (not As) and voila, importable 4-bit bitmap.

Checking the format of the image with ImageMagick (I forget which particular tool it was) shows that a 16-colour bitmap saved from GIMP is a different sub-format (something-class IIRK) to the one that modkeen exports, and this subtle difference is enough to make the image invalid for importing.

And yes, you definitely want lmodkeen. I use it without any hassles (besides the lowercase names issue, but that's easily resolved with a script available in one of the lmodkeen threads in the ModKeen subforum.
Herry Jerry
Posts: 18
Joined: Sat Mar 29, 2008 10:54 pm

Post by Herry Jerry »

CommanderSpleen wrote:Hmm, thought I responded to this.

I have encountered the same problem in my Linux Keen modding adventures, but found a workaround. For Keen 1, at least, but since the symptom is similar the solution is likely to work. Open the exported bitmap in GIMP, and create 24-bit copy to edit in mxPaint or KolourPaint. When you save the changes, select all and copy into GIMP. Save the file (not As) and voila, importable 4-bit bitmap.

Checking the format of the image with ImageMagick (I forget which particular tool it was) shows that a 16-colour bitmap saved from GIMP is a different sub-format (something-class IIRK) to the one that modkeen exports, and this subtle difference is enough to make the image invalid for importing.

And yes, you definitely want lmodkeen. I use it without any hassles (besides the lowercase names issue, but that's easily resolved with a script available in one of the lmodkeen threads in the ModKeen subforum.
It works! Thanks, Spleen!

I've been trying to use lmodkeen, but it doesn't work. I tried to import the files, but it wouldn't work even when the case was the same as it displayed in the error message. So I tried to re-import (export and then import) so that the case and the filenames would be the same. It gives me another error: "Not enough memory to decompress EGAGRAPH chunk 0 (size 1CC at 8)!"

Ah well, running modkeen in DOSBox is good enough for the time being. :)
User avatar
CommanderSpleen
Posts: 1017
Joined: Sun Aug 31, 2003 12:11 pm
Location: The Land of Sparkly Things
Contact:

Post by CommanderSpleen »

Aha! I've just figured out an even more efficient way of doing this using ImageMagick.

Code: Select all

convert [24-bit bitmap] -colors 16 [target bitmap]
Example:
convert 1til0000-24.bmp -colors 16 1til0000.bmp
This outputs a file that ImageMagick identifies as 8-bit PseudoClass 16c, which is exactly what Modkeen expects.

Now to construct a script to do this en masse.

EDIT: Blast, there's still the issue of the palette. Importing files converted in this manner end up with incorrectly assigned colours. Must be a way to fix this...
levellass
Posts: 3001
Joined: Wed Oct 11, 2006 12:03 pm
Location: Ngaruawahia New Zealand

Post by levellass »

Traditionally I have found this hard to do, since a lot of programs like to rearrange palettes when they change things. Perhaps what you want it Palsuite 3, the Jazz Jackrabbit utility for editing the palettes of various things. (I use it to check my program's exports.)

http://www.alister.eu/palsuite/


Though if you want I could write a short program to convert any and all Modkeen-ish images from 24 to 8-bit, but I doubt it's worth it.
User avatar
CommanderSpleen
Posts: 1017
Joined: Sun Aug 31, 2003 12:11 pm
Location: The Land of Sparkly Things
Contact:

Post by CommanderSpleen »

That's pretty much what I'm trying to achieve here. A CLI utility to mass convert modkeen bitmaps into 8-bit with the correct palette would be beautiful. The current alternative is to open the image in GIMP, paste the modified version, then save. For every single modified bitmap.

Care to post some info about the format?
levellass
Posts: 3001
Joined: Wed Oct 11, 2006 12:03 pm
Location: Ngaruawahia New Zealand

Post by levellass »

The utility has been coded! Get it here: http://levellord.toxicsheep.com/MODVERT.zip


What it does is copy and convert 16 color to 256 color bitmaps (And vice versa) filling the 'extra' colors with black, while keeping the useful 16 colors in the same order. Bitmap format is as follows:

Code: Select all

0  2    String "BM'
2  4    File size
6  4    Blank
10 4    Header size, 118 for 4-bit, 1078 for 8-bit
14 4    ? dword value 40
18 4    Bitmap width
22 4    Bitmap height
26 2    Word value 1
28 4    Type, dword value 4 for 4-bit, 8 for 8-bit, etc
32 22   Some gibberish, not useful
54 ?    Palette, x * 4 byte RGBS entries, 64 for 4-bit, 1024 for 8-bit
?  ?    Bitmap data, if width is not divisible by 4 each row as extra, unread data
        added to it to make it so. Rows are stored starting from the bottom of the
        bitmap to the top, but are read left to right.
User avatar
CommanderSpleen
Posts: 1017
Joined: Sun Aug 31, 2003 12:11 pm
Location: The Land of Sparkly Things
Contact:

Post by CommanderSpleen »

Care to add a means of keeping a 4- and 8-bit set of bitmaps in the same directory? For example, the 8-bit tile bitmap could be 1tilx000.bmp, and converting to 16 colour would simply overwrite 1til0000. 'Twould save on converting back and forth between editing and importing.

Also I've figured out the final piece of the puzzle in the conversion method--creating a program to overwrite the palette data at 0x36 with the correct palette data.

Gotta love how complicated these things can be.
Post Reply