
-----------------------------------
illu45
Mon Mar 28, 2005 7:52 pm

Transparent Images
-----------------------------------
Hey guys,

I'm trying to make a chess board (as you can probably tell from my previous thread), unfortunately, it seems that I can't import pictures with transparent backgrounds into Turing. This causes a problem, since I need the pieces to have transparent backgrounds... Is there any way that I may be missing to do this? 

I know that using PicXor I can set the image to be transparent, but I don't want the whole image to be transparetn, just the background...

Thanks,
illu45

-----------------------------------
Naveg
Mon Mar 28, 2005 11:39 pm


-----------------------------------
well if the background of the picture is transparent, then picCopy should work, otherwise picMerge will omit anything thats the colour of the turing background

-----------------------------------
jamonathin
Tue Mar 29, 2005 7:49 am


-----------------------------------
There are a couple commands that are used to play with a pictures transparancy.  Just type tansparent in the F10 help file, and I'm sure you'll find something to your likings.

-----------------------------------
[Gandalf]
Tue Mar 29, 2005 5:25 pm


-----------------------------------
Ya, you can set a certain colour to be the transparent part of a picture.  That way, you can colour in the part you dont want showing that colour and you have it.  Look up the command for this in turing help /\.

-----------------------------------
illu45
Tue Mar 29, 2005 8:20 pm


-----------------------------------
The Set.TransparencyColor doens't seem to be working for me, as I'm still getting the same issues as before... Here is my code, and the zip file with pictures:


setscreen ("graphics:400, 400")
var fontNumbers := Font.New ("Courier New:10")

procedure DrawTheCell (x, y, w, h : int)

    var clr : int := 255

    if (x + y) mod 2 = 0 then
        clr := 0
    end if

    drawfillbox (x * w, (y + 1) * h, (x + 1) * w, (y) * h, clr)

end DrawTheCell

var w : int := 40
var h : int := 40



drawfillbox (0, 0, maxx, maxy, 50)



var letters : array 1 .. 8 of string
letters (1) := "a"
letters (2) := "b"
letters (3) := "c"
letters (4) := "d"
letters (5) := "e"
letters (6) := "f"
letters (7) := "g"
letters (8) := "h"


for i : 1 .. 8
    locatexy (i * w + w div 2, h div 2)
    colorback (50)
    put letters (i)
end for


for j : 1 .. 8
    colorback (50)
    Font.Draw (intstr (j), w div 2, j * h + h div 2, fontNumbers, 255)
end for

for i : 1 .. 8
    for decreasing j : 8 .. 1
        DrawTheCell (i, j, w, h)
    end for
end for

var xaxis := w + w div 6
var yaxis := h + (h div 6)
var piece : int := Pic.FileNew ("images/Rw.JPG")
Pic.SetTransparentColor(piece, white)
Pic.Draw (piece, xaxis, yaxis, picMerge)
xaxis := xaxis + w
piece := Pic.FileNew ("images/Nw.JPG")
Pic.SetTransparentColor(piece, white)
Pic.Draw (piece, xaxis, yaxis, picMerge)
xaxis := xaxis + w
piece := Pic.FileNew ("images/Bw.JPG")
Pic.SetTransparentColor(piece, white)
Pic.Draw (piece, xaxis, yaxis, picMerge)
xaxis := xaxis + w
piece := Pic.FileNew ("images/Qw.JPG")
Pic.SetTransparentColor(piece, white)
Pic.Draw (piece, xaxis, yaxis, picMerge)
xaxis := xaxis + w
piece := Pic.FileNew ("images/Kw.JPG")
Pic.SetTransparentColor(piece, white)
Pic.Draw (piece, xaxis, yaxis, picMerge)
xaxis := xaxis + w
piece := Pic.FileNew ("images/Bw.JPG")
Pic.SetTransparentColor(piece, white)
Pic.Draw (piece, xaxis, yaxis, picMerge)
xaxis := xaxis + w
piece := Pic.FileNew ("images/Nw.JPG")
Pic.SetTransparentColor(piece, white)
Pic.Draw (piece, xaxis, yaxis, picMerge)
xaxis := xaxis + w
piece := Pic.FileNew ("images/Rw.JPG")
Pic.SetTransparentColor(piece, white)
Pic.Draw (piece, xaxis, yaxis, picMerge)

