|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-10-31 13:05 UTC] pajoye@php.net
[2006-10-31 16:05 UTC] slyc6 at aol dot com
[2006-11-01 13:36 UTC] pajoye@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 19:00:01 2025 UTC |
Description: ------------ Ok the problem is that when you use imagesetpixel in an nested loop it fails to draw the specified pixel. Im trying to make an image mask and need imagecolorallocatealpha to change according to the mask image im using. But in this case i just simply set it to a grey color and an alpha value of 63. But anyway when I run this loop the image draws the pixels up to a certain point. Usually it stops on the second line 1/3 of the way. The way I fixed this porblem was taking imagecolorallocatealpha out of the nested loop and put it in the first loop. In my code I have a for loop using $x nested inside of for loop using $y. So when imagecolorallocatealpha is in the loop of $y I get my problem. But if I move it to $x I dont any problems (but I can't achieve my goal) Reproduce code: --------------- <?php $newim = imagecreate(238,226); $tran = imagecolorallocate($newim,4,4,4); imagefill($newim,0,0,$tran); imagecolortransparent ($newim,$tran); $maskcolor = 0; for($y=0;$y<226;$y++) { for($x=0;$x<238;$x++) { $maskcolor = imagecolorallocatealpha ($newim,0,0,0,63); imagesetpixel ($newim,$x,$y,$maskcolor); } } header("Content-type: image/png"); imagepng($newim); ?> Expected result: ---------------- what it should doing is something along the lines of this ---------------------------------- xxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx etc... Actual result: -------------- but I get something like this -------------------------- xxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxx