Thanks Danny, that does the trick nicely.<br><br>Cheers,<br><br>Kieron.<br><br><div class="gmail_quote">On Mon, Sep 10, 2012 at 2:00 PM, Danny Yoo <span dir="ltr"><<a href="mailto:dyoo@hashcollision.org" target="_blank">dyoo@hashcollision.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">> I see the function read-icos in file/ico, and also the function ico->argb<br>
> which gives a bytes? that represents an argb image, but I can't figure out<br>
> how to get from a bytes? to an actual argb?.<br>
<br>
</div>Hi Kieron,<br>
<br>
An argb has a vector that we can probably mutate. It also holds width<br>
and height, so we need to preserve those too...<br>
<br>
Hmm. Something VERY strange is happening with the alphas being<br>
produced by ico->argb vs the alphas expected by the bitmap functions.<br>
They seem... flipped!<br>
<br>
Here's source that should do the trick for you, but I'm confused about<br>
what's going on with the alpha transparency stuff:<br>
<br>
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<br>
#lang racket/base<br>
<br>
(require file/ico)<br>
(require mrlib/cache-image-snip)<br>
<br>
(define (ico->bitmap x)<br>
(define argb-bytes (ico->argb x))<br>
(argb->bitmap<br>
(make-argb (for/vector ([b argb-bytes]<br>
[i (in-naturals)])<br>
(if (= (remainder i 4) 0)<br>
(- 255 b)<br>
b))<br>
(ico-width x)<br>
(ico-height x))))<br>
<br>
<br>
<br>
;; For example<br>
;;(map (lambda (x) (ico->bitmap x))<br>
;; (read-icos "001_01.ico"))<br>
<br>
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<br>
<br>
<br>
<br>
Good luck!<br>
</blockquote></div><br>