xaxis := w + w div 6
yaxis := h * 8 + (h div 6)
piece := Pic.FileNew ("images/Rw.JPG")
Pic.SetTransparentColor(piece, white)
Pic.Draw (piece, xaxis, yaxis, picMerge)
xaxis := xaxis + w
piece := Pic.FileNew ("images/Nw.JPG")
Pic.SetTransparentColor(piece, white)
Pic.Draw (piece, xaxis, yaxis, picMerge)
xaxis := xaxis + w
piece := Pic.FileNew ("images/Bw.JPG")
Pic.SetTransparentColor(piece, white)
Pic.Draw (piece, xaxis, yaxis, picMerge)
xaxis := xaxis + w
piece := Pic.FileNew ("images/Qw.JPG")
Pic.SetTransparentColor(piece, white)
Pic.Draw (piece, xaxis, yaxis, picMerge)
xaxis := xaxis + w
piece := Pic.FileNew ("images/Kw.JPG")
Pic.SetTransparentColor(piece, white)
Pic.Draw (piece, xaxis, yaxis, picMerge)
xaxis := xaxis + w
piece := Pic.FileNew ("images/Bw.JPG")
Pic.SetTransparentColor(piece, white)
Pic.Draw (piece, xaxis, yaxis, picMerge)
xaxis := xaxis + w
piece := Pic.FileNew ("images/Nw.JPG")
Pic.SetTransparentColor(piece, white)
Pic.Draw (piece, xaxis, yaxis, picMerge)
xaxis := xaxis + w
piece := Pic.FileNew ("images/Rw.JPG")
Pic.SetTransparentColor(piece, white)
Pic.Draw (piece, xaxis, yaxis, picMerge)

piece := Pic.FileNew ("images/Pw.JPG")
Pic.SetTransparentColor(piece, white)
for i : 1 .. 8
    xaxis := i * w + w div 6
    yaxis := h + h + (h div 6)
    Pic.Draw (piece, xaxis, yaxis, picMerge)
end for


piece := Pic.FileNew ("images/Pb.JPG")
Pic.SetTransparentColor(piece, white)
for i : 1 .. 8
    xaxis := i * w + w div 6
    yaxis := h * 7 + (h div 6)
    Pic.Draw (piece, xaxis, yaxis, picMerge)
end for

var x, y, button : int
loop
    mousewhere (x, y, button)
    locate (1, 1)
    if x > 40 and y > 40 and x < 9 * h and y < 9 * w then
        put "The mouse is in cell ", y div w, " , ", letters (x div w )
    else
        put "mouse is out of screen"
    end if
end loop


-----------------------------------
Mazer
Tue Mar 29, 2005 10:36 pm


-----------------------------------
I didn't even look at your code. The problem is with your images. JPEGs are great for websites and things where a relatively minor drop in image quality is acceptable for the savings in file size. However, the compression produces artifacts in the image. That is, what you see as "white" is often just many variations of colours that are extremely close to white.

Your best bet would be to keep the images as bitmaps (if you plan to convert from JPEG to bitmap, you'll need to go over it in an image editor and fix up the areas that need to be transparent. So, go into mspaint, and erase the background so that it's all pure white and then save it as a bitmap.

-----------------------------------
Naveg
Wed Mar 30, 2005 12:08 am


-----------------------------------
i had problems with BMP's a while ago...top part was cut off

what i did was make the transparent part the colour of the background, cheated a little

-----------------------------------
jamonathin
Wed Mar 30, 2005 9:23 am


-----------------------------------
Also, if you're going to make a zip file, you may as well include the turing file, rather than  posting it as code.
