OpenXcom Forum

Modding => Help => Topic started by: The Reaver of Darkness on December 12, 2017, 07:47:23 am

Title: [SOLUTIONS IN THREAD] Why is the background green?
Post by: The Reaver of Darkness on December 12, 2017, 07:47:23 am
Sometimes I get a green background on images and sometimes it looks like a grey checkerboard pattern. Why is it different in different images with the same palette, and how do I change it from one to the other?

I've attached example images.
Title: Re: Why is the background green?
Post by: Warboy1982 on December 12, 2017, 07:59:22 am
proper transparency support.
use .PNG and don't worry about it - it'll show up correctly in-game, colour 0 is treated as transparent no matter what actual colour it is.
.GIF has compatibility issues with mac.
Title: Re: Why is the background green?
Post by: The Reaver of Darkness on December 12, 2017, 09:01:43 am
But I have .pngs that don't have a green background. How do I make them all like that?

I realize they show up properly in-game, but that's not good enough. I need them to show up properly in my image editor so I can see what I'm doing, and I need them to show up properly on the forum so that people can see what I made.
Title: Re: Why is the background green?
Post by: 7Saturn on December 12, 2017, 09:27:33 am
Just change the color no. 0 to whatever you like. (You can do that, for example with Gimp.) If you prefer green to be this color, that's OK. Just make sure, not to pick any color already used somewhere else as this might get confusing again. =)
Title: Re: Why is the background green?
Post by: The Reaver of Darkness on December 12, 2017, 05:12:12 pm
But how do I make color 0 transparent?
Title: Re: Why is the background green?
Post by: 7Saturn on December 12, 2017, 05:15:47 pm
IIRC, that's an option you can set during export with Gimp.
Title: Re: Why is the background green?
Post by: Meridian on December 21, 2017, 12:42:04 pm
But how do I make color 0 transparent?

Using your favourite image editor?
Basically anything except MS Paint should work... I used IrfanView and attached example.
Title: Re: Why is the background green?
Post by: The Reaver of Darkness on December 21, 2017, 10:56:14 pm
mtPaint also doesn't work. Gimp doesn't work. I can't afford Aseprite. I can't afford Photoshop. I had never heard of IrfanView before you mentioned it here. I guess I need to get a better image editor.
Title: Re: Why is the background green?
Post by: Warboy1982 on December 21, 2017, 11:11:15 pm
i'm pretty sure you can get older versions of photoshop free from adobe
Title: Re: Why is the background green?
Post by: tkzv on December 22, 2017, 03:19:14 am
Gimp doesn't work.

Here's what is broken in GIMP: https://bugzilla.gnome.org/show_bug.cgi?id=791531#c3 The bug was first reported in 2010.

If you can find a program that would change a palette (colour map) in saved PNG and if you don't use colour 1 (seen as 0 in GIMP), GIMP would be usable. (Photoshop can do it, but I see it's not an option.) If you can program, you can write a converter using something like libpng.
Title: Re: Why is the background green?
Post by: The Reaver of Darkness on December 22, 2017, 07:05:36 am
It's doing more than that. When I load a paletted image, it doesn't show the palette. But even if I do nothing that would upset that palette, once I save the file and load it in mtPaint where I can see the palette, it will have been rearranged into the default 256-color palette. That's the same thing MS Paint does.
Title: Re: Why is the background green?
Post by: tkzv on December 22, 2017, 08:11:11 pm
It's doing more than that. When I load a paletted image, it doesn't show the palette. But even if I do nothing that would upset that palette, once I save the file and load it in mtPaint where I can see the palette, it will have been rearranged into the default 256-color palette. That's the same thing MS Paint does.
GIMP? I've never encountered such problem. There may be some default import setting, which causes it. Does the import dialog appear when you open an indexed PNG?
Title: Re: Why is the background green?
Post by: The Reaver of Darkness on December 22, 2017, 10:08:19 pm
No. No dialogue appears when I load an image. A dialogue appears when I try to export one, but it offers only options unrelated to what I need.

I tried loading and exporting a .gif and a .png, and I got different results. The .png had its palette intact, while the .gif had all colors past the last used color turned white.
Title: Re: Why is the background green?
Post by: tkzv on December 23, 2017, 12:55:58 am
Ah, I was speaking of PNG.

The import settings will appear if Edit -> Preferences -> Image Import -> "Color profile policy" is set to "Ask what to do". And if the PNG has colour profile.
Title: Re: Why is the background green?
Post by: The Reaver of Darkness on December 23, 2017, 05:49:00 am
On mine it is set to "Ask what to do" but it doesn't ask. In any case, it looks like it can work if I stick to .pngs but I don't like it. I don't trust it to always work, and I don't really like Gimp's tools for pixel work anyway. I'm going to seek out other image editors.
Title: Re: Why is the background green?
Post by: tkzv on December 30, 2017, 04:35:34 am
I'm going to seek out other image editors.
Any luck so far? Care to compare notes about Linux editors?

Kolourpaint — Messes the palette beyond recognition. Replaces transparent background with non-transparent after undoing resizing of selection.

Krita — Can't work with 8-bit indexed colour.

