Editor can't load its own saved walkable area mask (v. 3.5)

Started by pell, Thu 09/04/2020 03:02:27

Previous topic - Next topic

pell

When I export a walkable area from the room editor using the "Export mask to file" feature, then try to reload it using "Import mask from file", I get the following error message:
"This is not a valid mask bitmap. Masks must be 256-colour(8-bit) images, using the first colours in the palette to draw the room areas."

I originally got that message trying to load a walkable mask I created in GIMP. I'm not very familiar with GIMP's indexed color features, so I thought I'd take a look at a file produced by the editor as reference. But even the editor's own saved mask file fails to load. This happens with masks I create using the editor's mask tools as well as with walkable masks that come with the template games.

I'm running the AGS 3.5 editor in Wine on Debian 10 Linux. Can anyone replicate this in Windows?

Crimson Wizard

#1
Uh! There was such error in 3.5.Beta, when it did not save masks properly, but I think it was fixed since. First of all, could you double check what is the full version of the editor (found in Help - About)?

pell

The full version line reads: AGS Editor .Net (Build 3.5.0.24)

It has been at least a couple of weeks since I downloaded it. I'll check to see if there's a newer download available. Import may actually work. I just don't have a proper file to test with. I'll check the GIMP manual to see how to produce an 8-bit image with the colors AGS wants.

Edit: I'm using the latest version available on the Download AGS page.

Edit: I had some luck getting external indexed images to import. The colors weren't arranged the way AGS wanted them, so it's hard to tell if it's functioning correctly. But at least they imported. That's promising.

Crimson Wizard

Could you upload an exported mask that did not work, so that I could check it out?

pell

Sure. Here's a link to the file:
https://gitlab.com/gamesbypell/misc/-/blob/master/DefaultSierraGame_AGS3.5.0.24_WalkableAreaMask.bmp

Edit: Gimp loads that as a regular RGB file. I tried converting it back to an indexed 8-bit image and importing it, but that failed. However, I'm still learning the 8-bit features of Gimp, so maybe I did something wrong.

Edit: I've managed to get Gimp to generate an image file that the AGS editor will accept for walkarounds, hot spots, etc. It's an ugly, hacky workaround, but it'll probably do for now.

TheManInBoots

#5
To give you some background on how to make your mask usable with GIMP:

The image you provided the link for is in RGB to begin with.
So you need to change it to indexed. (Clicking: Image>Mode>Indexed)

Even if you choose 256 colors it automatically runs down the colormap to the colors present in the image (2 colors in your image).
So to fix this afterwards I create a new colormap (Colors>Map>Set Colormap) which includes exactly 256 colors. I pick one out of the list which includes a lot of different colors.

Now I also want black to be the transparent background color. AGS uses the color with ID 0 as transparency.
So I open the color map (Windows>Dockable Dialogs>Colormap), right click it and select Rearrange Colormap...
Now I move the black color to position 0, and the colors I want to use to positions 1-15 on the palette. Those are the colors AGS is going to use for Walkable Areas 1-15 (and that you should use to draw the walkable areas, obviously).

That's how you make it usable for AGS.
Note that when you export a mask from AGS and then import it into GIMP, GIMP should never change the color format without asking you.
So you probably changed some settings that made it not work in the first place. Otherwise you could have just exported and used it in AGS.

Also when exporting the image to a new name you have to make sure that both "Run Length-Encoded" and "Do not write color space information" are not selected in the pop-up window.

AGS is very sensitive as to what it accepts to import masks, so I hope that gives you a better overview on how to use GIMP for that ;)

pell

Quote from: TheManInBoots on Fri 10/04/2020 12:42:55
To give you some background on how to make your mask usable with GIMP:

The image you provided the link for is in RGB to begin with.
So you need to change it to indexed. (Clicking: Image>Mode>Indexed)

Even if you choose 256 colors it automatically runs down the colormap to the colors present in the image (2 colors in your image).
So to fix this afterwards I create a new colormap (Colors>Map>Set Colormap) which includes exactly 256 colors. I pick one out of the list which includes a lot of different colors.

