#39314 [NEW]: imagecolorallocatealpha causing problems
| From: | slyc6 at aol dot com | Date: | Tue, 31 Oct 2006 02:50:02 +0000 |
| Subject: | #39314 [NEW]: imagecolorallocatealpha causing problems | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-104204@lists.php.net to get a copy of this message | ||
From: slyc6 at aol dot com
Operating system: Windows XP
PHP version: 5.1.6
PHP Bug Type: *General Issues
Bug description: imagecolorallocatealpha causing problems
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 bug report at http://bugs.php.net/?id=39314&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=39314&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=39314&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=39314&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=39314&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=39314&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=39314&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=39314&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=39314&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=39314&r=support
Expected behavior: http://bugs.php.net/fix.php?id=39314&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=39314&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=39314&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=39314&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=39314&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=39314&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=39314&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=39314&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=39314&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=39314&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=39314&r=mysqlcfg