[racket] Using *.ico files

From: Kieron Hardy (kieron.hardy at gmail.com)
Date: Mon Sep 10 15:23:11 EDT 2012

Hi all,

Does anyone know how to easily go from a *.ico file (maybe Windows only) to
a bitmap% or something else I can use in program?

I see the function read-icos in file/ico, and also the function ico->argb
which gives a bytes? that represents an argb image, but I can't figure out
how to get from a bytes? to an actual argb?.

Cheers,

Kieron

****

#lang racket/base

(require file/ico)

(read-icos "icons\\an-icon-file.ico")

(map
  (lambda (x)
    (printf "ico:(~ax~ax~a)~n" (ico-width x) (ico-height x) (ico-depth x)))
  (read-icos "icons\\an-icon-file.ico"))

(require mrlib/cache-image-snip)

(map (lambda (x) (argb->bitmap (ico->argb x))) (read-icos
"icons\\an-icon-file.ico"))

****

Gives results:

'(#<ico> #<ico>)

ico:(32x32x4)
ico:(16x16x4)

'(#<void> #<void>)

. . argb->bitmap: contract violation
 expected: argb?
 given: #"\0\0\0\0\0\0\0\0\0\0\0\ ...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20120910/a936ad4c/attachment.html>

Posted on the users mailing list.