Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: WHAM on Tue 05/08/2008 21:09:34

Title: Black colour and sprite transparency
Post by: WHAM on Tue 05/08/2008 21:09:34
Kill me, 'cause I know someone has asked this before, but I cant find the goddamned thread! (I'm pretty sure I asked this myself way back when, but its not in my post history... Maybe I'm getting paranoid...)

When I import a sprite to the sprite manager (the sprite has a pink background for the transparency, and some black areas within.) using the "Top left pixel" as transparent colour, the black areas are turned pink. The transparency works fine, but AGS seems to alter the pure black colour into something entirely else. Why? How do I get around this?


Image I use as the background:
(http://www.whamgames.com/images/Forumsht/trobled_background.gif)

What it looks like when I use it:
(http://www.whamgames.com/images/Forumsht/troublemaker.png)
Title: Re: Black colour and sprite transparency
Post by: Khris on Tue 05/08/2008 21:31:54
I imported the GUI with top-left pixel transparency into a 16bit default game, and drew a yellow rectangle on the backgrouind, here's a screenshot (v3.02):

(http://img514.imageshack.us/img514/585/guiwhamlm9.png)

(It looks just fine in the editor, too, btw.)
Title: Re: Black colour and sprite transparency
Post by: WHAM on Tue 05/08/2008 21:44:08
Okay, but I'm using an empty game template. Is there a difference that could cause what I'm describing?
Title: Re: Black colour and sprite transparency
Post by: monkey0506 on Tue 05/08/2008 22:18:46
No, you just have to change the transparency selection when you import the sprite from "Palette Index 0" to "Top-left pixel".

Nevermind I'm just an idiot. That's what I get for not reading every word... :)
Title: Re: Black colour and sprite transparency
Post by: Khris on Tue 05/08/2008 22:39:16
As he stated in the first post, WHAM did use "top left pixel".

I copied the sprite straight from Firefox to AGS, maybe your graphics program screws up the transparency if you use copy & paste. Try saving the sprite as GIF, then import it.
Title: Re: Black colour and sprite transparency
Post by: Makeout Patrol on Tue 05/08/2008 23:47:50
You know, I've been having a similar problem, but I figured it was something to do with what I was doing. I've found that I can get around it by importing .BMP files instead of whatever else I might try.
Title: Re: Black colour and sprite transparency
Post by: WHAM on Wed 06/08/2008 07:10:51
Quote from: KhrisMUC on Tue 05/08/2008 22:39:16
As he stated in the first post, WHAM did use "top left pixel".

I copied the sprite straight from Firefox to AGS, maybe your graphics program screws up the transparency if you use copy & paste. Try saving the sprite as GIF, then import it.

All images are saved as .GIF and then imported to AGS...

The problem only manifests whan I use the empty game template, and not in the default game. What graphics options do those have that are different? Anything?
Title: Re: Black colour and sprite transparency
Post by: cat on Wed 06/08/2008 08:59:30
What version do you use?

I had some problems that black was changing into blue with my backgrounds.
http://www.adventuregamestudio.co.uk/yabb/index.php?topic=33582.msg435879#msg435879 (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=33582.msg435879#msg435879)

Maybe this is related? According to CJ this issue was fixed with some new AGS version.
Title: Re: Black colour and sprite transparency
Post by: Khris on Wed 06/08/2008 09:05:22
The empty game template uses 8-bit by default, which would explain the screwed up colors.

I had a similar problem: even after changing to 16-bit, DirectDraw5 mode would screw up the colors because I hadn't imported a background and the room was still in 8-bit mode. Importing an all black background saved as 16-bit png fixed it.
Title: Re: Black colour and sprite transparency
Post by: WHAM on Wed 06/08/2008 11:47:20
Quote from: KhrisMUC on Wed 06/08/2008 09:05:22
The empty game template uses 8-bit by default, which would explain the screwed up colors.

I had a similar problem: even after changing to 16-bit, DirectDraw5 mode would screw up the colors because I hadn't imported a background and the room was still in 8-bit mode. Importing an all black background saved as 16-bit png fixed it.

This would sound logical! I'll try this when I get home from work, thanks!

EDIT: When using the empty game template, I started the editor, started making a new game, set (from general settings) the resolution to 640x400 and color depth to 16bit. Why, when I create a new room, does the game still say the ROOM is in 8bit 320x200? And if I try to run the game in this way, it shows me only half of my 640x400 room, which I created. It's as if AGS is not allowing me to change my game resolution at all?

Has someone tested the empty game template lately? Should it really work?
Title: Re: Black colour and sprite transparency
Post by: SSH on Wed 06/08/2008 16:02:43
Have you imported a new BG for it yet?
Title: Re: Black colour and sprite transparency
Post by: WHAM on Wed 06/08/2008 16:41:35
Quote from: SSH on Wed 06/08/2008 16:02:43
Have you imported a new BG for it yet?

Yup, and it seems that importing a b ackground brings the room and game's colour depht into order, but the resolution problem still remains.
Title: Re: Black colour and sprite transparency
Post by: WHAM on Wed 06/08/2008 17:03:32
(http://www.whamgames.com/images/Forumsht/wtfcolours.png)

Here's what my game looks like after the following steps (please tell me if I'm missing something)

1. Start ags -> new game -> Empty template
2. General Settings -> Resolution 640x400 / Colour 32bit
3. Import a sprite to the sprite editor -> Whole image / top left pixel transparent colour / not tiled import
(In the sprite editor, the characters black areas are coloured as the same colour that was used in the top left pixel. The sprite's resolution information, colour depth and size are correct in the lower-right corner "Appearance" tab)
4. Set the sprite as the only sprite in View 1 used by character 1.
5. Create a new room -> Give the room a background (I'm using a 600x400 image as a test image, this is shown as the background of the image above).
6. Compile -> Test

The result can be seen above. The room seems too big, because the game uses it as an extra large 320x200 background and moves the "camera" along with the character.
Title: Re: Black colour and sprite transparency
Post by: Khris on Wed 06/08/2008 17:15:47
Using 3.1 beta 3, I followed your steps and the room shows up fine in-game. The character even looks a bit too tall compared to the doors.
Title: Re: Black colour and sprite transparency
Post by: WHAM on Wed 06/08/2008 17:21:27
I'm using 3.0.2 on Vista.

EDIT: Okay, the transparency problem has been solved. For some reason .gif files only caused this problem, and changing to .bpm and .png seems to make the transparency look normal. (Apparently .gif handles the ultimate white and black colours somehow differently or something...)

But still, the room size problem remains strong, as all the rooms remain in 320x200, even though I have changed the game resolution to 640x400.

SECOND EDIT: And now the room size problem fixed itself... sort of...

It seems that if the image you use as a background for a room is smaller than the game resolution, the game creates the room on a smaller resolution altogether. The image I was using was a slightly outdated one, and a bit too narrow, causing the mix-up.

Ahhh... I feel so relieved now that I can finally get some real work done here. Thanks to everyone for trying to help!
Title: Re: Black colour and sprite transparency
Post by: tilapisha on Wed 20/04/2022 02:02:54
(https://github.com/lishap/gobyworld/blob/main/forum.png?raw=true)

I'm having the same issue. The pants of my character are black, and it's using this as the transparent color. I didn't have this problem initially, but now as I load sprites (which are .png w/ transparency layer, I also tried bitmap but not working) it is reading this as transparent. I'm using top-left which should be transparent!

This is the image I want!
(https://github.com/lishap/gobyworld/blob/main/Sprites/Goby/GobyBarf.png?raw=true)
Title: Re: Black colour and sprite transparency
Post by: Crimson Wizard on Wed 20/04/2022 02:07:23
tilapisha, please tell:
* what is your game's color depth
* what are the sprite import settings that you use?

I think, if you have a 32-bit game and you load pngs with transparency layer, you should be having "use alpha channel" and "leave as is" as options.
Black color is a default transparent color in 8-bit palette games, I think, but idk if that is related.
Title: Re: Black colour and sprite transparency
Post by: tilapisha on Wed 20/04/2022 02:21:17
I'm using 16-bit hi color.

I'm importing Alpha channel, Transparent-colour is top-left (or wherever is transparent) and thats it. I tried unlocking the re=map, and it worked for this sprite but not all.
Title: Re: Black colour and sprite transparency
Post by: Cassiebsg on Wed 20/04/2022 16:52:14
Like CW said, set the import options to"use alpha channel" and "leave as is" and try again.
Title: Re: Black colour and sprite transparency
Post by: Crimson Wizard on Wed 20/04/2022 17:04:04
Quote from: Cassiebsg on Wed 20/04/2022 16:52:14
Like CW said, set the import options to"use alpha channel" and "leave as is" and try again.

If the game is 16-bit, then importing with alpha channel does not make a lot of sense. For 16-bit it's best to use mask (transparent) color on source images.

I'm also not certain if "remap colors" option would work on non-8-bit images, i thought it should not make any difference.
Title: Re: Black colour and sprite transparency
Post by: Cassiebsg on Wed 20/04/2022 17:06:30
I was just thinking about that, but don't know how the engine works when importing the images. I just assumed that if her PNGs have transparency, then AGS would be able to use that and convert that into transparent color.

The real question is, why not use 32-bit instead?  ;)
Title: Re: Black colour and sprite transparency
Post by: tilapisha on Wed 20/04/2022 21:40:51
(https://github.com/lishap/gobyworld/blob/main/Screenshots/Screenshot%202022-04-20%20163808.png?raw=true)

This is what I'm importing, which is a png image with a transparent background.

This is what happens when I import:

[imgzoom]https://github.com/lishap/gobyworld/blob/main/Screenshots/Screenshot%202022-04-20%20163556.png?raw=true[/imgzoom]
Title: Re: Black colour and sprite transparency
Post by: tilapisha on Wed 20/04/2022 21:42:07
Quote from: Cassiebsg on Wed 20/04/2022 17:06:30
The real question is, why not use 32-bit instead?  ;)

I guess I could. I'm hoping to port this to the web, and so the smaller the file sizes the better. Also, would that fix my problem? Originally I was having no issues with importing and the black colors.
Title: Re: Black colour and sprite transparency
Post by: Crimson Wizard on Thu 21/04/2022 00:24:00
In the above example you are importing a 32-bit sprite into 16-bit game, so it has to be converted to 16-bit, but you also choose "Leave as is", so the question is what would become to the transparency layer in this situation. I'd need to make a test myself to find out.
EDIT: I think it simply strips the alpha channel, so these transparent parts become solid color. For example, if you used color ARGB (0,0,0,0) in the paint program, then this becomes simply black.

For 16-bit games you should not be using transparency layers, but rather have a simple background of some color, which you would set as a transparent during import using "Top left"/"bottom left"/etc pixels.