Now I also want black to be the transparent background color. AGS uses the color with ID 0 as transparency.
So I open the color map (Windows>Dockable Dialogs>Colormap), right click and select Rearrange Colormap...
Now I move the black color to position 0, and the colors I want to use to positions 1-15 on the palette. Those are the colors AGS is going to use for Walkable Areas 1-15 (and that you should use to draw the walkable areas, obviously).

That's how you make it usable for AGS.
Note that when you export a mask from AGS and then import it into GIMP, GIMP should never change the color format without asking you.
So you probably changed some settings that made it not work in the first place. Otherwise you could have just exported and used it in AGS.

Also when exporting the image to a new name you have to make sure that both "Run Length-Encoded" and "Do not write color space information" are not selected in the pop-up window.

AGS is very sensitive as to what it accepts to import masks, so I hope that gives you a better overview on how to use GIMP for that ;)

Well, the original problem I mentioned in the first post involved exporting the walkable area mask from the editor and immediately trying to import it without messing with it at all. Apparently there's a bug in the export functionality that the devs thought they fixed.

Thanks for the tutorial. I'll try it out later this afternoon. My fingers are crossed, because not all the Indexed Color features were working for me when following the Gimp manual. I couldn't find the Rearrange Colormap dialog, for instance, and it wouldn't let me edit colors in the colormap. I may have been doing something wrong.

My solution so far was very hacky. Apparently there's a bug in Gimp's BMP export plugin that won't export a full 8-bit colormap unless you have more than 16 colors in your image. So I was hiding 16 colors in a layer behind a black background (which counted as the 17th) and then used the actual colors I wanted in layers above the background. Even so, not just any color would show up in the editor as the walkable map color.

TheManInBoots

#7
In any case, I tried it out, and following the steps I described above, I could eventually import your mask into AGS in Windows.
And exporting a mask, loading it into GIMP, exporting it and then re-importing it into AGS, also works fine for me on Windows.

It might be worth considering if AGS should be able to import a wider range of color formats with mask images in the future to avoid having to pay such scrupulous attention to details for mask image editing and export.

morganw

I would imagine this is a bug in WINE or a related component and not directly an AGS issue. I compared the mask that was uploaded to one which I exported myself:

Code: ags

$ file DefaultSierraGame_AGS3.5.0.24_WalkableAreaMask.bmp 
DefaultSierraGame_AGS3.5.0.24_WalkableAreaMask.bmp: PC bitmap, Windows 3.x format, 320 x 200 x 24

$ file export_test.bmp 
export_test.bmp: PC bitmap, Windows 3.x format, 320 x 200 x 8


My export is 8 bit and imported without error, so unfortunately I'm not sure what to suggest for a simple solution.

pell

Quote from: TheManInBoots on Fri 10/04/2020 13:50:52
In any case, I tried it out, and following the steps I described above, I could eventually import your mask into AGS in Windows.
And exporting a mask, loading it into GIMP, exporting it and then re-importing it into AGS, also works fine for me on Windows.

It might be worth considering if AGS should be able to import a wider range of color formats with mask images in the future to avoid having to pay such scrupulous attention to details for image editing and export.

Your tutorial worked perfectly. Thank you. I didn't realize I needed to choose a color map other than the one for the current image. That's why things didn't work for me. I'll just add that you still only need 17 colors in your map rather than the whole 256. You also have to choose your colors carefully so you don't have two or more colors displaying as only one color in 8-bit mode. But this will be a big help.

Quote from: morganw on Fri 10/04/2020 15:03:17
I would imagine this is a bug in WINE or a related component and not directly an AGS issue. I compared the mask that was uploaded to one which I exported myself:

Code: ags

$ file DefaultSierraGame_AGS3.5.0.24_WalkableAreaMask.bmp 
DefaultSierraGame_AGS3.5.0.24_WalkableAreaMask.bmp: PC bitmap, Windows 3.x format, 320 x 200 x 24

$ file export_test.bmp 
export_test.bmp: PC bitmap, Windows 3.x format, 320 x 200 x 8


My export is 8 bit and imported without error, so unfortunately I'm not sure what to suggest for a simple solution.

I suspected it could be a Wine issue. I'm not normally a Wine user, so I'm surprised the editor works as well as it does. If other Windows users can confirm exporting a walkable area/hotspot/walk behind file from the editor and then importing it without any modification works fine, I'll call this one solved.

TheManInBoots

#10
Quote from: pell on Fri 10/04/2020 16:29:38
Your tutorial worked perfectly. Thank you. I didn't realize I needed to choose a color map other than the one for the current image. That's why things didn't work for me.
Glad I could help. It looked like that was part of the problem.
Quote from: pell on Fri 10/04/2020 16:29:38
I'll just add that you still only need 17 colors in your map rather than the whole 256.
That's interesting. I'll keep it in mind. Did you try if it works with 16 colors? (1 transparency color and 15 areas-> 16 colors).

Crimson Wizard

Quote from: morganw on Fri 10/04/2020 15:03:17
I would imagine this is a bug in WINE or a related component and not directly an AGS issue.

Could be the way we ensure bitmap to 8-bit on export in .NET may have a simpler alternative?

TheManInBoots

#12
Quote from: morganw on Fri 10/04/2020 15:03:17
I would imagine this is a bug in WINE or a related component and not directly an AGS issue.
Btw. I'd like to mention that it's not obvious that the mask pell uploaded is the one they directly exported from AGS.
To me it seems the image pell uploaded is the one they edited and exported with Gimp.
So it would be useful to know what file pell uploaded, just to avoid drawing wrong conclusions.

pell

Quote from: TheManInBoots on Fri 10/04/2020 16:36:22
(snip)
That's interesting. I'll keep it in mind. Did you try if it works with 16 colors? (1 transparency color and 15 areas-> 16 colors).

It fails with 16 and fewer colors. There's a reported bug that the Gimp BMP file export plugin doesn't work properly with 16 colors and less.

https://gitlab.gnome.org/GNOME/gimp/-/issues/4155

Quote from: TheManInBoots on Fri 10/04/2020 16:59:21
Quote from: morganw on Fri 10/04/2020 15:03:17
I would imagine this is a bug in WINE or a related component and not directly an AGS issue.
I have to mention that it's not obvious that the mask pell uploaded is the one he directly exported from AGS.
To me it seems the image he uploaded is the one he edited and exported with Gimp.
So you should probably make sure you know what file he uploaded, just to avoid drawing wrong conclusions.
I just reexported the file to confirm it's the same file, and that newly exported file does not re-import into AGS. But my file doesn't matter anyway unless you're debugging for running the editor in Wine. Do you all have this problem running this version of the editor in Windows? MorganW could not replicate the problem but also didn't mention a version number.

Just to be clear: After making sure you have the latest version of AGS available to download (version 3.5.0.24), try exporting your walkable area map to a BMP file, then try importing that exact same file. That fails for me (running in Wine on Linux), and it looks like AGS is not exporting it in 8-bit mode.

Edit: Of course, this is probably not an Earth-shattering bug. I doubt very many people are exporting those maps. I discovered it while trying to figure out how to import a map, which is solved with help from TheManInBoots.

morganw

I was testing with the same AGS version. Which version of WINE is it?

pell

Quote from: morganw on Fri 10/04/2020 19:08:42
I was testing with the same AGS version. Which version of WINE is it?

It's Wine 4.0 running in the 32-bit i386 (Intel/AMD) version of Debian 10. I'm running it in a qemu virtual machine, but I doubt that would be a factor in the problem.

Wine is at its default configuration of Windows 7 compatibility mode. I'm running it through PlayOnLinux (a Wine front end app), which I used to install Visual C++ for Visual Studio 2015 and Microsoft .Net Framework 4.5 as recommended on the AGS download page.

morganw

