RE: Transparent color

2010-04-26 Thread CHAN, KENNETH 1 [AG/7721]
Thanks Shawn. But still not working.

> -Original Message-
> From: Shawn H Corey [mailto:shawnhco...@gmail.com]
> Try:
> my $img = new GD::Image(100,100,1);
[CHAN] Same as before, no difference.


-
This e-mail message may contain privileged and/or confidential information, and 
is intended to be received only by persons entitled to receive such 
information. If you have received this e-mail in error, please notify the 
sender immediately. Please delete it and all attachments from any servers, hard 
drives or any other media. Other use of this e-mail by you is strictly 
prohibited.


All e-mails and attachments sent and received are subject to monitoring, 
reading and archival by Monsanto, including its subsidiaries. The recipient of 
this e-mail is solely responsible for checking for the presence of "Viruses" or 
other "Malware". Monsanto, along with its subsidiaries, accepts no liability 
for any damage caused by any such code transmitted by or accompanying this 
e-mail or any attachment.
-


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Transparent color

2010-04-23 Thread Shlomi Fish
On Friday 23 Apr 2010 15:03:19 Shawn H Corey wrote:
> CHAN, KENNETH 1 [AG/7721] wrote:
> > First of all, thanks Owen, Shlomi and Shawn for your advices.
> > But I still can't get the line appear on the transparent circle. I am
> > guessing maybe there is a problem with my Perl setting or something.
> > Please see in text comments.
> 
> Try:
> my $img = new GD::Image(100,100,1);

That should be:
[code]
my $img = GD::Image->new(100,100,1);
[/code]

Indirect object creation ("new GD::Image") should be avoided. See Perl Best 
Practices and the 3rd Camel book ("Programming Perl") for why.

Regards,

Shlomi Fish

-- 
-
Shlomi Fish   http://www.shlomifish.org/
"Star Trek: We, the Living Dead" - http://shlom.in/st-wtld

Deletionists delete Wikipedia articles that they consider lame.
Chuck Norris deletes deletionists whom he considers lame.

Please reply to list if it's a mailing list post - http://shlom.in/reply .

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Transparent color

2010-04-23 Thread Shawn H Corey

CHAN, KENNETH 1 [AG/7721] wrote:

First of all, thanks Owen, Shlomi and Shawn for your advices.
But I still can't get the line appear on the transparent circle. I am
guessing maybe there is a problem with my Perl setting or something.
Please see in text comments.



Try:
my $img = new GD::Image(100,100,1);


--
Just my 0.0002 million dollars worth,
  Shawn

Programming is as much about organization and communication
as it is about coding.

I like Perl; it's the only language where you can bless your
thingy.

Eliminate software piracy:  use only FLOSS.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Transparent color

2010-04-23 Thread Owen
On Fri, 23 Apr 2010 15:04:27 +0800
"CHAN, KENNETH 1 [AG/7721]"  wrote:

> First of all, thanks Owen, Shlomi and Shawn for your advices.
> But I still can't get the line appear on the transparent circle. I am
> guessing maybe there is a problem with my Perl setting or something.
> Please see in text comments.


Apologies, an optical illusion on my part and I have no transparency in
the generated image. (see what you want to see)

Furthermore, I am as stumped as you in realizing this requirement





Owen

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




RE: Transparent color

2010-04-23 Thread CHAN, KENNETH 1 [AG/7721]
First of all, thanks Owen, Shlomi and Shawn for your advices.
But I still can't get the line appear on the transparent circle. I am
guessing maybe there is a problem with my Perl setting or something.
Please see in text comments.


> -Original Message-
> From: Owen [mailto:rc...@pcug.org.au]
> I rewrote your script to write to the hard drive. The background line
> is there when I viewed it in xview.
> 
> What did you use to view the image?
[CHAN] I was using IE6, Firefox and Chrome to view it. I tried to use
the same code as Owen's to write to a file then used GIMP2 to view it.
The circle is transparent color but still cannot see the line. When I
used xview to view it, the circle only appears as solid pink, still no
line.


> -Original Message-
> From: Shlomi Fish [mailto:shlo...@iglu.org.il]
> I think the Alpha color was drawn above the line, as the canvas of GD
is not
> multi-layered. Otherwise, here are some comments on your code:
[CHAN] I was guessing that this is the reason. But if Owen could get the
line drawn, there must be some problem with my perl setting or
something.


> -Original Message-
> From: Shawn H Corey [mailto:shawnhco...@gmail.com]
> 
> The alphaBlending may be in the wrong mode.  Try setting it to 0 and
> then try 1.
[CHAN] I tried both, but still not working. 



-
This e-mail message may contain privileged and/or confidential information, and 
is intended to be received only by persons entitled to receive such 
information. If you have received this e-mail in error, please notify the 
sender immediately. Please delete it and all attachments from any servers, hard 
drives or any other media. Other use of this e-mail by you is strictly 
prohibited.


All e-mails and attachments sent and received are subject to monitoring, 
reading and archival by Monsanto, including its subsidiaries. The recipient of 
this e-mail is solely responsible for checking for the presence of "Viruses" or 
other "Malware". Monsanto, along with its subsidiaries, accepts no liability 
for any damage caused by any such code transmitted by or accompanying this 
e-mail or any attachment.
-


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Transparent color

2010-04-22 Thread Shawn H Corey

CHAN, KENNETH 1 [AG/7721] wrote:

Hi all,

  I used colorAllocateAlpha to specify a transparent color. After
filling a circle with it, I don't see the background line which is drawn
before. The code is pasted below. What did I do wrong here? Thanks.



The alphaBlending may be in the wrong mode.  Try setting it to 0 and 
then try 1.



--
Just my 0.0002 million dollars worth,
  Shawn

Programming is as much about organization and communication
as it is about coding.

I like Perl; it's the only language where you can bless your
thingy.

Eliminate software piracy:  use only FLOSS.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Transparent color

2010-04-22 Thread Shlomi Fish
On Thursday 22 Apr 2010 12:12:34 CHAN, KENNETH 1 [AG/7721] wrote:
> Hi all,
> 
>   I used colorAllocateAlpha to specify a transparent color. After
> filling a circle with it, I don't see the background line which is drawn
> before. The code is pasted below. What did I do wrong here? Thanks.

I think the Alpha color was drawn above the line, as the canvas of GD is not 
multi-layered. Otherwise, here are some comments on your code:

> 
> 
> 
> Regards,
> 
> Kenneth
> 
> 
> 
> 
> 
> ## Code ###
> 
> print "Content-type: text/plain; charset-iso-8859-1\n\n";
> 

Please add "use strict;" and "use warnings;" and correct all the problems.

Also use CGI.pm or something like that. You also probably want to print a head 
with an "image/png" (IIRC) content-type instead of "text/plain".

Otherwise, looks fine.

Regards,

Shlomi Fish

> 
> 
> use GD;
> 
> my $img = new GD::Image(100,100);
> 
> 
> 
> $black = $img->colorAllocateAlpha(0,0,0,0);
> 
> $blue = $img->colorAllocateAlpha(0,0,255,0);
> 
> $redTrans = $img->colorAllocateAlpha(255,0,0,100);
> 
> 
> 
> $img->rectangle(0,0,99,99,$black);
> 
> $img->fill(50,50,$blue);
> 
> $img->line(0,0,100,100,$black);
> 
> # draw a transparent circle
> 
> $img->filledArc(50,50,50,50,0,360, $redTrans);
> 
> 
> 
> binmode STDOUT;
> 
> print $img->png;
> 
> 
> ---
> -- This e-mail message may contain privileged
> and/or confidential information, and is intended to be received only by
> persons entitled to receive such information. If you have received this
> e-mail in error, please notify the sender immediately. Please delete it
> and all attachments from any servers, hard drives or any other media.
> Other use of this e-mail by you is strictly prohibited.
> 
> 
> All e-mails and attachments sent and received are subject to monitoring,
> reading and archival by Monsanto, including its subsidiaries. The
> recipient of this e-mail is solely responsible for checking for the
> presence of "Viruses" or other "Malware". Monsanto, along with its
> subsidiaries, accepts no liability for any damage caused by any such code
> transmitted by or accompanying this e-mail or any attachment.
> --
> ---

