Newsgroups: comp.lang.smalltalk
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!news.mathworks.com!udel!gatech!howland.reston.ans.net!EU.net!Germany.EU.net!donald!hmm
From: hmm@heeg.de (Hans-Martin Mosner)
Subject: Re: Windows icons -> VisualWorks icons?
Message-ID: <Cyor6H.18q@heeg.de>
Organization: Georg Heeg Objektorientierte Systeme, Dortmund, FRG
References: <560VzY8.wgoldring@delphi.com>
Date: Thu, 3 Nov 1994 09:47:04 GMT
Lines: 62

In article <560VzY8.wgoldring@delphi.com> William Goldring <wgoldring@delphi.com> writes:
>Does anyone know how to convert standard Windows icons into
>suitable formats (bitmaps) importable to VisualWorks?
>Any help here greatly appreciated...

Although I don't fully understand the file format, this seems to work
well with the icons I tried it on. 

Hans-Martin


'From VisualWorks(TM), Release 1.0a of 10 February 1993 on 3 November 1994 at 10:47:18 am'!



!OpaqueImage class methodsFor: 'instance creation'!

fromWindowsIcon: filename 
	"ScheduledWindow new
		component: (OpaqueImage fromWindowsIcon: 'test.ico');
		openWithExtent: 32@32"
	| stream palette b g r figure shape |
	stream := filename asFilename readStream binary.
	stream skip: 62.
	palette := MappedPalette withColors: ((1 to: 16)
					collect: 
						[:i | 
						b := stream next.
						g := stream next.
						r := stream next.
						stream next.
						ColorValue
							red: r / 255
							green: g / 255
							blue: b / 255]).
	figure := Image
				extent: 32 @ 32
				depth: 4
				palette: palette.
	shape := Image
				extent: 32 @ 32
				depth: 1
				palette: CoveragePalette monoMaskPalette.
	stream
		next: 512
		into: figure bitsInstVar
		startingAt: 1;
		next: 128
		into: shape bitsInstVar
		startingAt: 1; close.
	shape
		copy: shape bounds
		from: 0 @ 0
		in: shape
		rule: 12.
	^self figure: (CachedImage on: figure reflectedInY)
		shape: (CachedImage on: shape reflectedInY)! !
-- 
+--- Hans-Martin Mosner ---------------- <hmm@heeg.de> ---+
| These opinions are entirely ficticious.  Any similarity |
| to real opinions is purely coincidental and unintended. |
+---------------------------------------------------------+
