Ask a Question related to PHP Bugs, Design and Development.
-
slyc6 at aol dot com #1
#39314 [NEW]: imagecolorallocatealpha causing problems
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 [url]http://bugs.php.net/?id=39314&edit=1[/url]
--
Try a CVS snapshot (PHP 4.4): [url]http://bugs.php.net/fix.php?id=39314&r=trysnapshot44[/url]
Try a CVS snapshot (PHP 5.2): [url]http://bugs.php.net/fix.php?id=39314&r=trysnapshot52[/url]
Try a CVS snapshot (PHP 6.0): [url]http://bugs.php.net/fix.php?id=39314&r=trysnapshot60[/url]
Fixed in CVS: [url]http://bugs.php.net/fix.php?id=39314&r=fixedcvs[/url]
Fixed in release: [url]http://bugs.php.net/fix.php?id=39314&r=alreadyfixed[/url]
Need backtrace: [url]http://bugs.php.net/fix.php?id=39314&r=needtrace[/url]
Need Reproduce Script: [url]http://bugs.php.net/fix.php?id=39314&r=needscript[/url]
Try newer version: [url]http://bugs.php.net/fix.php?id=39314&r=oldversion[/url]
Not developer issue: [url]http://bugs.php.net/fix.php?id=39314&r=support[/url]
Expected behavior: [url]http://bugs.php.net/fix.php?id=39314&r=notwrong[/url]
Not enough info: [url]http://bugs.php.net/fix.php?id=39314&r=notenoughinfo[/url]
Submitted twice: [url]http://bugs.php.net/fix.php?id=39314&r=submittedtwice[/url]
register_globals: [url]http://bugs.php.net/fix.php?id=39314&r=globals[/url]
PHP 3 support discontinued: [url]http://bugs.php.net/fix.php?id=39314&r=php3[/url]
Daylight Savings: [url]http://bugs.php.net/fix.php?id=39314&r=dst[/url]
IIS Stability: [url]http://bugs.php.net/fix.php?id=39314&r=isapi[/url]
Install GNU Sed: [url]http://bugs.php.net/fix.php?id=39314&r=gnused[/url]
Floating point limitations: [url]http://bugs.php.net/fix.php?id=39314&r=float[/url]
No Zend Extensions: [url]http://bugs.php.net/fix.php?id=39314&r=nozend[/url]
MySQL Configuration Error: [url]http://bugs.php.net/fix.php?id=39314&r=mysqlcfg[/url]
slyc6 at aol dot com Guest
-
Contribute - causing more problems than it cures?
;) Contribute has been nothing but problems and delays and amateurish nonsense since the minute it was installed on my office system. I have years... -
6.1 updater causing problems in error.rootcause
I am having trouble with my error reporting because after installing 6.1 updater on Windows 2003 Server w/ IIS the RootCause value in error... -
<wsdlHelpGenerator> causing problems with web-service references !?!
I have then been using Visual Studio to auto-create web service references to my .asmx files. But all my Reference.cs files are referring to the... -
Acro 6.01 update causing Twain problems?
I am having the same problem. I have a Cannon scanner with a document feeder. This scanner worked perfectly with Acrobat version 5 but after I... -
browser settings causing problems
I have created a online study course that streams mp3 files as the audio src. I have found that if IE's "Temp Internet Files" setting is set to... -
bjori@php.net #2
#39314 [Opn->Asn]: imagecolorallocatealpha causing problems
ID: 39314
Updated by: [email]bjori@php.net[/email]
Reported By: slyc6 at aol dot com
-Status: Open
+Status: Assigned
Bug Type: *General Issues
Operating System: Windows XP
PHP Version: 5.1.6
-Assigned To:
+Assigned To: pajoye
Previous Comments:
------------------------------------------------------------------------
[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 [url]http://bugs.php.net/?id=39314&edit=1[/url]
bjori@php.net Guest
-
pajoye@php.net #3
#39314 [Asn->Bgs]: imagecolorallocatealpha causing problems
ID: 39314
Updated by: [email]pajoye@php.net[/email]
Reported By: slyc6 at aol dot com
-Status: Assigned
+Status: Bogus
Bug Type: *General Issues
Operating System: Windows XP
PHP Version: 5.1.6
Assigned To: pajoye
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[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 [url]http://bugs.php.net/?id=39314&edit=1[/url]
pajoye@php.net Guest
-
slyc6 at aol dot com #4
#39314 [Bgs]: imagecolorallocatealpha causing problems
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]pajoye@php.net[/email]
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 [url]http://bugs.php.net/?id=39314&edit=1[/url]
slyc6 at aol dot com Guest
-
pajoye@php.net #5
#39314 [Bgs]: imagecolorallocatealpha causing problems
ID: 39314
Updated by: [email]pajoye@php.net[/email]
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."
You try to use much colors:
for($y=0;$y<226;$y++)for($x=0;$x<238;$x++); <<!!
Imagecreate creates a palette based images. Palette based images use a
256 colors palette to store the colors used by the image. Each color
has a unique index. The pixel uses this index to define which color to
use.
use true color images, they have unlimited colors (nearly):
$im = imagecreatetruecolor(...);
Previous Comments:
------------------------------------------------------------------------
[2006-10-31 16:05:47] slyc6 at aol dot com
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?
------------------------------------------------------------------------
[2006-10-31 13:05:59] [email]pajoye@php.net[/email]
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 [url]http://bugs.php.net/?id=39314&edit=1[/url]
pajoye@php.net Guest



Reply With Quote

