On Thu, 21 Nov 2002, Arnaud wrote:

> Hi everyone,
> I'd like to use "imagecreatetruecolor" function in order to "cut and paste"
> JPG files on a white background. It seems not to work correctly.

  This one bit me when I started working with GD 2.x as well.  Simply draw
  a filled rectangle over your entire canvas in the color you want:

<?
  $im=imagecreatetruecolor(50,50);
  $COULEUR_BLANC=imagecolorallocate($im,255,255,255);
  imagefilledrectangle($im,0,0,49,49,$COULEUR_BLANC);
  header ("Content-type: image/png");
  ImagePNG($im);
  imagedestroy($im);
?>

  The reason seems to be that when you create an indexed-color image
  (imagecreate()) gd sets all pixels to index 0, and when you allocate
  your first color, that's index 0.  Thus all background pixels magically
  become that color.

  When you use imagecreatetruecolor(), it sets all the pixels to black,
  and you have to explicitly draw them in to get them white.

-- 
   Morgan Hughes
   C programmer and highly caffeinated mammal.
   [EMAIL PROTECTED]
   ICQ: 79293356




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to