#39314 [NEW]: imagecolorallocatealpha causing problems

Ask a Question related to PHP Bugs, Design and Development.

  1. #1

    Default #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

  2. Similar Questions and Discussions

    1. 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...
    2. 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...
    3. <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...
    4. 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...
    5. 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...
  3. #2

    Default #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

  4. #3

    Default #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

  5. #4

    Default #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

  6. #5

    Default #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

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139