1 | /* $Id: cvticongrp.cpp,v 1.8 2001-08-07 21:34:16 sandervl Exp $ */
|
---|
2 |
|
---|
3 | /*
|
---|
4 | * PE2LX Icon group code
|
---|
5 | *
|
---|
6 | * Copyright 1998 Sander van Leeuwen (sandervl@xs4all.nl)
|
---|
7 | *
|
---|
8 | *
|
---|
9 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
10 | *
|
---|
11 | */
|
---|
12 | #define INCL_GPIBITMAPS
|
---|
13 | #define INCL_BITMAPFILEFORMAT
|
---|
14 | #define INCL_DOSFILEMGR /* File Manager values */
|
---|
15 | #define INCL_DOSERRORS /* DOS Error values */
|
---|
16 | #define INCL_DOSPROCESS /* DOS Process values */
|
---|
17 | #define INCL_DOSMISC /* DOS Miscellanous values */
|
---|
18 | #define INCL_WIN
|
---|
19 | #include <os2wrap.h>
|
---|
20 | #include <stdio.h>
|
---|
21 | #include <string.h>
|
---|
22 | #include <stdlib.h>
|
---|
23 | #include <string.h>
|
---|
24 | #include <win32type.h>
|
---|
25 | #include <win32api.h>
|
---|
26 | #include <winconst.h>
|
---|
27 | #include <winicon.h>
|
---|
28 | #include <misc.h>
|
---|
29 | #include "cvtresource.h"
|
---|
30 | #include <winres.h>
|
---|
31 |
|
---|
32 | #define DBG_LOCALLOG DBG_cvticongrp
|
---|
33 | #include "dbglocal.h"
|
---|
34 |
|
---|
35 | //******************************************************************************
|
---|
36 | //******************************************************************************
|
---|
37 | void * WIN32API ConvertIconGroup(void *hdr, HINSTANCE hInstance, DWORD *ressize)
|
---|
38 | {
|
---|
39 | IconHeader *ihdr = (IconHeader *)hdr;
|
---|
40 | ResourceDirectory *rdir = (ResourceDirectory *)(ihdr + 1);
|
---|
41 | int i, groupsize = 0, os2iconsize;
|
---|
42 | BITMAPARRAYFILEHEADER2 *bafh, *orgbafh;
|
---|
43 | WINBITMAPINFOHEADER *iconhdr;
|
---|
44 | void *os2icon;
|
---|
45 | HRSRC hRes;
|
---|
46 |
|
---|
47 | dprintf(("Icon Group type :%d", ihdr->wType));
|
---|
48 | dprintf(("Icon Group count:%d", ihdr->wCount));
|
---|
49 | for(i=0;i<ihdr->wCount;i++) {
|
---|
50 | dprintf2(("Icon : %d", rdir->wNameOrdinal));
|
---|
51 | dprintf2(("Width : %d", (int)rdir->bWidth));
|
---|
52 | dprintf2(("Height : %d", (int)rdir->bHeight));
|
---|
53 | dprintf2(("Colors : %d", (int)rdir->bColorCount));
|
---|
54 | dprintf2(("Bits : %d", rdir->wBitCount));
|
---|
55 | dprintf2(("ResBytes: %d", rdir->lBytesInRes));
|
---|
56 | hRes = FindResourceA(hInstance,
|
---|
57 | (LPCSTR)rdir->wNameOrdinal, (LPSTR)NTRT_ICON);
|
---|
58 |
|
---|
59 | groupsize += QueryConvertedResourceSize(hInstance, (char *)NTRT_ICON, hRes);
|
---|
60 | rdir++;
|
---|
61 | }
|
---|
62 | groupsize = groupsize+ihdr->wCount*sizeof(BITMAPARRAYFILEHEADER2);
|
---|
63 | bafh = (BITMAPARRAYFILEHEADER2 *)malloc(groupsize);
|
---|
64 | orgbafh = bafh;
|
---|
65 |
|
---|
66 | rdir = (ResourceDirectory *)(ihdr + 1);
|
---|
67 | for(i=0;i<ihdr->wCount;i++) {
|
---|
68 | bafh->usType = BFT_BITMAPARRAY;
|
---|
69 | bafh->cbSize = sizeof(BITMAPARRAYFILEHEADER2);
|
---|
70 | bafh->cxDisplay = 0;
|
---|
71 | bafh->cyDisplay = 0;
|
---|
72 | hRes = FindResourceA(hInstance,
|
---|
73 | (LPCSTR)rdir->wNameOrdinal, (LPSTR)NTRT_ICON);
|
---|
74 |
|
---|
75 | if(hRes == NULL) {
|
---|
76 | dprintf(("Can't find icon!"));
|
---|
77 | rdir++;
|
---|
78 | continue;
|
---|
79 | }
|
---|
80 |
|
---|
81 | iconhdr = (WINBITMAPINFOHEADER *)LockResource(LoadResource(hInstance, hRes));
|
---|
82 | os2icon = ConvertIcon(iconhdr, SizeofResource(hInstance, hRes), &os2iconsize, (int)bafh - (int)orgbafh + sizeof(BITMAPARRAYFILEHEADER2)-sizeof(BITMAPFILEHEADER2));
|
---|
83 |
|
---|
84 | if(os2icon == NULL) {
|
---|
85 | dprintf(("Can't convert icon!"));
|
---|
86 | rdir++;
|
---|
87 | continue;
|
---|
88 | }
|
---|
89 |
|
---|
90 | if(i != ihdr->wCount -1) {
|
---|
91 | bafh->offNext = (int)&bafh->bfh2 - (int)orgbafh + os2iconsize;
|
---|
92 | }
|
---|
93 | else bafh->offNext = 0;
|
---|
94 |
|
---|
95 | memcpy((char *)&bafh->bfh2, os2icon, os2iconsize);
|
---|
96 | free(os2icon);
|
---|
97 |
|
---|
98 | bafh = (BITMAPARRAYFILEHEADER2 *)((int)&bafh->bfh2 + os2iconsize);
|
---|
99 |
|
---|
100 | rdir++;
|
---|
101 | }
|
---|
102 | *ressize = groupsize;
|
---|
103 | return (void *)orgbafh;
|
---|
104 | }
|
---|
105 | //******************************************************************************
|
---|
106 | //******************************************************************************
|
---|