-- 
-
Shlomi Fish   http://www.shlomifish.org/
Understand what Open Source is - http://shlom.in/oss-fs

Deletionists delete Wikipedia articles that they consider lame.
Chuck Norris deletes deletionists whom he considers lame.

Please reply to list if it's a mailing list post - http://shlom.in/reply .

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Transparent color

2010-04-22 Thread Owen

> Hi all,
>
>   I used colorAllocateAlpha to specify a transparent color. After
> filling a circle with it, I don't see the background line which is
> drawn
> before. The code is pasted below. What did I do wrong here? Thanks.



I rewrote your script to write to the hard drive. The background line
is there when I viewed it in xview.

What did you use to view the image?


Owen (see below for rewritten code)


>
> ## Code ###
>
> print "Content-type: text/plain; charset-iso-8859-1\n\n";
>
>
>
> use GD;
>
> my $img = new GD::Image(100,100);
>
>
>
> $black = $img->colorAllocateAlpha(0,0,0,0);
>
> $blue = $img->colorAllocateAlpha(0,0,255,0);
>
> $redTrans = $img->colorAllocateAlpha(255,0,0,100);
>
>
>
> $img->rectangle(0,0,99,99,$black);
>
> $img->fill(50,50,$blue);
>
> $img->line(0,0,100,100,$black);
>
> # draw a transparent circle
>
> $img->filledArc(50,50,50,50,0,360, $redTrans);
>
>
>
> binmode STDOUT;
>
> print $img->png;
>
>
>


Rewritten=
#!/usr/bin/perl

use strict;
use warnings;
use GD;

my $img = new GD::Image(100,100);
my $black = $img->colorAllocateAlpha(0,0,0,0);
my $blue = $img->colorAllocateAlpha(0,0,255,0);
my $redTrans = $img->colorAllocateAlpha(255,0,0,100);

$img->rectangle(0,0,99,99,$black);
$img->fill(50,50,$blue);
$img->line(0,0,100,100,$black);
$img->filledArc(50,50,50,50,0,360, $redTrans);

open(my $IMG, '>', "test.png") or die "$1\n";
binmode $IMG;
print $IMG $img->png;
close($IMG);


-- 



Owen


-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Transparent color

2010-04-22 Thread CHAN, KENNETH 1 [AG/7721]
Hi all,

  I used colorAllocateAlpha to specify a transparent color. After
filling a circle with it, I don't see the background line which is drawn
before. The code is pasted below. What did I do wrong here? Thanks.

 

Regards,

Kenneth

 

 

## Code ###

print "Content-type: text/plain; charset-iso-8859-1\n\n";

 

use GD;

my $img = new GD::Image(100,100);

 

$black = $img->colorAllocateAlpha(0,0,0,0);

$blue = $img->colorAllocateAlpha(0,0,255,0);

$redTrans = $img->colorAllocateAlpha(255,0,0,100);

 

$img->rectangle(0,0,99,99,$black);

$img->fill(50,50,$blue);

$img->line(0,0,100,100,$black);

# draw a transparent circle

$img->filledArc(50,50,50,50,0,360, $redTrans);

 

binmode STDOUT;

print $img->png;


-
This e-mail message may contain privileged and/or confidential information, and 
is intended to be received only by persons entitled to receive such 
information. If you have received this e-mail in error, please notify the 
sender immediately. Please delete it and all attachments from any servers, hard 
drives or any other media. Other use of this e-mail by you is strictly 
prohibited.


All e-mails and attachments sent and received are subject to monitoring, 
reading and archival by Monsanto, including its subsidiaries. The recipient of 
this e-mail is solely responsible for checking for the presence of "Viruses" or 
other "Malware". Monsanto, along with its subsidiaries, accepts no liability 
for any damage caused by any such code transmitted by or accompanying this 
e-mail or any attachment.
-