ScotlandPHP

imagesetpixel

(PHP 4, PHP 5, PHP 7)

imagesetpixelSet a single pixel

Description

bool imagesetpixel ( resource $image , int $x , int $y , int $color )

imagesetpixel() draws a pixel at the specified coordinate.

Parameters

image

An image resource, returned by one of the image creation functions, such as imagecreatetruecolor().

x

x-coordinate.

y

y-coordinate.

color

A color identifier created with imagecolorallocate().

Return Values

Returns TRUE on success or FALSE on failure.

Examples

Example #1 imagesetpixel() example

A random drawing that ends with a regular picture.

<?php

$x 
200;
$y 200;

$gd imagecreatetruecolor($x$y);
 
$corners[0] = array('x' => 100'y' =>  10);
$corners[1] = array('x' =>   0'y' => 190);
$corners[2] = array('x' => 200'y' => 190);

$red imagecolorallocate($gd25500); 

for (
$i 0$i 100000$i++) {
  
imagesetpixel($gdround($x),round($y), $red);
  
$a rand(02);
  
$x = ($x $corners[$a]['x']) / 2;
  
$y = ($y $corners[$a]['y']) / 2;
}
 
header('Content-Type: image/png');
imagepng($gd);

?>

The above example will output something similar to:

Output of example : imagesetpixel()

See Also

add a note add a note

User Contributed Notes 23 notes

up
8
guy032 at gmail dot com
5 years ago
making images with white (or close to white) background transprent

<?
function FloodFill($im, $x, $y)
{
   
$rgb = imagecolorat($im, $x, $y);
   
$r = ($rgb >> 16) & 0xFF;
   
$g = ($rgb >> 8) & 0xFF;
   
$b = $rgb & 0xFF;

   
$counter=0;
   
$counter2=0;
    if(
$r >= 245){ $counter++;}
    if(
$g >= 245){ $counter++;}
    if(
$b >= 245){ $counter++;}
    if(
$r >= 240){ $counter2++;}
    if(
$g >= 240){ $counter2++;}
    if(
$b >= 240){ $counter2++;}

    if(
$counter >= 1 && $counter2 == 3){
       
$background = imagecolorallocate($im, 180, 0, 255);
       
imagesetpixel($im, $x, $y, $background);

       
FloodFill ($im, $x, $y+1);
       
FloodFill ($im, $x+1, $y);
       
FloodFill ($im, $x, $y-1);
    }
}

$src = $_GET["src"];
$im = imagecreatefromjpeg($src);

// Draw border
$border = imagecolorallocate($im, 180, 0, 255);
drawBorder($im, $border, 1);

// Draw a border
function drawBorder($im, $color, $thickness = 1)
{
   
$x1 = 0;
   
$y1 = 0;
   
$x2 = ImageSX($im) - 1;
   
$y2 = ImageSY($im) - 1;

    for(
$i = 0; $i < $thickness; $i++)
    {
       
ImageRectangle($im, $x1++, $y1++, $x2--, $y2--, $color);
    }
}

$rgb = imagecolorat($im, 0, 0);
FloodFill($im, 0, 0);
$color = imagecolorallocate($im, 180, 0, 255);
imagecolortransparent($im, $color);
header("Content-type: image/png");
imagepng($im);
imagedestroy($im);
?>
up
3
d [AT] sprid [DOT] de
12 years ago
This code does generate a RGB-cube (with or without borders). Because its only rendering the visible pixels its clearly fast (approx 1 up to 2 seconds). With changing the $order-variable you can see the cube from different perspectives. Entering double or tribble values (like rrg or ggg) will give you other specs of single channels. Send any sugestions to my email.

<?php
$borders
= true;
$order   = 'rgb';

set_time_limit(0);
$img = imageCreateTrueColor(510, 510);

$bg = imageColorAllocate($img, 255, 255, 255);
$black = imageColorAllocate($img, 255, 255, 255);

for (
$r=0; $r<256; $r++) {
  for (
$g=0; $g<256; $g++) {
    for (
$b=0; $b<256; $b++) {
     
$rN = ${$order{0}};
     
$gN = ${$order{1}};
     
$bN = ${$order{2}};
   
     
$col = imageColorAllocate($img, $rN, $gN, $bN);
     
imagesetpixel($img, $b+($r*0.5)+(255/4), $g+($r*0.5)+(255/4), $col);
      if (
$r < 255 && $g > 0) break;
    }
  }
 
  if (
$borders) {
   
imagesetpixel($img, ($r*0.5+(255/4)), ($r*0.5)+(255/4),     $black);
   
imagesetpixel($img, ($r*0.5)+255+(255/4), ($r*0.5)+(255/4), $black);
   
imagesetpixel($img, ($r*0.5)+(255/4), ($r*0.5)+255+(255/4), $black);
  }
}

if (
$borders) {
 
imageline($img, 255/4, 255/4, 255+(255/4), 255/4, $black);
 
imageline($img, 255/4, 255/4, 255/4, 255+(255/4), $black);
 
imageline($img, 255*0.5+(255/4), 255*0.5+(255/4), 255*0.5+(255/4), 255*0.5 + 509*0.5+(255/4), $black);
 
imageline($img, 255*0.5+(255/4), 255*0.5+(255/4), 255*0.5 + 509*0.5+(255/4), 255*0.5+(255/4), $black);
 
imageline($img, 255*0.5+(255/4), 255*0.5 + 509*0.5+(255/4), 255*0.5 + 509*0.5+(255/4), 255*0.5 + 509*0.5+(255/4), $black);
 
imageline($img, 255*0.5 + 509*0.5+(255/4), 255*0.5+(255/4), 255*0.5 + 509*0.5+(255/4), 255*0.5 + 509*0.5+(255/4), $black);
}

header("Content-Type: image/png");
imagepng($img);
imagedestroy($img);
?>
up
1
CR@SH
3 years ago
imagesetpixel ($image, $x, $y, IMG_COLOR_BRUSHED);
up
2
mail AT kkapsner DOT de
7 years ago
It IS posible to "delete" pixels from an image in PHP natively - the key-function is imageAlphaBlending:
<?php

$image
= imageCreateTrueColor(101, 101);
imageSaveAlpha($image, true);

# draw a red cycle with alpha blending
$red = imageColorAllocateAlpha($image, 255, 0, 0, 30);
imageFilledEllipse($image, 50, 50, 100, 100, $red);

# disable alpha blending for deletion
imageAlphaBlending($image, false);

# paint with a complete opaque color
$trans = imageColorAllocateAlpha($image, 0, 0, 0, 127);

# you can clear every shape you like
imageFilledRectangle($image, 30, 30, 70, 70, $trans);

# enable alpha blending again
imageAlphaBlending($image, true);

# draw a green rectangle with alpha blending
$green = imageColorAllocateAlpha($image, 0, 255, 0, 40);
imageFilledRectangle($image, 40, 20, 90, 80, $green);

header("Content-Type: image/png");
imagePNG($image);

?>
up
2
cyberhorse at users dot sourceforge dot net
7 years ago
Given an image $src and mask $mask, this applies the mask over the image, using different levels of transparency properly.

<?php
function image_mask(&$src, &$mask) {
   
imagesavealpha($src, true);
   
imagealphablending($src, false);
   
// scan image pixels
   
for ($x = 0; $x < imagesx($src); $x++) {
        for (
$y = 0; $y < imagesy($src); $y++) {
           
$mask_pix = imagecolorat($mask,$x,$y);
           
$mask_pix_color = imagecolorsforindex($mask, $mask_pix);
            if (
$mask_pix_color['alpha'] < 127) {
               
$src_pix = imagecolorat($src,$x,$y);
               
$src_pix_array = imagecolorsforindex($src, $src_pix);
               
imagesetpixel($src, $x, $y, imagecolorallocatealpha($src, $src_pix_array['red'], $src_pix_array['green'], $src_pix_array['blue'], 127 - $mask_pix_color['alpha']));
            }
        }
    }
}
?>

If your mask is reversed, change 127 - $mask_pix_color['alpha'] with just $mask_pix_color['alpha']
up
1
aelitadelarobia at gmail dot com
8 years ago
another gradient example that can do horizontal or vertical gradients

<?php
$width
=$_GET['width'];
$height=$_GET['height'];
$starts=explode(",",$_GET['startcolor']);
$ends=explode(",",$_GET['endcolor']);
   
$rstart=$starts[0];
   
$gstart=$starts[1];
   
$bstart=$starts[2];
   
$rend=$ends[0];
   
$gend=$ends[1];
   
$bend=$ends[2];
   
$r=$rstart;
   
$g=$gstart;
   
$b=$bstart;
$bigger=imagecreatetruecolor($width,$height);
for (
$y=0;$y<=265;$y++) {
    if (
$mode == 'horiz') { //if doing a horizontal gradient, reset to the starting color every row
       
$r=$rstart;
       
$g=$gstart;
       
$b=$bstart;
    }
    for (
$x=0;$x<=464;$x++) {
       
imagesetpixel($bigger,$x,$y,imagecolorallocate($bigger,$r,$g,$b));
        if (
$mode=="horiz") {   
            if (
$r != $rend) {
               
$r=$r+(($rend-$rstart)/$width);
            }
            if (
$g != $gend) {
               
$g=$g+(($gend-$gstart)/$width);
            }
            if (
$b != $bend) {
               
$b=$b+(($bend-$bstart)/$width);
            }
        }
    }
    if (
$mode == "vert") {
        if (
$r != $rend) {
           
$r=$r+(($rend-$rstart)/$height);
        }
        if (
$g != $gend) {
           
$g=$g+(($gend-$gstart)/$height);
        }
        if (
$b != $bend) {
           
$b=$b+(($bend-$bstart)/$height);
        }
    }
}
header("Content-type: image/jpeg");
header('Content-Disposition: inline; filename="gradient.jpg"');

imagejpeg($bigger,NULL,99);
imagedestroy($bigger);
?>
up
1
Scott Evernden (doctor3d at gmail)
9 years ago
My last note doesn't do alpha properly, so make the following change to the appropriate lines:

$r = ($word & 0x7C00) >> 7;
$g = ($word & 0x03E0) >> 2;
$b = ($word & 0x001F) << 3;
$a = ($word & 0x8000) ? 127 : 0;
$color = imagecolorallocatealpha($image, $r, $g, $b, $a);
imagesetpixel($image, $x, $y, $color);
up
1
Scott Evernden (doctor3d at gmail)
9 years ago
here's my version of imagecreatefromtga() that's been tested to work for targa 16 .. adapted from offering by zehao dot chang at gmail dot com

