Well I am using the image functions to draw pixels on an image file using PHP. The problem is that when for instance I draw a black pixel and right next to it a white pixel and than again a black pixel the white pixel will get faded! It will go grey or something. I really want precision!

It would help if you'd show your code. :)

It would help if you'd show your code. :)

well I guess something like that...

<?php 
$x=0;
while($x<300)
{
imageline($img,$x,0,$x,50,$red);
$x=$x+2;
}
?>

assume that I have already got img and $red color

Assuming that you are correctly displaying a white pixel, you might be pushing the limits of the monitor or more likely the human eye. You may need something larger than a single pixel in order to have the color clearly distinguished. I'm not a physics expert but remember than a monitor creates (the illusion of) a whole variety of colors through combinations of red, green and blue dots. The human eye interprets the different combinations as other colors instead of red, green and blue. If you make the dots much bigger, then you start to see them as the three prime colors again. With a white pixel (actually red, green and blue) on a black background, the eye is probably doing some interpretation. If you were to use a magnifying glass to look at the pixel, it might then appear to be more white than gray.

I just tried the code like you posted and I can't reproduce your problem apart from a little JPEG-encoding (~1 fluctuation e.g. 255 -> 254).
Maybe your screen is playing tricks on you?

What I did exactly was to compare every pixel r,b,g and if it was above 100 I would turn it into a white, and if it was below or equal to 100 i would turn it into black. Now when I displayed the image I could see something like noise on some parts of the image,pixels that were something in between black and white. I saved the image from browser, I opened photoshop I focused in, I clearly saw that these pixels were neither black nor white, I took the "color copier" tool, I selected the pixels and they were grey. No illusions at all!

It' seems the php is interpolating the image, is the colour in photoshop #808080?
We all can't seem to re-create your problem, but maybe check your php file-system/ini file

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.