Sorry for the long intro of my function, but i just want to tell how it works and - how silly sometimes the ideas are to make such functions. Have fun ;D

<?php

//@FunctionName: drawPlot //@Parameters: drawPlot(img &$image, int $red, int $green, int $blue, int $x, int $y) // // img $image // The Image it will draw on. The Image will be modified; there is no return value. // // int $red, int $green, int $blue // The Colorvalues to draw with // // int $x, int $y // The Location to draw the Plot. // And this is the Mainpart, because $x and $y // NEED NOT be rounded! // If you want to make a Plot at [253.643891, 482]; // It will draw the Plot there. Exact at the Coordinates. // You could use this to make smooth lines. // They have rational Coordinates, too. // //@Author: Alexander Rath (*Feb 9th, 1996 ; 13 Years old) // //@Idea: We have in Math Geometrie now. And as the only Computerfreak // In the class, i asked me: "How would it be, to mirror something // At a NOT FLAT LINE." // So I started thinking about it. First i tought about degresses - Nah! // Then i saw: // A point to mirror, has the SHORTEST way to the Line; // so i just needed to make the result smooth. // Unlike the other ways to draw pixels. // ~I started developing this: // PS: Sorry for bad english ( I am german )

Scott, your function works great for uncompressed TGA image files, except the results for TGA 32 with alpha don't come out right, at least in my tests. If the alpha is all white, the resulting image comes out with a red tint. If black, the resulting image has a blue tint. I don't know how to make it just ignore the alpha, but that would be handy...

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.

I looked, but was unable to find any example code to watermark an image with a watermark that contained alpha transparency. So the following class does just that. As a parameter, it takes 2 image objects: the main image, and the watermark image (which can be a gif, png, whatever) - and optionally, an alpha setting (0-100% alpha for the watermark image). It then creates and returns a new image with the alpha-transparent watermark imposed, center-aligned, over the larger image.

I was looking for a way to actually DELETE pixels or squares or parts of an image from an image resource, and at first I thought imagesetpixel would do the trick. Unfortunately, it merely paints over that one pixel, and as far as I knew, php didn't have any native way of deleting sections out of your image - so this little method should take care of deleting rectangular parts of your pictures!

function deleteRectangle(&$oldImage,$leftX,$leftY,$rightX,$rightY) { // Since php has no native way of delete parts of images // We have to divide the image into four different parts and then copy them manually to a new // image

// Copies each of the four imagesections into their respective old positions for($i = 0;$i<count($imagesection);$i++)imagecopyresampled($newImage,$oldImage, $imagesection[$i][0],$imagesection[$i][1], $imagesection[$i][0],$imagesection[$i][1], $imagesection[$i][2]-$imagesection[$i][0], $imagesection[$i][3]-$imagesection[$i][1], $imagesection[$i][2]-$imagesection[$i][0], $imagesection[$i][3]-$imagesection[$i][1]);

// Alternately you can cycle through each pixel in an image and see if that pixel is an the area // but that could be more intensive imagedestroy($oldImage);

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.

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.0000001110011100111000000