Re: Hex Help Please...

From: Date: Mon, 22 Jul 2002 08:37:29 +0000
Subject: Re: Hex Help Please...
References: 1  Groups: php.db php.general 
Request: Send a blank email to php-general+get-108782@lists.php.net to get a copy of this message
OK, i thought I found my solution but... How come if I convert from "1000" from Binary to Hex in calculator, it returns 8, but when I use the PHP bin2hex function, it returns loads of 3s and 0s???? "Georgie Casey" <webmaster@filmfind.tv> wrote in message news:20020722001821.54678.qmail@pb1.pair.com... > Rite, > > There's a PHP script that takes a monochrome BMP and converts it into some > sort of hex code and I've noticed some patterns with this code. This image > is 72 pixels wide by 14 high so there's 1008 pixels. In the code returned, > theres 252 chars, which is 1008 divided by 4. > > So I guessed the image is split into 4 pixels each. So if I pass an image > with the first pixel black and everyhting else white, it returns 8 for those > 4. If I pass an image with the first and second black, it returns c. > > With the first three black, it returns e. With the first 4, f. And if I have > the 5th pixel black it goes onto the next char code, eg returning f for the > first 4 pixels, then 8 for the 5th pixel black, ie the first pixel in the > next 4. In total it returns f8. > > PS > I tried reading in each pixel of the script, checking if it was black or > white, 1 for black, 0 for white. Then converting these 0s and 1s from > decimal to hex, then converting from binary to hex, but to no avail. Then I > tried taking a set of 4 1s or 0s and converting them, but still no luck. > > So my questions is, does anyone know how theyre encoding the image???? I > could probably could decipher the coding with some experimentation but it > really looks like hex and I might be wasting my time. > > TIA > > > > > >

« previous php.general (#108782) next »