Mtpaint — Refused to compile in 64-bit system (but I'll give a few more tries).

Pinta — Saves PNGs as truecolour. Palette saving "optimizes" palettes.
Title: Re: Why is the background green?
Post by: Yankes on December 30, 2017, 02:30:48 pm
https://openxcom.org/forum/index.php/topic,2676.0.html
Title: Re: Why is the background green?
Post by: tkzv on December 30, 2017, 05:33:12 pm
https://openxcom.org/forum/index.php/topic,2676.0.html
It lists mtPaint as "good", but it has troubles on new systems. Linux distributions are dropping it.

P.S. And HTTPS links to Evilpixie and GrafX2 don't work for me, only HTTP.
Title: Re: Why is the background green?
Post by: Yankes on December 30, 2017, 05:58:40 pm
It lists mtPaint as "good", but it has troubles on new systems. Linux distributions are dropping it.
But this do not change fact it "good" for editing palettes.
Title: Re: Why is the background green?
Post by: tkzv on December 30, 2017, 11:17:35 pm
But this do not change fact it "good" for editing palettes.
No good for me, until it starts to work :(

EvilPixie needs a deprecated version of GIFlib. I'll see what I can do about that.

GraFX2 works. But it has a lot of quirks, most of which were common 20 years ago, but not now. It hangs with 100% processor load if it tries to display preview for GIMP XCF, and SIGTERM doesn't help, only SIGKILL. Some keyboard shortcuts conflict with xkb group toggle. It follows symlinks and saves changes to the original file, which was unexpected. File browser combines case-sensitive sorting with case-insensitive search, which ends up missing files that start with lowercase. Also the file browser treats Unicode as ISO-8859-1. Changes are only applied to the visible part of the image. Worst of all: it cannot fix palettes damaged by GIMP, or at least I didn't find the way.
Title: Re: Why is the background green?
Post by: Yankes on December 31, 2017, 01:07:14 am
If you want fix only palette then falko tool could be useful: https://openxcom.org/forum/index.php/topic,2980.0.html
Title: Re: Why is the background green?
Post by: The Reaver of Darkness on January 02, 2018, 03:27:13 am
Falko's tool "fixes" the palette into a green alpha color.
Title: Re: Why is the background green?
Post by: Yankes on January 02, 2018, 11:51:32 pm
In game? Remember color of first color index is irrelevant (in 99.9% cases) only its usage. If this green should be transparent and have index of 0 then it will be transparent in battlescape.
Title: Re: Why is the background green?
Post by: The Reaver of Darkness on January 03, 2018, 12:48:53 am
No, in the editor. This is very difficult to work with. The green is very bright and I can't see what I'm doing without coloring the background black first. Then I have to remember to change it back to green/transparent.
Title: Re: Why is the background green?
Post by: Yankes on January 03, 2018, 01:06:21 am
Do change pixels or palette? You probably need change palette color only. For battlescape code that blit units it will made no difference.
Title: Re: Why is the background green?
Post by: Meridian on January 03, 2018, 10:07:41 am
There is no in-game issue Yankes... he just doesn't know how to change a non-transparent color into a transparent color in the PNG/GIF image (for the ease of editing).

The task is absolutely trivial (takes about 2 seconds), just let him figure it out on his own...
Title: Re: Why is the background green?
Post by: The Reaver of Darkness on January 03, 2018, 03:16:48 pm
There is no in-game issue Yankes... he just doesn't know how to change a non-transparent color into a transparent color in the PNG/GIF image (for the ease of editing).
I thought I was clear enough, but thanks for clearing that up.

The task is absolutely trivial (takes about 2 seconds), just let him figure it out on his own...
It's not that trivial, apparently. It should be trivial, but whoever designed most of these image editors doesn't seem to know what a palette is.
Title: Re: Why is the background green?
Post by: ohartenstein23 on January 03, 2018, 03:31:07 pm
I was able to get it working in GIMP.  Opened up your bigobs_AlloyLaserTurret.png image in GIMP, changed image mode from indexed to RGB and back to indexed, selecting the proper colormap (otherwise GIMP removes color index 0, shifting all images down one color index), added alpha channel to the layer containing the image, then just selected the neon green background and deleted it.  If you already have the proper palette applied, just add alpha channel to the layer and delete the background color.

Edit: Another option for pixel editing tools is MCDEdit - IvanDogovich has a version that allows for working with 32x48 instead of 32x40 images, useful for bigobs and floorobs.  It's made with X-Com in mind, so the proper palettes are baked-in.
Title: Re: Why is the background green?
Post by: Hobbes on January 03, 2018, 04:58:20 pm
I use GIMP to edit the image, then Grafx2 to apply the proper palette from an existing image. Works like a charm
Title: Re: Why is the background green?
Post by: tkzv on January 05, 2018, 12:48:37 pm
I use GIMP to edit the image, then Grafx2 to apply the proper palette from an existing image. Works like a charm
And how to do that if GIMP shifted the colours? Here's what I get:
Title: Re: Why is the background green?
Post by: The Reaver of Darkness on January 05, 2018, 01:45:50 pm
I found a solution that works for me: I can load the correct palette in mtpaint. Turns out I had been avoiding this option due to past failure in using it. The reason it failed before was because I needed the colors in the image to follow the palette move. If I'm just changing the background to something else, then it works fine. I can find palettes I like from other images, several images floating around have a transparent color 0 already.

I found a second solution that also works in mtPaint: in the palette editor I can change the color of the color 0. It doesn't matter what I change it to, in-game it is transparent. I can't change it to transparent in mtPaint, but I can at least change it to black.



In exploring palettes, I discovered something odd which had been previously giving me problems: the last 16 colors on the tactical palette have two different settings. One of the settings is a full gradient of a blue-grey color which has slightly inconsistent hue and saturation. The other setting involves just 5 of these blue-grey, 5 blue, 2 gray, and 4 spring green. In-game, the palette selection is inconsistent, leading to color changes of anything using these last 16 colors.

In the attached zip are two palettes. Palette 1 has the multi-color selection. Palette 2 has the single color at the end. I was originally working with the second palette, and I made a smoke rocket and smoke bomb using that color. In-game it looked fine some times, and sometimes did not look fine. I could not figure out what caused it to change, but now I know why it didn't look fine sometimes.