Saving an Image Background as Transparent?
Author |
Message |
Fexter
|
Posted: Mon Jan 30, 2012 12:55 pm Post subject: Saving an Image Background as Transparent? |
|
|
What is it you are trying to achieve?
I want to use Turing to automate making pictures (Such as text) with transparent backgrounds (So I can easily bring them into other programs and not have to worry about the white of the background).
What is the problem you are having?
I can't seem to find any way to make the background transparent once I save my image.
Describe what you have tried to solve this problem
I tried looking through the Turing Documentation for something that would be able to do this, but didn't find anything. I also looked through the forum search, but all I could find was setting what colour is transparent for Turing.
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Turing: |
% My current code
% Displays 1 - 9, finds where it's located on the screen, then saves this with a random name
% Declare variables
var maxX, minX, maxY, minY, nameNum : int
var name : string
procedure saveScreen
% The main part
% Reset the min and max variables
maxX := 0
maxY := 0
minX := maxx
minY := maxy
% Look through every square
for x : 0 .. maxx
for y : 0 .. maxy
if whatdotcolor (x, y ) not= white then
if y < minY then
minY := y
elsif y > maxY then
maxY := y
end if
if x > maxX then
maxX := x
elsif x < minX then
minX := x
end if
end if
end for
end for
% Move the min and max values by five; makes it have a bit of a border
if minX - 5 >= 0 then
minX - = 5
end if
if maxX + 5 <= maxx then
maxX + = 5
end if
if minY - 5 >= 0 then
minY - = 5
end if
if maxY - 5 <= 0 then
maxY - = 5
end if
% Generate the random name
nameNum := Rand.Int (1, maxint)
name := "TuringPic" + intstr(nameNum ) + ".bmp"
% Finally, save the picture
Pic.ScreenSave (minX, minY, maxX, maxY, name )
end saveScreen
% Show 1 .. 9, then save the text on the screen
for i : 1 .. 9
cls
Font.Draw(intstr(i ), maxx div 2, maxy div 2, Font.New("Arial:20:bold"), black)
saveScreen (intstr(i ))
end for
|
Please specify what version of Turing you are using
I am using Turing 4.1.1. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
mirhagk
|
Posted: Mon Jan 30, 2012 1:15 pm Post subject: RE:Saving an Image Background as Transparent? |
|
|
I don't think you can natively with Turing, you'd have to figure out how to parse the picture file yourself. |
|
|
|
|
|
Fexter
|
Posted: Mon Jan 30, 2012 1:28 pm Post subject: RE:Saving an Image Background as Transparent? |
|
|
Okay, thanks. |
|
|
|
|
|
Raknarg
|
Posted: Mon Jan 30, 2012 4:28 pm Post subject: RE:Saving an Image Background as Transparent? |
|
|
If I'm unserstanding this correctly, you can probably solve the problem by using picMerge instead of picCopy when you draw an image. |
|
|
|
|
|
copthesaint
|
Posted: Mon Jan 30, 2012 4:59 pm Post subject: Re: RE:Saving an Image Background as Transparent? |
|
|
Fexter wrote:
What is it you are trying to achieve?
I want to use Turing to automate making pictures (Such as text) with transparent backgrounds (So I can easily bring them into other programs and not have to worry about the white of the background).
If you want to accomplish this first you will need to save Two Images. First Your Colored Image, second your Alpha image which will be composed of grey scale colors.
then you will need to write a file from another language (or find one) that will allow you to set the alpha channel with an image, and allow you to save that file, here is an example.
I myself havnt had a reason to ever save an image with an alpha channel. So I cant really help you anymore.
Raknarg @ Mon Jan 30, 2012 wrote: If I'm unserstanding this correctly, you can probably solve the problem by using picMerge instead of picCopy when you draw an image.
No That not what he wants. he wants to save with alpha not draw transparent. |
|
|
|
|
|
|
|