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/05/05 00:02

Andy Hassall wrote:
> On 4 Nov 2005 12:31:18 -0800, lkrubner@geocities.com wrote:
>
> >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;
> > }
> >}
>
> Yep. You probably want zero-padding on the hex, depends on the requirements
> for your Postscript format (I have no idea about Postscript).
>
> You've also got the image rotated 90 degrees because of your loops - $i and $r
> would be clearer as $x and $y, in which case you'd probably have already
> spotted it.
>
> Here's the code expanded to convert images into HTML coloured text (and it
> deals with both paletted and true colour images):

When you say true color, I assume you mean 24 bit and 32 bit colors,
where each pixels has an "r" and a "g" and "b" value?

"paletted colour" would be what? Anything less that 24 bit? Or
something like a Gif, where the image creates chooses the palette of
colors that will be allowed into an image?

 

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

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