# Importing an image with alpha from Paint Shop Pro

**URL:** <https://discourse.libsdl.org/t/importing-an-image-with-alpha-from-paint-shop-pro/8709>\
**Category:** SDL Development\
**Created:** [May 9, 2003, 6:23am UTC](https://discourse.libsdl.org/t/importing-an-image-with-alpha-from-paint-shop-pro/8709 "2003-05-09T06:23:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![CRUSADER\_KY](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/c/4bbf92/32.png) [@CRUSADER\_KY](https://discourse.libsdl.org/u/CRUSADER_KY)\
**Post date:** [May 9, 2003, 6:23am UTC](https://discourse.libsdl.org/t/importing-an-image-with-alpha-from-paint-shop-pro/8709/1 "2003-05-09T06:23:01Z")

</div>

I’ve got an image created with paint shop pro that has some  
semi-transparent pixels in it and I want to use it with my SDL application.  
The first try I’ve made has been to set the background color to purple  
(0xFF00FF), merge all layers and save it to PNG; then load the image with  
SDL\_image and set the colorkey to 0xFF00FF. This works for the pixel with  
opacity 100% or 0%, but it doesnt’t with semi-transparent ones (which are  
blended with the background).

(1) Is there a file format both supported by psp7 and by some SDL library  
that can store a RGBA surface?  
(2) Is there some SDL library that can load a psp image into SDL surfaces?  
(the PSP file format specs are public, but they’'e 77 pages long…)  
(3) are there any other alternatives?

I’ve thought about saving the image with two different backgrounds, i.e.  
purple (0xFF00FF) and green (0x00FF00) and, by comparing the RGB pixels in  
the two surfaces, revert to the original RGBA image. However, this is quite  
a pain in the a\*\* - and it’s a bad, dirty work too.

[] Guido Imperiale  
[] CRV?ADER/KY  
[] CVI.SCIENTIA.IMPERIVM

crusaderky at [libero.it](http://libero.it)  
[http://crusaderky.da.ru](http://crusaderky.da.ru)

“Nam et ipsa scientia potestas est” (Knowledge is power)  
– Sir Francis Bacon (1561-1626)  
Meditationes Sacrae, de Haeresibus

“I worry about my child and the Internet all the time, even though she’s  
too young to have logged on yet. Here’s what I worry about. I worry that 10  
or 15 years from now, she will come to me and say ‘Daddy, where were you  
when they took freedom of the press away from the Internet?’”  
–Mike Godwin, Electronic Frontier Foundation

---

<div class="post-metadata">

**Author:** ![Reinhard\_Prix](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/r/f1d935/32.png) [@Reinhard\_Prix](https://discourse.libsdl.org/u/Reinhard_Prix)\
**Post date:** [May 9, 2003, 8:50am UTC](https://discourse.libsdl.org/t/importing-an-image-with-alpha-from-paint-shop-pro/8709/2 "2003-05-09T08:50:00Z")

</div>

Hi,

> semi-transparent pixels in it and I want to use it with my SDL application.  
> The first try I’ve made has been to set the background color to purple  
> (0xFF00FF), merge all layers and save it to PNG; then load the image with  
> SDL\_image and set the colorkey to 0xFF00FF. This works for the pixel with

I would think you simply have to: \*) save the pic as a PNG (which supports  
alpha-transparency) and \*) use alpha in SDL instead of colorkey.  
Colorkey gives you either 100% opaque or transparent, alpha gives you a  
smooth transparency range, and both PNG and SDL support it.

> (1) Is there a file format both supported by psp7 and by some SDL library  
> that can store a RGBA surface?

yes, PNG.

> (2) Is there some SDL library that can load a psp image into SDL surfaces?

use IMG\_Load() from the SDL-image library to load a PNG.

Cheers,  
Reinhard.

---

<div class="post-metadata">

**Author:** ![CRUSADER\_KY](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/c/4bbf92/32.png) [@CRUSADER\_KY](https://discourse.libsdl.org/u/CRUSADER_KY)\
**Post date:** [May 10, 2003, 3:23am UTC](https://discourse.libsdl.org/t/importing-an-image-with-alpha-from-paint-shop-pro/8709/3 "2003-05-10T03:23:01Z")

</div>

> > semi-transparent pixels in it and I want to use it with my SDL application.  
> > The first try I’ve made has been to set the background color to purple  
> > (0xFF00FF), merge all layers and save it to PNG; then load the image with  
> > SDL\_image and set the colorkey to 0xFF00FF. This works for the pixel with
> 
> I would think you simply have to: \*) save the pic as a PNG (which supports  
> alpha-transparency) and \*) use alpha in SDL instead of colorkey.  
> Colorkey gives you either 100% opaque or transparent, alpha gives you a  
> smooth transparency range, and both PNG and SDL support it.

PNG supports alpha, but apparently Paint Shop Pro 7.01 does not support  
PNG… ☹  
That is, I save a psp image with no background and some semi-transparent  
areas to PNG, choosing [Options]–\>[Run Optimizer].  
Then I select true color, Alpha Channel Transparency and Existing  
Image or Layer Transparency and finally save it.  
When I open the PNG, the picture has lost its alpha and has an opaque  
black background.