function imagecreatefromtga($filename)
{
    $data = file_get_contents($filename);
 
    // Extract header information
    $string_length = fileint($data, 1, 1);
    $data_type = fileint($data, 2, 1);
    $width = fileint($data, 12, 2);
    $height = fileint($data, 14, 2);
    $bits_per_pixel = fileint($data, 16, 1);

    $bytes_per_pixel = (int) $bits_per_pixel / 8;
   
    // Currently only supporting RGB Data type
    switch ($data_type)        // Header information taken from http://astronomy.swin.edu.au/~pbourke/dataformats/tga/
    {
        case 2:     // Uncompressed RGB image
            break;
        case 0:     // No attached image data
        case 1:     // Uncompressed color-mapped image
        case 3:     // Uncompressed black and white image
        case 9:     // Runlength encoded color-mapped image
        case 10:    // Runlength encoded RGB image
        case 11:    // Compressed black and white image
        case 32:    // Compressed color-mapped data, using Huffman, Delta, and runlength encoding
        case 33:    // Compressed color-mapped data, using Huffman, Delta, and runlength encoding.  4-pass quadtree-type process
        default:
            return NULL;    // No support for any of these types
    }   
   
    // Compute things we need from the header information
    $pointer = 18 + $string_length;
    $x = 0;  $y = $height - 1;
  
    $image = imagecreatetruecolor($width, $height);

    while ($pointer < strlen($data))
    {
        if ($bytes_per_pixel == 2)            // TARGA 16 - ARRRRRGG GGGBBBBB
        {
            $word = fileint($data, $pointer, 2);
            $r = ($word & 0x7C00) >> 10;
            $g = ($word & 0x03E0) >> 5;
            $b = ($word & 0x001F);
            imagesetpixel($image, $x, $y, $r << 19 | $g << 11 | $b << 3);
        }
        else if ($bytes_per_pixel == 3)        // TARGA 24 - RRRRRRRR GGGGGGGG BBBBBBBB
        {
            imagesetpixel($image, $x, $y, fileint($data, $pointer, 3));
        }
        else if ($bytes_per_pixel == 4)        // TARGA 32 - AAAAAAAA RRRRRRRR GGGGGGGG BBBBBBBB
        {
            imagesetpixel($image, $x, $y, fileint($data, $pointer + 1, 3));
        }
   
        if (++$x == $width)
        {
            $y--;
            $x = 0;
        }
       $pointer += $bytes_per_pixel;
    }
 
    return $image;
}

function fileint($data, $pos, $len)
{
    return base_convert(bin2hex(strrev(substr($data, $pos, $len))), 16, 10);
}
up
1
zehao dot chang at gmail dot com
11 years ago
Here's my stab at the imagecreatefromtga function. I used code from send at mail dot 2aj dot net and others below as a basis, and added support for targa 16, targa 24 and targa 32. However, I only support uncompressed RBG data type as that's the only one I need. (I removed the return_array feature since you can simply use imagesx() and imagesy() to get the image size).

Please note that I have not tested this with a targa 16 since I don't have one handy at the moment.

<?php

function imagecreatefromtga( $filename )
{
   
$handle = fopen( $filename, 'rb' );
   
$data = fread( $handle, filesize( $filename ) );
   
fclose( $handle );
 
   
// Extract header information
   
$string_length = base_convert( bin2hex( substr($data,1,1) ), 16, 10 );
   
$data_type = base_convert( bin2hex( substr($data,2,1) ), 16, 10 );
   
$width = base_convert( bin2hex( strrev( substr($data,12,2) ) ), 16, 10 );
   
$height = base_convert( bin2hex( strrev( substr($data,14,2) ) ), 16, 10 );
   
$bits_per_pixel = base_convert( bin2hex( substr($data,16,1) ), 16, 10 );
   
   
// Currenly I'm only supporting RGB Data type
   
switch( $data_type )        // Header information taken from http://astronomy.swin.edu.au/~pbourke/dataformats/tga/
   
{
        case
2:        // Uncompressed RGB image
           
break;
        case
0:        // No attached image data
       
case 1:        // Uncompressed color-mapped image
       
case 3:        // Uncompressed black and white image
       
case 9:        // Runlength encoded color-mapped image
       
case 10:    // Runlength encoded RGB image
       
case 11:    // Compressed black and white image
       
case 32:    // Compressed color-mapped data, using Huffman, Delta, and runlength encoding
       
case 33:    // Compressed color-mapped data, using Huffman, Delta, and runlength encoding.  4-pass quadtree-type process
       
default:
            return
NULL;    // No support for any of these types
   
}   
   
   
// Compute things we need from the header information
   
$pointer = 18 + $string_length;
   
$bytes_per_pixel = (int) $bits_per_pixel/8;
   
$x = 0$y = $height;
   
   
$image = imagecreatetruecolor($width, $height);

    while (
$pointer < strlen($data) )
    {
        if(
$bytes_per_pixel == 2 )            // TARGA 16 - ARRRRRGG GGGBBBBB
       
{
           
$low_byte = bin2hex( strrev( substr($data, $pointer, $bytes_per_pixel)));
           
$high_byte = bin2hex( strrev( substr($data, $pointer, $bytes_per_pixel)));
           
$r = base_convert( ($high_byte & 0x7C)>>2, 16, 10);
           
$g = base_convert( (($high_byte & 0x03)<<3) | (($low_byte & 0xE0)>>5), 16, 10);
           
$b = base_convert( $low_byte & 0x1F, 16, 10);
           
imagesetpixel( $image, $x, $y, $r<<16 | $g<<8 | $b);
        }
        else if(
$bytes_per_pixel == 3 )    // TARGA 24 - RRRRRRRR GGGGGGGG BBBBBBBB
       
{
           
imagesetpixel( $image, $x, $y, base_convert( bin2hex( strrev( substr($data, $pointer, $bytes_per_pixel))), 16, 10));
        }
        else if(
$bytes_per_pixel == 4 )    // TARGA 32 - AAAAAAAA RRRRRRRR GGGGGGGG BBBBBBBB
       
{
           
imagesetpixel( $image, $x, $y, base_convert( bin2hex( strrev( substr($data, $pointer, $bytes_per_pixel-1))), 16, 10));
        }
           
        if(++
$x == $width)
        {
           
$y--;
           
$x=0;
        }
      
$pointer += $bytes_per_pixel;
    }
 
    return
$image;
}

?>
up
1
T. Dekker
11 years ago
In reply to weitheism at gmail.com:

You should probably have used ImageAlphaBlending($image, false); in your early attempts. This way any paint/fill operation replaces the alpha value of the destination.
up
1
bpgordon at gmail dot com
12 years ago
This code converts a block of text to an image so that each character in the block defines one pixel in the image and each line in the block (delimited by \n's) builds one whole row of pixels in the image.
Usage: Place a 0 to create a white pixel. Place a 1 to create a black pixel.
Example: Entering the following digits (including the line breaks) will create a 3x3 square with a 1-pixel white border.
00000
01110
01110
01110
00000

<?php
if (isset($_POST["sendtxt"])) {
header("Content-type: image/png");
$splitted = explode("\n", $_POST["sendtxt"]);
foreach (
$splitted as $tcurkey => $curval) $tsplitted[$tcurkey] = rtrim($curval);
$splitted = $tsplitted; //referencing isn't working for some reason...
$image = imagecreate(strlen($splitted[1]), count($splitted));
$white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF); // don't delete this line
$black = imagecolorallocate($image, 0x00, 0x00, 0x00);
foreach(
$splitted as $curkey => $opelement) {
$subsplitten = preg_split("//", $opelement);
foreach(
$subsplitten as $subcurkey => $subopelement) {
if (
$subopelement == "1" || $subopelement == ".") imagesetpixel($image, $subcurkey-1, $curkey, $black);
}
}
imagepng($image);
imagedestroy($image);
} else {
echo <<<end
<table width="1" border="0"><td>
<form method="post" action="#">
<textarea cols="30" rows="7" name="sendtxt"></textarea><br>
<input type="submit" value="render">
</form></td></table>
end; }
?>
up
1
odin<spam inside(C)>dtdm.org
13 years ago
Just a simple implementation of the Bresenham algorythm (educational purpose....)

You can find more about this and many other tutorials for gfx there: http://brand107.home.comcast.net/pc-gpe/

<?php

/****************************************************
     Bresenham Line Algorythm PHP/GD implementation 
****************************************************/
function line($im,$x1,$y1,$x2,$y2,$color){
   
   
$deltax=abs($x2-$x1);
   
$deltay=abs($y2-$y1);

    if (
$deltax>$deltay) {
    
$numpixels=$deltax+1;
    
$d=(2*$deltay)-$deltax;
    
$dinc1=$deltay << 1; $dinc2=($deltay-$deltax) << 1;
    
$xinc1=1; $xinc2=1;
    
$yinc1=0; $yinc2=1;
    } else {
    
$numpixels=$deltay+1;
    
$d=(2*$deltax)-$deltay;
    
$dinc1=$deltax << 1; $dinc2=($deltax-$deltay)<<1;
    
$xinc1=0; $xinc2=1;
    
$yinc1=1; $yinc2=1;
    }

    if (
$x1>$x2) {
    
$xinc1=-$xinc1;
    
$xinc2=-$xinc2;
    }

    if (
$y1>$y2) {
    
$yinc1=-$yinc1;
    
$yinc2=-$yinc2;
    }
   
$x=$x1;
   
$y=$y1;

    for (
$i=0;$i<$numpixels;$i++) {
    
imagesetpixel($im,$x,$y,$color);
     if (
$d<0) {
     
$d+=$dinc1;
     
$x+=$xinc1;
     
$y+=$yinc1;
     } else {
     
$d+=$dinc2;
     
$x+=$xinc2;
     
$y+=$yinc2;
     }
    }
return ;
}

?>
up
1
dino at nordmark dot dk
15 years ago
The example above diden't work, because of some errors.
This should work and it's also faster because there is only one 512*512 loop. (but it is still very slow)

<?
$filename
="lena.raw";
$width=512;
$height=512;
$fp=fopen($filename, "r");
$contents=fread($fp,filesize($filename));
fclose($fp);

$image=imagecreate($width,$height);

// create greyscale palette because the image is limited to 256 colors
for ($i=0;$i<256;$i++){ ImageColorAllocate($image,$i,$i,$i);}

// This is slow, but probably the only way
for ($i=0;$i<512;$i++){
   for (
$j=0;$j<512;$j++){   
  
imagesetpixel ($image,$i,$j,ord($contents[$i+$j*512]));
   }
}

imagepng($image,"result.png");
imagedestroy($image);

echo
"<img src=result.png></img>";
?>

--

Dino Patti
up
0
Scott Evernden (doctor3d at gmail)
8 years ago
Re: imagecreatefromtga() .. I just did some testing with what I think are valid Targa-24 and Targa-32 bit images, and modified the inner logic as follows:

<?php
       
if ($bytes_per_pixel == 2)            // TARGA 16 - ARRRRRGG GGGBBBBB
       
{
           
$word = fileint($data, $pointer, 2);
           
$r = ($word & 0x7C00) >> 7;
           
$g = ($word & 0x03E0) >> 2;
           
$b = ($word & 0x001F) << 3;
           
$a = ($word & 0x8000) ? 127 : 0;
           
$color = imagecolorallocatealpha($image, $r, $g, $b, $a);
           
imagesetpixel($image, $x, $y, $color);         }
        else if (
$bytes_per_pixel == 3)        // TARGA 24 - BBBBBBBB GGGGGGGG RRRRRRRR
       
{
           
$r = fileint($data, $pointer, 1);
           
$b = fileint($data, $pointer+1, 1);
           
$g = fileint($data, $pointer+2, 1);
           
$color = imagecolorallocate($image, $r, $g, $b);
           
imagesetpixel($image, $x, $y, $color);
        }
        else if (
$bytes_per_pixel == 4)        // TARGA 32 - BBBBBBBB GGGGGGGG RRRRRRRR AAAAAAAA
       
{
           
$b = fileint($data, $pointer, 1);
           
$g = fileint($data, $pointer+1, 1);
           
$r = fileint($data, $pointer+2, 1);
           
$a = (255 - fileint($data, $pointer+3, 1)) >> 1;
           
$color = imagecolorallocatealpha($image, $r, $g, $b, $a);
           
imagesetpixel($image, $x, $y, $color);
        }
