ID:               39314
 User updated by:  slyc6 at aol dot com
 Reported By:      slyc6 at aol dot com
 Status:           Bogus
 Bug Type:         *General Issues
 Operating System: Windows XP
 PHP Version:      5.1.6
 Assigned To:      pajoye
 New Comment:

Well I only use 63 for the example. But what Im  really trying to do is
set a color ever pixel but the color differ in alpha value depending on 
the color of the pixel in the image mask that I am using.

imagecolorallocatealpha ($newim,0,0,0,63);      
So when I really call this function it would be more along the lines
of
imagecolorallocatealpha ($newim,$backr,$backg,$backb,$alpha);

So is there a way I can delete the previous color after I use it since
I only need it for that one pixel? So I dont reach that 255 cap?


Previous Comments:
------------------------------------------------------------------------

[2006-10-31 13:05:59] [EMAIL PROTECTED]

You allocate a new color on each iteration. You reached the 255 limit
on the 255th iteration.

It makes also little sense to do that in the loop if you use always the
same color. As a side note, you may consider to use imagefill or
imagefilledrectangle.

------------------------------------------------------------------------

[2006-10-31 02:50:02] slyc6 at aol dot com

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


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=39314&edit=1

Reply via email to