[REBOL] Re: Compressing image data (bugs?)
From: henrik:webz:dk at: 4-Dec-2003 15:18
Henrik Mikael Kristensen wrote:
> Hi, all
>
> Sometimes image handling baffles me a bit. I want to embed a small
> 2-colored image in the script for use in a button. It would of course be
> nice to compress it to a chunk of binary data.
>
> However, I always lose the size of the image when doing something with
> it, which is highly impractical. If I have:
>
> >> img: make image! [16x14 #{
> FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000000FFFFFF
> FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF... etc.
>
> or
>
> >> img: load %image.gif
>
> and:
>
> >> to-image decompress compress img
>
> the size is lost, but the binary information remains.
>
> So in order to keep size information, I would have to:
>
> >> img-data: to-binary decompress #{
> 789CAD90410A003008C3FCFFA7DD6583516CD5CDDC94A688EE1CDB8888E4C5BF
> F3E8675D515ECD915BF1B1C3808A7FF6B8EBF88C8EFF7BFFC4FFB23C9B5987F2
> 959BDDD3A5E22F920B1DFF80030000
> }
>
> >> img2: make image! [16x14 img-data]
>
> But, img2 contains just 2 bytes set, and they are random, for each time
> I set img2 by the above line. The remaining bytes are zero. It looks
> like a bug?
Sorry, that's a blunder from my side. Of course I should use:
>> img2: make image! reduce [16x14 img-data]
Then it works...
Still, I'd like to know if there's an easier way to contain the image
size with the data.
Regards,
Henrik Mikael Kristensen