This toturial was written for me by Imran Khan (imranahmedkhan82@hotmail.com,
iak1982@yahoo.com). |
||||
Applying Transparency: When you run the previous version of the program, all things are fine except the Grey color around the character. This Grey Color is the image background color.if the picture got pink color as background it will show the pink color. We want to elimate this color.So that it will look more better. First Declare an instance of ColorKey class.
All the things are same except these ck.ColorSpaceHighValue = RGB(153, 153, 153) We specify the Range of the color to make transparent, Here we want to make Grey to be transparent so we give the same values in both arguments. (153, 153, 153) is the RGB combination of Grey.One can make more then 1 color Transparent. Then we delcare a character surface object ( we done this before ) The last line sets the ColorKey that we created eariler. The first argument specifies that we will use the source which is our surface for transparency and then the second argument is the ColorKey structure we made eariler. Now replace a single line in ShowSurface( ) method Older Version:
New Version :
We must specify that we will use a color key in the DrawFastFlags, so we change the flags to SourceColorKey which will cause the color we set in the ColorKey to be drawn transparent. Now when you run the Program, You will see no White color Around character. |
metadata block |
|
see also: | |
Correspondence about this page |
This site may have errors. Don't use for critical systems.
Copyright (c) 1998-2023 Martin John Baker - All rights reserved - privacy policy.