?>
't work,e red span>fileint
strrev( down
35767="Vd87763"> down
35767="Vd87763"> 0
<35767ttt Evernden (doctor3d at gmail)
stronu15 years ago
Re: im14gecreatefromtga() .. I just did some testing with what35767tp= are valid Targa-24 and Targa-32 bit images, an class="default">strrenbsp;  Bresenham Line Algorythm PHP/GD implemeesenhaAny one 512/GDbin10
ill verpan>strreH>);
$splitted = explode;
$image= class="keyword">;
$image= class=">($image$height);

// creat>?> ($image$height);

// crean class="default">imagepng&nt>?> imagepng&n />($image$i,?> <=ass="keyword">[=ass="keyword">[= />($image$i,?> <=ass="keyword">[=ass="keyword">[= />$i=forss="keyword">+$imass="keyword">[=="default">imagesetpixel $im"keyword">++){ ImageColorAllocate($im">0$image, pan>$i,?> $imt>?> $imt>?> $imdefault">0for ($i($y[/efault">$i,=ass="keyword">[= />+$imass="keyword">[=="default">imagesetpixel $im"keyword">++){ = cn>($im">0$image, $efault">$fp["r", deg2rfault">filesize($imn class="default">imagepng= class="keyword">;
  ult">$y
++){ =) )ord">);
            ;
 12an>= ($image, $col_arbr />*$im]br />return ;
}

0for forss="keyword">+
$i=="default">imagesetpixel ++) {
 e image is limited to 256 colorsimagesetpixel 0$forss="keyword">+$y==="default">imagesetpixel ++) {
 span>// crea="default">imagesetpixel 0$image, $imgAGG RRRRRRRR AAAAAAAA
&nword">*
*return ;
}

*0for n>for forss="keyword">+
$i=="default">imagesetpixel ++) {
 e image is limited to 256 colorsimagesetpixel 0$forss="keyword">+$y==="default">imagesetpixel ++) {
 span>// crea="default">imagesetpixel 0$image, $imgBGG RRRRRRRR AAAAAAAA
&nword">*
*return ;
}

*0for n>for (
$i=forss="keyword">+$i=="default">imagesetpixel ++) {
 e image is limited to 256 colorsimagesetpixel 0$forss="keyword">+$y==="default">imagesetpixel ++) {
 span>// crea="default">imagesetpixel 0$image, $imgCGG RRRRRRRR AAAAAAAA
&nword">*
*return ;
}

&nword">*
*]));
   }imgBGG RRRRRRRR AAAAAAAA
&nword">*
*$image, $"default">1;
   &imgCGG RRRRRRRR AAAAAAAA
&nword">*
*++){ +=$yinc2$image, pan>< class="default">$x
, *);
     if (
$d10for n>for (
$i($x
, ?> <"deAGG RRRRRRRR AAAAAAAA
&nt>?> <=a>?> <=a>?> <=a>?> <=a>?> // crean class="default">imagepng&nt>?> imagepng&na>?> // creaa>?> // crea />($x, ( down
9322e="Vd87763"> down
9322e="Vd87763"> 0
<9322ethis...">en (doctor3d at gmail)-ng>
9189="Vd87763"> 0 <89189this...">en (doctor3d at gmail)-ng>
Re: imagecreatefromtga() .. I just did some testing with what89189tp= are valid Targa-24 and Targa-32 bit images, anSorryakeywr />l/a> ;0);lt">$i00000000pan>< it wis=adraw pan>< wis=abe modified;wr /re/is no return vapue.eault">00000span vapues/spadraw 00000Lass= spadraw r />Plot.eault">00Maanpart, becaill $xtend $yaault">0000Plotblt [253.643891, 482]s/span>0Plotwr /re. Exactblt td">spn>00ill or3d spamaoctsmooth (dnhs.eault">00spn>000000Math Gebr trie now.aAnd aswr />on="nCompugerfreakeault">00ord">,it be, spamirreyw
0000=0000SHORTEST way/spatd">Ldnhs/span>0( swortsmooth.eault">00or /r ways/spadraw anuals.eault">00=00pan>< Resourceeault">0);lass="defauan>< s="default">$dinc2, 't work,e red span>+=a>?> <48= efault">00);lt">$i0);
ass="blendan esp; 
);
$y
, = efault">0);
saveass="default">$r, $g, = efault">00);lt">$i0);
fis=edrectangl"default">$r, $g, =a>?> <=a>?> <64=a>?> <48=a>?> $r, $g, $r $r 00);lt">$i0);bsp; +$dinc2==yword">, $dinc2=pan class="keyword">);
$dinc2
$dinc2);
= ($dinc2$dinc2;$r, );
= (
$r, $g, =a>?> <=a>?> <=a>?> $color);
        }
000
);nbsp; &nbh>);
$splitted = explode0
);
pn esp; 
);
$y
00?> $r);
$y
, filesize, filesize, filesize, $color);
  &nbsf _p;     }
$image$data 't work,e red span>+$color0);
$image$data=p/span>0);
$image$data 't work,e red span>+0);
$image$data=p/span>0$image$im*an class="keyword">);
= ();
$image
$im*an class="keyword">);
= (/span>);
$image$im*an class="keyword">);
= ();
$image$im*an class="keyword">);
= ();
$image$im*an class="keyword">);
=p/span>$image$im*an class="keyword">);
=p/span>0$dinc2 't work,e red span>+$color0$data 't work,e red span>+00
+$y, $color);
  &nbsf _p;     }
?> $r, $y, filesize, filesize, filesize,="keyword">);
$data
0+$y, $dinc2);
$r ?> $r, $y, filesize, filesize, filesize,="keyword">);
$data
0+$y, $dinc2);
$r $dinc2);
$r $r, $y, filesize, filesize, filesize,="keyword">);
$data
=ddefault">0+$y, $r $dinc2);
$r $r, $y, filesize, filesize, filesize,="keyword">);
$data
=ddefault">00ault"Haven> >;Dadown
7651="Vd87763"> down
7651="Vd87763"> 0 <87651this...">en (doctor3d at gmail)-ng>
Re: imagecreatefromtga() .. I just did some testing with what87651tp= are valid Targa-24 and Targa-32 bit images, an@ Scott Ev/didenuspan>/span>Scott, youraf workatg theakeyw ompressed TGA= ( sworsakeywTGA=32> ts.aIf td">ass=" iatell whie ,ttd">( swor10( d">( swor10ass=", but that2would>bp handy atadown
4479="Vd87763"> down
4479="Vd87763"> 0 <84479this...">en (doctor3d at gmail)-ng>
Re: im9gecreatefromtga() .. I just did some testing with what84479tp= are valid Targa-24 and Targa-32 bit images, anTr3d snippet d the swa gradientb vapue verRGB cbrponents.aGradientatellow youra7763/spahavena sha="# effect.eault";=try0$y$color span>< the truer /> 't work,e red span>+filesize,="keyword">);
filesize
+ 't work,e red span>+$i=="default">imagesetpixel ++) {
 10alt">filesize
, 0000, 't work,e red span>$color span>$r, $g, +imagepng,="keyword">);
+
imagepng,="keyword">);
+
imagepng=ddefault">0+$i=="default">imagesetpixel ++) {
 50alt">filesize
, $color0
00+$g, $color);
     if (
$d 't work,e red span>0
't work,e redlt">$i);= "result.png");
$g
, <$i
"<img src=result.png></img&"default">$y0$y, $y d">, $y0for (down
74488="Vd87763"> down
74488="Vd87763"> 0 <74488this...">en (doctor3d at gmail)-ng>
Re: im10gecreatefromtga() .. I just did some testing with what74488tp= are valid Targa-24 and Targa-32 bit images, anTr3d d Ta bp good/spadefine f);< verpan cs- more f);an na.raw";$r, $y 't work,e redlt">$iizl or3d spaseen
for (
$datafilesize 't work,e redlt">$ifor ($imagefilesize 't work,e redlt">$ifor ($imagpan class="default">$x<60alt">filesize0, $ifor ($image$im/efilesizefor ($image$im/efor ($imagefilesizefor ($image, 't work,e red span>+$im"default">$d$imdefault"keyword">;$dinc2==yword">, $dinc2$im=yword">, $dinc2 't work,e redlt">$i 't work,e red class="def_polss="default">$dinc2, $colorfilesizefor 't work,e redlt">$i0( deault">0greenuault">0>0 't work,e red class="dergb_polalt">filesize*=] span>, $r, filesize;filesizefilesize;$im+an class="keyword">);
=ddefault">0 't work,e red class="dergb_polalt">filesize*, $r, filesize;filesizefilesize;$im+an class="keyword">);
=ddefault">0 't work,e red class="dergb_polalt">filesize*+=, $r, filesize;filesizefilesize;$im+an class="keyword">);
=ddefault">0 't work,e redlt">$i0 't work,e red class="dergb_r /an>$y*=] span>, $data);
$data
);
filesize
*=]efault">0 't work,e red class="dergb_r /an>$y*, $data);
$data
);
filesize
*0 't work,e red class="dergb_r /an>$y*+=, $data);
$data
);
filesize
*+=$i0 't work,e reds="defaulkeyword">;$dinc2==an class="keyword">);
$dinc2
$im=an class="keyword">);
$dinc2
't work,e redlt">$i0 't work,e red class="dey_polss="default">$dinc2$x$data
;$colorfilesize);
+=
*=] span>, $y*=] laefilesize0 't work,e red class="dergb_ouge is limited to 256 colors*, $y*filesize0 't work,e red class="dergb_ouge is limited to 256 colors*+=, $y*+=filesize/span> 't work,e redlt">$i0 't work,e reds="defaulkeyeach;img src=result.png></imergb_ouga/span> 't work,e reds="defaulalss="default">$dinc2$dinc2$dinc2$y0;$dinc2$dinc20 't work,e red class="dergb_ouge is limited to 256 colors*+=, for pan clan>;$dinc2=d0 't work,e red class="dergb_ouge is limited to 256 colors*+=, filesizefor pan clan> 't work,e redlt">$i0 't work,e red class="der /ss="default">$dinc2, $r, );
*
=]an class="keyword">);
*
);
*
+=0+);
$color
);
     if (
$d=default">0for ($ifor ("result.png");
$d 't work,e red span>,
< 't work,e red span>for (down
56249="Vd87763"> down
56249="Vd87763"> 0 <56249this...">en (doctor3d at gmail)-ng>
Re: im12gecreatefromtga() .. I just did some testing with what56249tp= are valid Targa-24 and Targa-32 bit images, anI looked,wcodymsrk that2contained>ass=" trans776ency.aSo r />followia>
maan ="def,wcodymsrk ass=" "/me10ass="-trans776ent>wcodymsrk largera ;=div c (={/span>/span>?> =(a/span> 't work,e red class="dedst_amgnbsp; if ($image$imda0 't work,e red class="deass="0 't work,e reds="defaul/age 't work,e red span> 't work,e redlt">$i/span>0 't work,e red class="dedst_amg_w0 't work,e reds="defaulspan>, sfault">$color 't work,e red class="dedst_amgspan>$imd;">for pan clan>0 't work,e red class="dedst_amg_h0 't work,e reds="defaulspan>, sspan>"<a/span> 't work,e red class="dedst_amgspan>$imd;">for pan clan>0 't work,e red class="dewcodymsrk_amg_w0 't work,e reds="defaulspan>, sfault">$color 't work,e red class="dewcodymsrk_amgspan>$imd;">for pan clan>0 't work,e red class="dewcodymsrk_amg_h0 't work,e reds="defaulspan>, sspan>"<a/span> 't work,e red class="dewcodymsrk_amgspan>$imd;">for pan clan>0for pan clan>0 't work,e redlt">$i0 't work,e reds="defaulspan>, d the truer /> 't work,e red span> 't work,e red class="dedst_amg_wnbsp; if ($imd;">for /span> 't work,e redlt">$i00d the ( edst_amg_w, sdst_amg_hsd;">for pan clan>0for pan clan>0$inhe s">for pan clan>0 't work,e red class="dedst_amg_min_x0 't work,e reds="defaulspan>, 't work,e red span> 't work,e red class="dedst_amg_wa/span> 't work,e reds="defaul/pan>, $imda- sa/span> 't work,e red class="dewcodymsrk_amg_wa/span> 't work,e reds="defaul/pan>, $imdad;">for pan clan>0 't work,e red class="dedst_amg_max_x0 't work,e reds="defaulspan>, 't work,e red span> 't work,e red class="dedst_amg_wa/span> 't work,e reds="defaul/pan>, $imda+ sa/span> 't work,e red class="dewcodymsrk_amg_wa/span> 't work,e reds="defaul/pan>, $imdad;">for pan clan>0 't work,e red class="dedst_amg_min_y0 't work,e reds="defaulspan>, 't work,e red span> 't work,e red class="dedst_amg_hspan>$im/pan>, $imda- sa/span> 't work,e red class="dewcodymsrk_amg_hspan>$im/pan>, $imdad;">for pan clan>0 't work,e red class="dedst_amg_max_y0 't work,e reds="defaulspan>, 't work,e red span> 't work,e red class="dedst_amg_hspan>$im/pan>, $imda+ sa/span> 't work,e red class="dewcodymsrk_amg_hspan>$im/pan>, $imdad;">for pan clan>0for pan clan>0 't work,e redlt">$imaan ="def/>for pan clan>0 't work,e reds="defaulkeysa/span> 't work,e red class="deyss="default">$dinc2==an class="keyword">);
$dinc2
==an class="keyword">);
=++ da0 't work,e red class="depss="default">$dinc2==yword">, $dinc2, =++ da00 't work,e red class="dereturn_r /><0 't work,e reds="defaulspan>, 0000 't work,e redlt">$icorrect anual lass= withan ourawcodymsrkespan>00 't work,e red class="dewcodymsrk_x0 't work,e reds="defaulspan>, $dinc200 't work,e red class="dewcodymsrk_y0 't work,e reds="defaulspan>, $dinc2==/span>0000 't work,e redlt">$i00 't work,e red class="dedst_rgba/span> 't work,e reds="defaulspan>, dan cskeyindefault">$color 't work,e red class="dedst_amgnbsp; if ($r 't work,e red class="dedst_amgnbsp; if ($r $dinc2for pan clan>0000 't work,e redlt">$ivapue at or3d anual i="krse 00boundssverr />wcodymsrk 00 't work,e redspan>0 't work,e red class="dewcodymsrk_xss="default">$dinc2$dinc2 't work,e red class="dewcodymsrk_xss="default">$dinc2 't work,e reds="defaulsvotesvote/span>0000 't work,e red class="dewcodymsrk_yss="default">$dinc2$dinc2 't work,e red class="dewcodymsrk_yss="default">$dinc2$imda000 't work,e red class="dewcodymsrk_rbgspan>$imagedan cskeyindefault">$color 't work,e red class="dewcodymsrk_amgnbsp; if ($r 't work,e red class="dewcodymsrk_amgnbsp; if ($dinc2for pan clan>000000 't work,e redlt">$iass=",2calculhe baver/sp/span>000 't work,e red class="dewcodymsrk_ass="0 't work,e reds="defaulage 't work,e red span> 't work,e red class="d12a="default">$data$data*, $data$imd;">for pan clan>000 't work,e red class="dewcodymsrk_ass="0 't work,e reds="defaulage);
$r
for pan clan>00000 't work,e redlt">$icon cs'aver/sp' between r />two - tak10specified>ass=" leval/ault"000 't work,e red class="deavg_rea0 't work,e redspan>$data d">, 't work,e red span> 't work,e red class="dedst_rgb"default">$data* 't work,e red span>00 't work,e red class="dewcodymsrk_rbg"default">$data* 't work,e red span>00 't work,e red class="dewcodymsrk_ass="a/span> 't work,e reds="defauld;">for pan clan>000 't work,e red class="deavg_green>0 't work,e redspan>$data d">, 't work,e red span> 't work,e red class="dedst_rgb"default">$data* 't work,e red span>0 't work,e red class="dewcodymsrk_rbg"default">$data* 't work,e red span>0 't work,e red class="dewcodymsrk_ass="a/span> 't work,e reds="defauld;">for pan clan>000 't work,e red class="deavg_>0 't work,e redspan>$data d">, 't work,e red span> 't work,e red class="dedst_rgb"default">$data* 't work,e red span>0 't work,e red class="dewcodymsrk_rbg"default">$data* 't work,e red span>00 't work,e red class="dewcodymsrk_ass="a/span> 't work,e reds="defauld;">for pan clan>000000 't work,e redlt">$ivapue us10aver/sprRGB vapues we've2deodymined">for pan clan>000 't work,e red class="dereturn_r /><0 't work,e reds="defaulspan>, $data d">, 't work,e red span> 't work,e red class="dereturn_amgnbsp; if (filesize, for pan clan>00000 't work,e redlt">$iaver/sprpan csher ,ttd"n let's just copymaan r />00 't work,e redspan>000 't work,e red class="dereturn_r /><0 't work,e reds="defaulspan>, $r 't work,e red class="dedst_amgnbsp; if ($r $dinc2for pan clan>00000 't work,e redlt">$i/span>00approprihe bpan csonto td">( turn 00 't work,e redord">, s/manual/span> 't work,e red span> 't work,e red class="dereturn_amgnbsp; if ($r $r $dinc2for /span>0 't work,e redlt">$i0 't work,e redspan> 't work,e redlt">$i0for pan clan>0( swor10<, wcodymsrked= 0 't work,e redspan> 't work,e red class="dereturn_amgnbsp; if (for /span> 't work,e redlt">$iaver/sprtwo dan cs giv"n an>ass="/span>0 't work,e reds="defaulk
?> 't work,e red span> 't work,e red class="der /><_"default">$r
$r <_b"default">$data$imda0 't work,e red class="dround/span> 't work,e red span> 't work,e red class="der /><_"a/span> 't work,e reds="defaul*a=a/span> 't work,e red class="d1="default">$data$imdada+ sa/span> 't work,e red class="der /><_b0 't work,e reds="defaul*an class="keyword">);
$imdadad;">for pan clan> 't work,e redlt">$i<()fault"( turn closest pallette-r />0 't work,e reds="defaulk
?> < 't work,e red span>);
$data0 't work,e red class="dec/span> 't work,e reds="defaulsan>, $r, 't work,e red class="dernbsp; if ($datafor pan clan>0;$data$x 't work,e red class="dur"default">$datafor pan clan>0 't work,e red class="dec/span> 't work,e reds="defaulsan>, $r, 't work,e red class="dernbsp; if ($datafor pan clan>0;$data$x 't work,e red class="dur"default">$datafor pan clan>0 't work,e red class="dspan>$r, 't work,e red class="dernbsp; if ($datafor pan clan> 't work,e redlt">$i<(na.raw"span> 't work,e redspan> 't work,e redlt">$ifor (down
55607="Vd87763"> down
55607="Vd87763"> 0
<55607this...">en (doctor3d at gmail)-ng>
Re: im12gecreatefromtga() .. I just did some testing with what55607tp= are valid Targa-24 and Targa-32 bit images, anI walslook10wcy to actuss=" DELETE anuals eywsquares eyw776tssveranb trick. Unkeytunhe ly,wcy verdelet10take care verdelet10deleteRectangle(/vote$oldI"def,$leftX,$leftY,$rlassX,$rlassY)fault"0wcy verdeletew776tssver 0 doly to abnew/span>0for pan clan>0for pan clan>0sx($oldI"defd;">for pan clan>0sy($oldI"defd;">for pan clan>00 for pan clan>0= array(d;">for pan clan>0= array(0,0,$leftX,$ySizld;">for pan clan>0= array($leftX,0,$rlassX+1,$leftYd;">for pan clan>0= array($leftX,$rlassY+1,$rlassX+1,$ySizld;">for pan clan>0= array($rlassX+1,0,$xSizl,$ySizld;">for pan clan>00new, copied= for pan clan>0d the truer /><($xSizl,$ySizld;">for pan clan>0for pan clan>0for pan clan>00background " trans776ent r />0dspan class="ass="($newI"def,255,255,255,127d;">for pan clan>0for pan clan>00foura 0dspyresne 51d($newI"def,$oldI"def,a$href="/ for pan clan>00each anual i=ranb a th/span>0bd 3oreai="kesivp">for pan clan>0for pan clan>00old new, clcreed= for pan clan>0for pan clan>trans776ent background i=rmind,easilyrrhanf= that2byrrhanf=10cod= that2deals down
45043="Vd87763"> down
45043="Vd87763"> 0 <45043this...">en (doctor3d at gmail)-ng>
Re: im13gecreatefromtga() .. I just did some testing with what45043tp= are valid Targa-24 and Targa-32 bit images, anHereaiswa k that2takes anb contrast maximised ateault";=f ?> $r, $data, $datafor pan clan>$data, $datafor pan clan>$data, for pan clan>, $data, $data, for pan clan>, , $data*=]efault">0, =san>, $data*00;, $data;, , =++da0;, $data;, ==an class="keyword">);
=++da0 't work,e red class="dergb"default">$data, $r, 't work,e red class="defsp;       $r for pan clan>0 't work,e red class="dergb"default">$data, $color, 't work,e red class="dergb"default">$datafor pan clan>0 't work,e red class="degr=">+=, 't work,e red class="dergb"default">$data* 't work,e red span>00 't work,e redord">, 't work,e red class="dergb"default">$data* 't work,e red span>00 't work,e redord">, 't work,e red class="dergb"default">$data* 't work,e red span>0$data, +=for pan clan>0;+= d">, $data$data, +=for pan clan>0;+=, $data$data, +=for pan clan>0 't work,e red"keyword"sbrlassnesd"default">$data, $data;=d;">for pan clan>, $data, $data;$data$x$datafor pan clan>$data;$x$data;$data$x$datafor pan clan>$r, $color, $data 't work,e red class="demaxb"default">$data00;, $data;, , =++da0;, $data;, ==an class="keyword">);
=++da0 't work,e red class="dergb"d;       , $r, 't work,e red class="defsp;       $r for pan clan>0 't work,e red class="dergb"default">$data, $color, 't work,e red class="dergb"d;       for pan clan>0 't work,e red class="dspan>s/manual/span> 't work,e red span>, 't work,e red class="defsp;       $r 00 't work,e redord">, 't work,e red class="dflo> 't work,e red span>, $color, $data* 't work,e red span> 't work,e red class="dedontrastdefault">$r00 't work,e redord">, 't work,e red class="dflo> 't work,e red span>, $color, $data* 't work,e red span> 't work,e red class="dedontrastdefault">$r00 't work,e redord">, 't work,e red span>, $color, $data* 't work,e red span> 't work,e red class="dedontrastdefault">$rfor pan clan>0, for }a.raw", ;$data>+=for "keyword">, $data, < the fromjpegnbsp; if (, $datafor /span> 't work,e redspan classim/sp"default">$data, $r, $datafor /span> 't work,e redspan clasim/spjpegnbsp; if (, $r $datafor /span> 't work,e redspan clas="Vu21dowadd>
dowen/> add@2x.png' alt='addwa note' width='12' helass='12'> addwa noteef/mall>> >