Transparent image from PNG format

<db8nbs$mrv$1 at sea.gmane.org>
In-reply-to: <db3m24$jii$1 at sea.gmane.org>
<db8nbs$mrv$1 at sea.gmane.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-2
Content-Transfer-Encoding: 8bit
Content-Disposition: inline
X-Mailer: Interfejs WWW poczty Wirtualnej Polski
Organization: Poczta Wirtualnej Polski S.A. http://www.wp.pl/
X-User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.5) Gecko/20031016 K-Meleon/0.8.2
X-IP: 83.18.3.90
X-WP-AV: skaner antywirusowy poczty Wirtualnej Polski S. A.
X-WP-SPAM: NO AS1=NO AS2=YES(0.999924) AS3=NO AS4=NO

I have a big problem with SDL_Image library,
when i want to load a "png"
image into surface. In my game that surface
need to by transparen
(additionally with transparent that image from
e.g. Photoshop).You know

use gimp instead of photoshop when exporting to .png
i’ve found that most of .png’s exported by photoshop
were incorrect. tested on mozilla / acdsee / galeon / gtksee
i opened them in gimp and 'saved as’
oops … all .png’s are now correct.

please note that if you want transparent sufrace
than you have to use SDL_SetAplha()

but if you want a partially transparent images
as I correctly understand you
( part of image is not transparent but unwanted part is )
than make them in gimp ( preferred for .png’s )
and than load them using IMG_Load() ( also works for .tga’s )

or you can always make them on top of known background color
( black for example ) and use SDL_SetColorKey( that_color )
( this method is faster ON MY MACHINE, especially with RLE )

I’m from Poland and in my counrty SDL is
a tabu. If anyone can help me ,please respond.

wrong assumption
#1 ( open source ) free-civ -> SDL-client by rafal bursig
#2 ( commercial ) www.gamesystem.pl -> prohibition and others
#3 ( open source ) members.fortunecity.com/pamashoid -> lorion
just need some time to finish it :wink:

i’m pole too, and i see nothing wrong with it, do you? :wink:

polaczek nie kra, sdl’a zna :wink:

pamashoid at poczta.onet.pl----------------------------------------------------
Mamo to ja! - Nowy serwis internetowy o Twoim dziecku - Zobacz
jak piel?gnowa?, karmi? i wychowywa? bez pora?ek - Kliknij:
http://klik.wp.pl/?adr=www.mamotoja.wp.pl&sid=432

use gimp instead of photoshop when exporting to .png
i’ve found that most of .png’s exported by photoshop
were incorrect. tested on mozilla / acdsee / galeon / gtksee
i opened them in gimp and 'saved as’
oops … all .png’s are now correct.

oh no ,Photoshop have solid support for png too (check “save for web” ,also
tested)

please note that if you want transparent sufrace
than you have to use SDL_SetAplha()

PNG has own alpha channel ,and when i use SDL_DisplayFormat() or
SDL_DisplayFormatAlpha()
this what was trasparent is visible now.

or you can always make them on top of known background color
( black for example ) and use SDL_SetColorKey( that_color )
( this method is faster ON MY MACHINE, especially with RLE )

with BMP format this works, but around a sprite is black contour

#1 ( open source ) free-civ -> SDL-client by rafal bursig

i have Linux too

#2 ( commercial ) www.gamesystem.pl -> prohibition and others

SPAMMERS!!! (spyware)

i’m pole too, and i see nothing wrong with it, do you? :wink:

and also :wink:

polaczek nie kra, sdl’a zna :wink:
GO POLAND!

salut>

pamashoid at poczta.onet.pl


Mamo to ja! - Nowy serwis internetowy o Twoim dziecku - Zobacz
jak piel?gnowa?, karmi? i wychowywa? bez pora?ek - Kliknij:
http://klik.wp.pl/?adr=www.mamotoja.wp.pl&sid=432

I didnt followed this thread in detail, but i would suggest to use 32bit rle
encoded targa files. Though they are slightly bigger, depending what kind of
images / sprites you use, but loading tga - files is so much easier. You do
not need sdl_image, libpng and zlib. This saves you a lot of trouble when it
comes to porting your application to different platforms. Loading
rle-compressed tga files requires less than 10 kbyte c++ code. ( i attached
my tiny_targa.h tga-loader - you can load from file and memory, and save to
streambuffer or file)

Usage of tiny_targa:

void main()
{
int n=500;
Targa<Targa_pixel> tga(n,n);

for(int a=0;a<n;a++)
{
	for(int b=0;b<n;b++)
	{
		tga(a,b).r=int(0.2*a*cos(a/float(b)))%256;
		tga(a,b).g=int(0.1*a*b)%256;
		tga(a,b).b=int(0.1*(a*a-10*b))%256;
		tga(a,b).a=int(0.01*(a*b*b))%256;
	}
}
tga.save("test_gen.tga");


tga.load("32bit_compressed.tga");
tga.save("test_uncompressed_32bit_out.tga");

// test - save to memory buffer
stringstream s;
tga.save(s);

// and write that memorybuffer to file
fstream f;
f.open("test2.tga", std::ios::binary | std::ios::out);

if(f.is_open())
{
	string data=s.str();
	f.write(data.c_str(), data.length());
	f.close();
}

}> -----Original Message-----

From: sdl-bounces+post=andre-krause.net at libsdl.org
[mailto:sdl-bounces+post=andre-krause.net at libsdl.org] On
Behalf Of Tomek Cynacewicz
Sent: Samstag, 16. Juli 2005 13:32
To: sdl at libsdl.org
Subject: [SDL] Re: Transparent image from PNG format

use gimp instead of photoshop when exporting to .png i’ve
found that
most of .png’s exported by photoshop were incorrect. tested
on mozilla
/ acdsee / galeon / gtksee i opened them in gimp and 'saved as’
oops … all .png’s are now correct.

oh no ,Photoshop have solid support for png too (check “save
for web” ,also
tested)

please note that if you want transparent sufrace than you
have to use
SDL_SetAplha()

PNG has own alpha channel ,and when i use SDL_DisplayFormat() or
SDL_DisplayFormatAlpha()
this what was trasparent is visible now.

or you can always make them on top of known background
color ( black
for example ) and use SDL_SetColorKey( that_color ) ( this
method is
faster ON MY MACHINE, especially with RLE )

with BMP format this works, but around a sprite is black contour

#1 ( open source ) free-civ -> SDL-client by rafal bursig

i have Linux too

#2 ( commercial ) www.gamesystem.pl -> prohibition and others

SPAMMERS!!! (spyware)

i’m pole too, and i see nothing wrong with it, do you? :wink:

and also :wink:

polaczek nie kra, sdl’a zna :wink:
GO POLAND!

salut

pamashoid at poczta.onet.pl


Mamo to ja! - Nowy serwis internetowy o Twoim dziecku - Zobacz jak
piel?gnowa?, karmi? i wychowywa? bez pora?ek - Kliknij:
http://klik.wp.pl/?adr=www.mamotoja.wp.pl&sid=432


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed…
Name: tiny_targa.h
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20050716/d9ee72f9/attachment.asc