You are here: Re: do I use fopen or fsockopen to get an image as a stream of bytes? « PHP Programming Language « IT news, forums, messages
Re: do I use fopen or fsockopen to get an image as a stream of bytes?

Posted by lkrubner on 11/04/05 22:31

Andy Hassall wrote:
> On 4 Nov 2005 11:42:47 -0800, lkrubner@geocities.com wrote:
> >echo "<p>the height is $height and the width is $width </p>";
> >for ($i=0; $i < $width; $i++) {
> > for ($r=0; $r < $height; $r++) {
> > $rgb = imagecolorat($image, $i, $r);
> > echo $rgb;
> > echo "<br>";
> > }
> >}
> >
> >which gave me something like this:
> >
> >16645629
> >16711422
> [snip]
> >but a lot more of that.
>
> Good, that's what you asked for. All you need to do now is read the
> imagecolorat manual page a bit more closely and convert it into the hex
> representation you wanted (sprintf and %x is useful here), and you're done.

Yes, your solution was nearly perfect. I suppose to get it into hex i
do something like this:

for ($i=0; $i < $width; $i++) {
for ($r=0; $r < $height; $r++) {
$rgb = imagecolorat($image, $i, $r);
$format = "%x";
$byteCode = sprintf($format, $rgb);
$imageAsBytesAsString .= $byteCode;
}
}

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация