1 /******************************************************************************
2 *
3 * Copyright (C) 2008, The Gentee Group. All rights reserved.
4 * This file is part of the Gentee open source project - http://www.gentee.com.
5 *
6 * THIS FILE IS PROVIDED UNDER THE TERMS OF THE GENTEE LICENSE ("AGREEMENT").
7 * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE CONSTITUTES RECIPIENTS
8 * ACCEPTANCE OF THE AGREEMENT.
9 *
10 * Author: Alexey Krivonogov ( gentee )
11 *
12 ******************************************************************************/
13
14 type iBITMAPINFOHEADER{
15 uint biSize
16 uint biWidth
17 uint biHeight
18 ushort biPlanes
19 ushort biBitCount
20 uint biCompression
21 uint biSizeImage
22 uint biXPelsPerMeter
23 uint biYPelsPerMeter
24 uint biClrUsed
25 uint biClrImportant
26 }
27
28 type iICONDIRENTRY
29 {
30 ubyte bWidth // Width of the image
31 ubyte bHeight // Height of the image (times 2)
32 ubyte bColorCount // Number of colors in image (0 if >=8bpp)
33 ubyte bReserved // Reserved
34 ushort wPlanes // Color Planes
35 ushort wBitCount // Bits per pixel
36 uint dwBytesInRes // how many bytes in this resource?
37 uint dwImageOffset // where in the file is this image
38 }
39
40 type iICONDIR
41 {
42 ushort idReserved // Reserved
43 ushort idType // resource type (1 for icons)
44 ushort idCount // how many images?
45 }
46
47 type iconinfo
48 {
49 iICONDIRENTRY icondir
50 buf data
51 }
52
53 func uint geticoninfo( str iconame, arr result of iconinfo )
54 {
55 buf input
56 uint dir i cur
57
58 result.clear()
59 input.read( iconame )
60 if !*input : return 0
61 dir as input.ptr()->iICONDIR
62 cur = input.ptr() + sizeof( iICONDIR )
63
64 fornum i, dir.idCount
65 {
66 uint bi
67
68 result.expand( 1 )
69 mcopy( &result[i].icondir, cur, sizeof( iICONDIRENTRY ))
70 cur += sizeof( iICONDIRENTRY )
71 result[i].data.copy( input.ptr() + result[i].icondir.dwImageOffset,
72 result[i].icondir.dwBytesInRes )
73 bi as result[i].data.ptr()->iBITMAPINFOHEADER
74
75 result[i].icondir.wPlanes = bi.biPlanes
76 result[i].icondir.wBitCount = bi.biBitCount
77 result[i].icondir.bColorCount = bi.biClrUsed
78 }
79 return 1
80 }
81
82
Редактировать