Quote from: pell on Sat 11/04/2020 02:06:26
It's Wine 4.0 running in the 32-bit i386 (Intel/AMD) version of Debian 10. I'm running it in a qemu virtual machine, but I doubt that would be a factor in the problem.

Wine is at its default configuration of Windows 7 compatibility mode. I'm running it through PlayOnLinux (a Wine front end app), which I used to install Visual C++ for Visual Studio 2015 and Microsoft .Net Framework 4.5 as recommended on the AGS download page.
As it happens, this is the same as I'm currently using (minus qemu) so I can give it a try. Did you install the Visual C++ and .NET runtime using PlayOnLinux's 'install other app' button, installing each separately?

morganw

I did install it (not through PlayOnLinux) but I can see the same problem, the deduplicated warnings are:

Code: ags

0009:fixme:shell:ShellItem_QueryInterface not implemented for {00000144-0000-0000-c000-000000000046} (unknown)
0009:warn:ntdll:NtQueryFullAttributesFile L"\\??\\C:\\users\\mwillcock\\My Documents\\wine_export4.bmp" not found (c0000034)
0009:warn:palette:GDISelectPalette invalid selected palette (nil)
0031:fixme:ole:Context_CC_ContextCallback (0x144ce8/0x144cec)->(0xa47011, 0x35afa44, {d7174f82-36b8-4aa8-800a-e963ab2dfab9}, 2, (nil))
0009:warn:wincodecs:BmpFrameEncode_Initialize ignoring encoder options.
0009:warn:palette:GDISelectPalette invalid selected palette (nil)
0009:fixme:gdiplus:GdipGetNearestColor (0x1bae90, 0x33ebac): Passing color unmodified
0009:warn:palette:GDISelectPalette invalid selected palette (nil)


The "invalid selected palette" message is being reported all the time, sometimes just by moving the mouse, so I imagine the problem is likely:

Code: ags
0009:warn:wincodecs:BmpFrameEncode_Initialize ignoring encoder options.


From a very quick look (maybe in the wrong place), it doesn't look like there is any support for 8 bit color:
https://github.com/wine-mirror/wine/blob/ba9f3dc198dfc81bb40159077b73b797006bb73c/dlls/windowscodecs/bmpencode.c

pell

Quote from: morganw on Sat 11/04/2020 15:26:54
I did install it (not through PlayOnLinux) but I can see the same problem, the deduplicated warnings are:

Code: ags

0009:fixme:shell:ShellItem_QueryInterface not implemented for {00000144-0000-0000-c000-000000000046} (unknown)
0009:warn:ntdll:NtQueryFullAttributesFile L"\\??\\C:\\users\\mwillcock\\My Documents\\wine_export4.bmp" not found (c0000034)
0009:warn:palette:GDISelectPalette invalid selected palette (nil)
0031:fixme:ole:Context_CC_ContextCallback (0x144ce8/0x144cec)->(0xa47011, 0x35afa44, {d7174f82-36b8-4aa8-800a-e963ab2dfab9}, 2, (nil))
0009:warn:wincodecs:BmpFrameEncode_Initialize ignoring encoder options.
0009:warn:palette:GDISelectPalette invalid selected palette (nil)
0009:fixme:gdiplus:GdipGetNearestColor (0x1bae90, 0x33ebac): Passing color unmodified
0009:warn:palette:GDISelectPalette invalid selected palette (nil)


The "invalid selected palette" message is being reported all the time, sometimes just by moving the mouse, so I imagine the problem is likely:

Code: ags
0009:warn:wincodecs:BmpFrameEncode_Initialize ignoring encoder options.


From a very quick look (maybe in the wrong place), it doesn't look like there is any support for 8 bit color:
https://github.com/wine-mirror/wine/blob/ba9f3dc198dfc81bb40159077b73b797006bb73c/dlls/windowscodecs/bmpencode.c

The editor can load 8-bit graphics (one's that are encoded correctly), so maybe there's a bug in the encoding code. There's not enough use of 8-bit graphics these days to notice all the bugs in software.

SMF spam blocked by CleanTalk