Giving a picture transparent properties above a background
Author |
Message |
LegendsEnd
|
Posted: Sat May 20, 2006 11:09 am Post subject: Giving a picture transparent properties above a background |
|
|
Here's my problem:
I Pic.Draw a background. This background has a menu.
I Pic.Draw a custom cursor picture for the menu (slides up/down)
The curor picture is in .jpg format however, so it does not support transparency.
I can make everything around the picture black/white and I have tried using Pic.SetTransparentColor black/white but neither works. Am I doing something wrong?
|
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
LegendsEnd
|
Posted: Sat May 20, 2006 11:11 am Post subject: (No subject) |
|
|
Sorry about this double post but it seems I can't edit. The problem is that I don't want a moving rectangle. I've also tried the sprite commands but it doesn't seem to help.
|
|
|
|
|
 |
HellblazerX

|
Posted: Sat May 20, 2006 11:20 am Post subject: (No subject) |
|
|
Why not just change the format of your image to bmp or gif. I'm pretty sure those suppost transparency. Also, make sure when you use Pic.Draw, that you set the mode to picMerge and not picCopy.
|
|
|
|
|
 |
LegendsEnd
|
Posted: Sat May 20, 2006 11:30 am Post subject: (No subject) |
|
|
I'm using turing 4.03 (the school version) so it does not support GIF images. As for bmp, it does not support transparency either.
|
|
|
|
|
 |
TheOneTrueGod

|
Posted: Sat May 20, 2006 12:00 pm Post subject: (No subject) |
|
|
If you use a .bmp file, and you use the default background colour (white), then it is transparent. You just have to use the
"picMerge" option instead of "picCopy"
|
|
|
|
|
 |
LegendsEnd
|
Posted: Sat May 20, 2006 1:57 pm Post subject: (No subject) |
|
|
I have tried bmp with both a white and black background on the image itself. Perhaps you don't understand what i'm trying to do. I have a background image, lets say it has all the colors of the rainbow. I have a 2nd image I want applied, but the image has whitespace around it. I know PNG files support transparency but turing does not support PNG.
|
|
|
|
|
 |
TheOneTrueGod

|
Posted: Sat May 20, 2006 2:16 pm Post subject: (No subject) |
|
|
yes, but did you use picMerge instead of picCopy? If you just use picCopy, then it won't include any background colour. picMerge will take into account a background colour, and will not draw that colour. (Theres probably a more technical definition, check the help file)
|
|
|
|
|
 |
Cervantes

|
Posted: Sat May 20, 2006 2:18 pm Post subject: (No subject) |
|
|
TheOneTrueGod is right.
The second image should be drawn using picMerge.
code: |
Pic.Draw (second_image, x_pos, y_pos, picMerge)
|
It should automatically use white as the "transparent" colour. If not, try using Pic.SetTransparentColour.
LegendsEnd, why don't you post your code? (Not all of it; just the part where you're drawing).
|
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
LegendsEnd
|
Posted: Sat May 20, 2006 5:11 pm Post subject: (No subject) |
|
|
Well here's the code + images. I tried it multiple times and finally decided to test the code stand alone from my program (which I should have done first). It appears it's the RGB code that's messing it up.
code: |
var c1 := 0
RGB.SetColor (c1, 0, 0, 0)
var pic1 := Pic.FileNew ("d3tn02.jpg")
var pic2 := Pic.FileNew ("Untitled-1.bmp")
Pic.Draw (pic1, 0, 0, 0)
Pic.Draw (pic2, 200, 200, picMerge)
|
Description: |
|
Filesize: |
4.18 KB |
Viewed: |
1861 Time(s) |

|
Description: |
|
Filesize: |
766.86 KB |
Viewed: |
1861 Time(s) |

|
|
|
|
|
|
 |
jamonathin

|
Posted: Sat May 20, 2006 5:41 pm Post subject: (No subject) |
|
|
Well first of all, your gun doesn't even have a complete white background, there's grey mushed all in there.
Secondly RGB.SetColor(c1, 0, 0, 0) is black. You're going to want 1, 1, 1.
Since i'm SUCH a nice guy, here's your pic . . cleaned. Just use paint .
code: |
var pic2 := Pic.FileNew ("Untitled-1.bmp")
colorback(13)
cls
Pic.Draw (pic2, 200, 200, picMerge) |
Description: |
|
Filesize: |
4.18 KB |
Viewed: |
1863 Time(s) |

|
|
|
|
|
|
 |
LegendsEnd
|
Posted: Sat May 20, 2006 7:15 pm Post subject: (No subject) |
|
|
It's actually a sword with a dragon wrapped around it lol. I don't really understand the problem though. Why does setting c1 to a certain color affect my pictures at all? and isn't 255,255,255 white?
|
|
|
|
|
 |
TheOneTrueGod

|
Posted: Sat May 20, 2006 7:20 pm Post subject: (No subject) |
|
|
Turings RGB works in real numbers, so 1 = 1*255 = 255. 0.5 =0.5*255 = 128 0.25 = 0.25*255 = 64. etc. In order to work the colours properly you have to use numbers between 0 and 1. And I don't think it does, I think the whole problem was that you tried to take a .jpeg, and turn it into a .gif. Unfortunately, this doesn't work very well, because .jpegs auto-blend pictures, causing them to look slightly nicer (in some cases...), but making it so there is no predominant background colour.
|
|
|
|
|
 |
jamonathin

|
Posted: Sun May 21, 2006 1:07 pm Post subject: (No subject) |
|
|
The RGB he had in there did effect the transparency of the white background, because it was set to black, but yes, the auto-blend did mess up the image.
|
|
|
|
|
 |
|
|