Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Transaparent logo. My brain is dead :-(

This thread is locked; no one can reply to it. rss feed Print
Transaparent logo. My brain is dead :-(
Bob Bobosky
Member #7,151
April 2006

Please help
I have background and logo ( all 32bit )
My code:
--------------------------------------------
BITMAP *bg,*logo;

set_color_depth(32);
set_palette(desktop_palette);
set_gfx_mode(GFX_AUTODETECT_WINDOWED, 800, 600, 0, 0);

logo=load_bitmap("logo.bmp",NULL);
bg=load_bitmap("bg.bmp",NULL);
while (1){
blit(bg, buffer, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
masked_blit(logo, buffer, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
blit(buffer,screen ,0, 0, 0, 0, SCREEN_W, SCREEN_H);
if (key[KEY_ESC]){break;}
}
--------------------------------------------

This is my result : http://www.hostfornet.net/vasilevs/problem.htm
I loking in this forum but not found solution ... :-(
Please help

***********
Привет русскoязычным кoдерам планеты ! :-)

umperio
Member #3,474
April 2003
avatar

The problem is the shadow is not proper bright pink. For it to be transparent it needs to be exactly 255,0,255. While the shadow you have is a combination of the bright pink with black.

Fladimir da Gorf
Member #1,565
October 2001
avatar

The solution: save your image as a 32-bit RGBA image and render it with set_alpha_blender/draw_trans_sprite.

OpenLayer has reached a random SVN version number ;) | Online manual | Installation video!| MSVC projects now possible with cmake | Now alvailable as a Dev-C++ Devpack! (Thanks to Kotori)

Neil Walker
Member #210
April 2000
avatar

btw, you don't need set_palette if you're working with 32 bit. If you have 8bit graphics they are dealt with by the colour conversion global.

You could always try the png library extension.

Neil.
MAME Cabinet Blog / AXL LIBRARY (a games framework) / AXL Documentation and Tutorial

wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie

Ceagon Xylas
Member #5,495
February 2005
avatar

Bob, use the code tags around your code. You can reference tags by the HTML Mockup Code link at the top of the reply text input.

Bob Bobosky
Member #7,151
April 2006

umperio, I know about this problem but i need shadows etc.

Fladimir da Gorf, I create my images in Photoshop CS 9 . My experience in C very poor ( as my english :-) . And i don't uses BMP files ( i'm PHP/Perl coder over 7 years ) and i don't know how create like this format file :-(
Please look at this 2 bmp files : http://www.hostfornet.net/vasilevs/imgs.zip
It is RGBA image ?
And this my code don't work with these images:-(

1#include <allegro.h>
2BITMAP *logo;
3int main(void)
4{
5 allegro_init();
6 install_timer();
7 install_keyboard();
8 set_color_depth(32);
9 set_gfx_mode(GFX_AUTODETECT_WINDOWED, 800, 600, 0, 0);
10 logo=load_bitmap("logo1.bmp",NULL);
11 set_alpha_blender();
12 draw_trans_sprite(screen, logo, 10, 10);
13 readkey();
14 destroy_bitmap(logo);
15}
16END_OF_MAIN();

Please , show me any working code , may be i understand it (set_alpha_blender,draw_trans_sprite)

Neil Walker, I try libpng but not working
Do you have any working code ?

Thank you all for reply

Fladimir da Gorf
Member #1,565
October 2001
avatar

In Photoshop, delete the pink layer (which is probably the surface layer). Then save your image as a .tga instead of .bmp.

OpenLayer has reached a random SVN version number ;) | Online manual | Installation video!| MSVC projects now possible with cmake | Now alvailable as a Dev-C++ Devpack! (Thanks to Kotori)

Bob Bobosky
Member #7,151
April 2006

This picture in this format ?
http://www.hostfornet.net/vasilevs/logo.tga

Fladimir da Gorf
Member #1,565
October 2001
avatar

Yeah, but you need to make the background translucent (thus, delete background layer).

OpenLayer has reached a random SVN version number ;) | Online manual | Installation video!| MSVC projects now possible with cmake | Now alvailable as a Dev-C++ Devpack! (Thanks to Kotori)

Bob Bobosky
Member #7,151
April 2006

I make picture but without background translucent :-(
Please, look at my steps: http://www.hostfornet.net/vasilevs/photoshop/photoshop.htm

What is wrong i do ?

Fladimir da Gorf
Member #1,565
October 2001
avatar

Ah yeah, Photoshop can't save RGBA .tga files. Well, .png files are better anyways and they work with Photoshop, but you'll need loadpng, libpng and libz -libraries to load them in your game.

OpenLayer has reached a random SVN version number ;) | Online manual | Installation video!| MSVC projects now possible with cmake | Now alvailable as a Dev-C++ Devpack! (Thanks to Kotori)

Inphernic
Member #1,111
March 2001

Quote:

Ah yeah, Photoshop can't save RGBA .tga files.

It can.

Bob Bobosky
Member #7,151
April 2006

GIMP Forever :-)

Amen ! :-))

Thank you !

LordHolNapul
Member #3,619
June 2003
avatar

To create a Trasluncent TGA with photoshop you must do as I say below:

- Create your 32RGB color Bitmap, ad be sure to have upon your sprite ;)

- Look (down right) for the LEVEL manager , that is a popup with all the levels you create for yor image.

- Select in this popup window the "RGB level manager". This manager should discrimiate your bitmap in the 3 color level, and you should see the RGB selection that return to all color RGB . ok, this is not so important...

- below click the icon to create a new RGB level. Automatically you will obtain a level called ALPHA. This is your level. select it, and draw Black or White if you want transparency or opacity upon your picture.

- Save this image as TGA 32 bit = 8 bit for Red/Green/Blue and 8 for alpha... 32!

- Use the Allegro command draw_trans_sprite() and you will obtain 32 transparency images.

- I used Photoshop 6.

My game has been done like this.
Ciao

Go to: