You are here: Re: setting imagecreatetruecolor() to have transparency as default « PHP Programming Language « IT news, forums, messages
Re: setting imagecreatetruecolor() to have transparency as default

Posted by Kimmo Laine on 12/18/01 11:48

"Chamomile" <newsgroups@chamomile.co.uk> wrote in message
news:OJWdnR76YoFdfezZRVny1A@bt.com...
> Yes, thanks - I came accross that.
> The problem is, it only makes a non-truecolor image which is no good for
> my
> purposes
> as I am downsampling with imagecopyresample() in order to get 'aliased'
> curve fills at small sizes.
> - downsampling an image made using imagecreate() gives jagged curves,
> whereas downsampling using imagecreatetruecolor() gives good smoothing.
> Unfotunately it seems once an image has ever been truecolor - even if you
> theoretically set it back to paletted colors
> (as far as I can see with experimentation) you cannot re-set the
> transparency of the 'black' areas.
>
> It seems to be a choice between smoothed curves or transparency - not
> both!
>

A slight modification to the original sample seems to answer the question.

<?php

header('Content-type: image/png');
$imageOut = imagecreate(100, 100);
$colourBlack = imagecolorallocatealpha($imageOut, 0, 0, 0, 127);
imagepng($imageOut);

?>

This worked for me so that when I saved the image and opened it in photoshop
it really was transparent. The solution apparently is that the first color
you allocate defines the background of the image. Now if you use
imagecolorallocatealpha and give 127 as the alpha channel, you'll get a
truecolor image with completely transparent bg.

HTH, again ;)

--
"ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" -lpk
spam@outolempi.net | Gedoon-S @ IRCnet | rot13(xvzzb@bhgbyrzcv.arg)

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация