source: trunk/src/kernel32/cvticongrp.cpp@ 589

Last change on this file since 589 was 589, checked in by sandervl, 26 years ago

More PE resource changes

File size: 3.4 KB
Line 
1/* $Id: cvticongrp.cpp,v 1.1 1999-08-19 19:50:40 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 <winicon.h>
26#include <winres.h>
27#include <misc.h>
28#include "cvtresource.h"
29
30HRSRC WIN32API FindResourceA(HINSTANCE hModule, LPCSTR lpszName, LPCSTR lpszType);
31
32//******************************************************************************
33//******************************************************************************
34void *ConvertIconGroup(IconHeader *ihdr, int size, Win32Image *module)
35{
36 ResourceDirectory *rdir = (ResourceDirectory *)(ihdr + 1);
37 int i, groupsize = 0;
38 BITMAPARRAYFILEHEADER2 *bafh, *orgbafh;
39 WINBITMAPINFOHEADER *iconhdr;
40 Win32Resource *winres;
41 void *os2icon;
42
43 dprintf(("Icon Group type :%d", ihdr->wType));
44 dprintf(("Icon Group count:%d", ihdr->wCount));
45 for(i=0;i<ihdr->wCount;i++) {
46 dprintf(("Icon : %d", rdir->wNameOrdinal));
47 dprintf(("Width : %d", (int)rdir->bWidth));
48 dprintf(("Height : %d", (int)rdir->bHeight));
49 dprintf(("Colors : %d", (int)rdir->bColorCount));
50 dprintf(("Bits : %d", rdir->wBitCount));
51 dprintf(("ResBytes: %d", rdir->lBytesInRes));
52 groupsize += module->getResourceSizeA((LPSTR)rdir->wNameOrdinal, (LPSTR)NTRT_ICON);
53 rdir++;
54 }
55 bafh = (BITMAPARRAYFILEHEADER2 *)malloc(groupsize+ihdr->wCount*sizeof(BITMAPARRAYFILEHEADER2));
56 orgbafh = bafh;
57
58 rdir = (ResourceDirectory *)(ihdr + 1);
59 for(i=0;i<ihdr->wCount;i++) {
60 bafh->usType = BFT_BITMAPARRAY;
61 bafh->cbSize = sizeof(BITMAPARRAYFILEHEADER2);
62 bafh->cxDisplay = 0;
63 bafh->cyDisplay = 0;
64 winres = (Win32Resource *)FindResourceA(module->getInstanceHandle(),
65 (LPCSTR)rdir->wNameOrdinal,
66 (LPSTR)NTRT_ICON);
67 if(winres == NULL) {
68 dprintf(("Can't find icon!"));
69 rdir++;
70 continue;
71 }
72 if(i != ihdr->wCount -1) {
73 bafh->offNext = (int)&bafh->bfh2 - (int)orgbafh + winres->getSize();
74 }
75 else bafh->offNext = 0;
76
77 iconhdr = (WINBITMAPINFOHEADER *)winres->lockResource();
78 os2icon = ConvertIcon(iconhdr, winres->getSize(), (int)bafh - (int)orgbafh + sizeof(BITMAPARRAYFILEHEADER2)-sizeof(BITMAPFILEHEADER2));
79
80 if(os2icon == NULL) {
81 dprintf(("Can't convert icon!"));
82 delete winres;
83 rdir++;
84 continue;
85 }
86
87 memcpy((char *)&bafh->bfh2, os2icon, winres->getSize());
88 free(os2icon);
89
90 bafh = (BITMAPARRAYFILEHEADER2 *)((int)&bafh->bfh2 + winres->getSize());
91 delete winres;
92
93 rdir++;
94 }
95 return (void *)orgbafh;
96}
97//******************************************************************************
98//******************************************************************************
Note: See TracBrowser for help on using the repository browser.