View unanswered posts | View active topics It is currently Thu Mar 28, 2024 11:43 am



Reply to topic  [ 3 posts ] 
Transparent background 
Author Message
New pChart user
New pChart user

Joined: Sun Jan 16, 2011 2:15 pm
Posts: 3
Post Transparent background
I've noticed that pPie draws on transparent background but could not get regular charts with pImage to have transparent backgrounds:

I had to amend the code, and I'm not sure i've done the right thing but here goes.
In pImage

Code:
function pImage($XSize,$YSize,$DataSet = NULL)  {
     if ( $DataSet != NULL ) { $this->DataSet = $DataSet; }

     $this->XSize   = $XSize;
     $this->YSize   = $YSize;
     $this->Picture = imagecreatetruecolor($XSize,$YSize);

     imagealphablending($this->Picture, false);
     
     $col=imagecolorallocatealpha($this->Picture, 255, 255, 255, 127);
     imagefilledrectangle($this->Picture, 0,0,$XSize, $YSize, $col);
     
     imagealphablending($this->Picture,TRUE);

     // $C_White = $this->AllocateColor($this->Picture,255,255,255);
     // imagefilledrectangle($this->Picture,0,0,$XSize,$YSize,$C_White);
     
    }

...

/* Render the picture to a file */
   function render($FileName) {
       imagealphablending($this->Picture,false);
      imagesavealpha($this->Picture,true);
       imagepng($this->Picture,$FileName);
    }


as per this blog entry.
Is there a legit way of doing this without changing pImage?


Sun Jan 16, 2011 3:52 pm
Profile WWW
Site Admin
Site Admin
User avatar

Joined: Thu Dec 02, 2010 2:31 pm
Posts: 409
Location: France
Post Re: Transparent background
To be honest this is something that I was looking for since long times. I've adapted the code to the last subversion and added a $TransparentBackground switch to the pImage() class constructor. Rendering results are awesome.

Thank you very much for this suggestion and code!

JD.


Attachments:
Capture.PNG
Capture.PNG [ 48.46 KiB | Viewed 6620 times ]
Sun Jan 16, 2011 5:11 pm
Profile WWW
Site Admin
Site Admin
User avatar

Joined: Thu Dec 02, 2010 2:31 pm
Posts: 409
Location: France
Post Re: Transparent background
This has been fixed in the 2.1.0 that you can get from here : download.

Kind regards,
JD.


Wed Jan 26, 2011 3:02 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron