|
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]
|