Index: trunk/src/kernel32/KERNEL32.DEF
===================================================================
--- trunk/src/kernel32/KERNEL32.DEF	(revision 6486)
+++ trunk/src/kernel32/KERNEL32.DEF	(revision 6487)
@@ -1,3 +1,3 @@
-; $Id: KERNEL32.DEF,v 1.120 2001-08-07 21:34:15 sandervl Exp $
+; $Id: KERNEL32.DEF,v 1.121 2001-08-08 10:06:52 sandervl Exp $
 
 ;Basis is Windows95 KERNEL32
@@ -1190,6 +1190,4 @@
     strncmpiW                                                     @2022 NONAME
 
-    _ConvertIconGroup@12                                          @2023 NONAME
-
     GetDisplayCodepage__Fv                                        @3000 NONAME
     GetWindowsCodepage__Fv                                        @3001 NONAME
Index: trunk/src/kernel32/cvticon.cpp
===================================================================
--- trunk/src/kernel32/cvticon.cpp	(revision 6486)
+++ 	(revision )
@@ -1,210 +1,0 @@
-/* $Id: cvticon.cpp,v 1.8 2000-02-16 14:25:37 sandervl Exp $ */
-
-/*
- * PE2LX icons
- *
- * Copyright 1998 Sander van Leeuwen (sandervl@xs4all.nl)
- *
- *
- * Project Odin Software License can be found in LICENSE.TXT
- *
- */
-#define INCL_GPIBITMAPS
-#define INCL_BITMAPFILEFORMAT
-#define INCL_DOSFILEMGR          /* File Manager values      */
-#define INCL_DOSERRORS           /* DOS Error values         */
-#define INCL_DOSPROCESS          /* DOS Process values       */
-#define INCL_DOSMISC             /* DOS Miscellanous values  */
-#define INCL_WIN
-#include <os2wrap.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <string.h>
-#include <win32type.h>
-#include <winicon.h>
-#include <misc.h>
-
-#define DBG_LOCALLOG	DBG_cvticon
-#include "dbglocal.h"
-
-//******************************************************************************
-//******************************************************************************
-ULONG QueryConvertedIconSize(WINBITMAPINFOHEADER *bmpHdr, int size)
-{
- int bwsize, colorsize, rgbsize, iconsize;
-
-  bwsize   = (bmpHdr->biWidth*(bmpHdr->biHeight/2))/8;
-  colorsize = bmpHdr->biWidth*(bmpHdr->biHeight/2);
-  //SvL: 28-09-'98: only for <= 8
-  if(bmpHdr->biBitCount <= 8)
-        rgbsize = (1<<bmpHdr->biBitCount)*sizeof(RGB2);
-  else  rgbsize = 0;
-
-  switch(bmpHdr->biBitCount) {
-        case 1:
-                colorsize /= 8;
-                break;
-        case 4:
-                colorsize /= 2;
-                break;
-        case 8:
-                break;
-        case 16:
-                colorsize *= 2;
-                break;
-        case 24:
-                colorsize *= 3;
-                break;
-        case 32:
-                colorsize *= 4;
-                break;
-  }
-  if(bmpHdr->biSizeImage == 0 && bmpHdr->biCompression == 0) {
-        bmpHdr->biSizeImage = bwsize + colorsize;
-  }
-
-  //SvL: 28-09-'98: cllngenu.dll has an incorrect size in the header
-  if(bmpHdr->biSizeImage < colorsize) {
-        bmpHdr->biSizeImage = colorsize;
-  }
-  //bitmapfileheader for AndXor mask + 2 RGB structs + bitmapfileheader
-  //for color bitmap + RGB structs for all the colors
-  //SvL, 3-3-98: 2*bwsize
-  iconsize = 2*sizeof(BITMAPFILEHEADER2) + 2*sizeof(RGB2) +
-             rgbsize + 2*bwsize + bmpHdr->biSizeImage;
-
-  return iconsize;
-}
-//******************************************************************************
-//NOTE: offsetBits is the value added to the offBits bitmap structure members
-//      (handy for converting icon groups)
-//******************************************************************************
-void *ConvertIcon(WINBITMAPINFOHEADER *bmpHdr, int size, int *os2size, int offsetBits)
-{
- RGBQUAD *rgb;
- RGB2    *os2rgb;
- int bwsize, i, colorsize, rgbsize, iconsize;
- BITMAPFILEHEADER2 *iconhdr;
- BITMAPFILEHEADER2 *iconhdr2;
- char *pAnd, *pXor;
-
-  bwsize   = (bmpHdr->biWidth*(bmpHdr->biHeight/2))/8;
-  colorsize = bmpHdr->biWidth*(bmpHdr->biHeight/2);
-  //SvL: 28-09-'98: only for <= 8
-  if(bmpHdr->biBitCount <= 8)
-        rgbsize = (1<<bmpHdr->biBitCount)*sizeof(RGB2);
-  else  rgbsize = 0;
-
-  switch(bmpHdr->biBitCount) {
-        case 1:
-                colorsize /= 8;
-                break;
-        case 4:
-                colorsize /= 2;
-                break;
-        case 8:
-                break;
-        case 16:
-                colorsize *= 2;
-                break;
-        case 24:
-                colorsize *= 3;
-                break;
-        case 32:
-                colorsize *= 4;
-                break;
-  }
-  if(bmpHdr->biSizeImage == 0 && bmpHdr->biCompression == 0) {
-        bmpHdr->biSizeImage = bwsize + colorsize;
-  }
-  dprintf2(("Icon size    : %d", bmpHdr->biSizeImage));
-  dprintf2(("Icon Width   : %d", bmpHdr->biWidth));
-  //height for both the XOR and AND bitmap (color & BW)
-  dprintf2(("Height       : %d", bmpHdr->biHeight));
-  dprintf2(("Icon Bitcount: %d", bmpHdr->biBitCount));
-  dprintf2(("Icon Compress: %d", bmpHdr->biCompression));
-
-  //SvL: 28-09-'98: cllngenu.dll has an incorrect size in the header
-  if(bmpHdr->biSizeImage < colorsize) {
-        bmpHdr->biSizeImage = colorsize;
-  }
-  //bitmapfileheader for AndXor mask + 2 RGB structs + bitmapfileheader
-  //for color bitmap + RGB structs for all the colors
-  //SvL, 3-3-98: 2*bwsize
-  iconsize = 2*sizeof(BITMAPFILEHEADER2) + 2*sizeof(RGB2) +
-             rgbsize + 2*bwsize + bmpHdr->biSizeImage;
-
-  iconhdr  = (BITMAPFILEHEADER2 *)malloc(iconsize);
-  memset(iconhdr, 0, iconsize);
-  iconhdr->usType        = BFT_COLORICON;
-  iconhdr->cbSize        = sizeof(BITMAPFILEHEADER2);
-  iconhdr->xHotspot      = 0;
-  iconhdr->yHotspot      = 0;
-  iconhdr->offBits       = 2*sizeof(BITMAPFILEHEADER2) +
-                           2*sizeof(RGB2) + rgbsize + offsetBits;
-  iconhdr->bmp2.cbFix    = sizeof(BITMAPINFOHEADER2);
-  iconhdr->bmp2.cx       = (USHORT)bmpHdr->biWidth;
-  iconhdr->bmp2.cy       = (USHORT)bmpHdr->biHeight;
-  iconhdr->bmp2.cPlanes  = 1;
-  iconhdr->bmp2.cBitCount= 1;
-  iconhdr->bmp2.ulCompression   = BCA_UNCOMP;
-  iconhdr->bmp2.ulColorEncoding = BCE_RGB;
-  os2rgb                 = (RGB2 *)(iconhdr+1);
-  memset(os2rgb, 0, sizeof(RGB2));
-  memset(os2rgb+1, 0xff, sizeof(RGB)); //not reserved byte!
-  iconhdr2               = (BITMAPFILEHEADER2 *)(os2rgb+2);
-  iconhdr2->usType       = BFT_COLORICON;
-  iconhdr2->cbSize       = sizeof(BITMAPFILEHEADER2);
-  iconhdr2->xHotspot     = 0;
-  iconhdr2->yHotspot     = 0;
-  iconhdr2->offBits      = 2*sizeof(BITMAPFILEHEADER2) +
-                           2*sizeof(RGB2) + rgbsize + 2*bwsize + offsetBits;
-  iconhdr2->bmp2.cbFix   = sizeof(BITMAPINFOHEADER2);
-  iconhdr2->bmp2.cx      = (USHORT)bmpHdr->biWidth;
-  iconhdr2->bmp2.cy      = (USHORT)(bmpHdr->biHeight/2);
-  iconhdr2->bmp2.cPlanes = bmpHdr->biPlanes;
-  iconhdr2->bmp2.cBitCount= bmpHdr->biBitCount;
-  iconhdr2->bmp2.ulCompression   = BCA_UNCOMP;
-  iconhdr2->bmp2.ulColorEncoding = BCE_RGB;
-  os2rgb                 = (RGB2 *)(iconhdr2+1);
-  rgb                    = (RGBQUAD *)(bmpHdr+1);
-  if(bmpHdr->biBitCount <= 8) {
-        for(i=0;i<(1<<bmpHdr->biBitCount);i++) {
-                os2rgb->bRed   = rgb->red;
-                os2rgb->bBlue  = rgb->blue;
-                os2rgb->bGreen = rgb->green;
-                os2rgb++;
-                rgb++;
-        }
-  }
-
-  pXor = (char *)os2rgb;
-  pAnd = (char *)os2rgb + bwsize;
-
-  if ((size - (bmpHdr->biSize - rgbsize - colorsize)) == bwsize) {
-    char *q;
-    int i, linesize;
-
-    linesize = bmpHdr->biWidth / 8;
-    q = (char *)rgb + colorsize;
-    for (i = 0; i < (bmpHdr->biHeight/2); i++) {
-      memcpy (pAnd, q, linesize);
-      pAnd += linesize;
-      q += linesize;
-
-      memcpy (pXor, q, linesize);
-      pXor += linesize;
-      q += linesize;
-    }
-  } else {
-    memcpy (pAnd, (char *)rgb + colorsize, bwsize);
-    memset (pXor, 0, bwsize);
-  }
-  memcpy((char *)os2rgb+2*bwsize, (char *)rgb, colorsize);
-
-  *os2size = iconsize;
-  return (void *)iconhdr;
-}
-//******************************************************************************
-//******************************************************************************
Index: trunk/src/kernel32/cvticongrp.cpp
===================================================================
--- trunk/src/kernel32/cvticongrp.cpp	(revision 6486)
+++ 	(revision )
@@ -1,106 +1,0 @@
-/* $Id: cvticongrp.cpp,v 1.8 2001-08-07 21:34:16 sandervl Exp $ */
-
-/*
- * PE2LX Icon group code
- *
- * Copyright 1998 Sander van Leeuwen (sandervl@xs4all.nl)
- *
- *
- * Project Odin Software License can be found in LICENSE.TXT
- *
- */
-#define INCL_GPIBITMAPS
-#define INCL_BITMAPFILEFORMAT
-#define INCL_DOSFILEMGR          /* File Manager values      */
-#define INCL_DOSERRORS           /* DOS Error values         */
-#define INCL_DOSPROCESS          /* DOS Process values       */
-#define INCL_DOSMISC             /* DOS Miscellanous values  */
-#define INCL_WIN
-#include <os2wrap.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <string.h>
-#include <win32type.h>
-#include <win32api.h>
-#include <winconst.h>
-#include <winicon.h>
-#include <misc.h>
-#include "cvtresource.h"
-#include <winres.h>
-
-#define DBG_LOCALLOG	DBG_cvticongrp
-#include "dbglocal.h"
-
-//******************************************************************************
-//******************************************************************************
-void * WIN32API ConvertIconGroup(void *hdr, HINSTANCE hInstance, DWORD *ressize)
-{
- IconHeader *ihdr = (IconHeader *)hdr;
- ResourceDirectory *rdir = (ResourceDirectory *)(ihdr + 1);
- int i, groupsize = 0, os2iconsize;
- BITMAPARRAYFILEHEADER2 *bafh, *orgbafh;
- WINBITMAPINFOHEADER    *iconhdr;
- void                   *os2icon;
- HRSRC                   hRes;
-
-  dprintf(("Icon Group type :%d", ihdr->wType));
-  dprintf(("Icon Group count:%d", ihdr->wCount));
-  for(i=0;i<ihdr->wCount;i++) {
-        dprintf2(("Icon    : %d", rdir->wNameOrdinal));
-        dprintf2(("Width   : %d", (int)rdir->bWidth));
-        dprintf2(("Height  : %d", (int)rdir->bHeight));
-        dprintf2(("Colors  : %d", (int)rdir->bColorCount));
-        dprintf2(("Bits    : %d", rdir->wBitCount));
-        dprintf2(("ResBytes: %d", rdir->lBytesInRes));
-	hRes = FindResourceA(hInstance, 
-                             (LPCSTR)rdir->wNameOrdinal, (LPSTR)NTRT_ICON);
-
-	groupsize += QueryConvertedResourceSize(hInstance, (char *)NTRT_ICON, hRes);
-        rdir++;
-  }
-  groupsize = groupsize+ihdr->wCount*sizeof(BITMAPARRAYFILEHEADER2);
-  bafh    = (BITMAPARRAYFILEHEADER2 *)malloc(groupsize);
-  orgbafh = bafh;
-
-  rdir = (ResourceDirectory *)(ihdr + 1);
-  for(i=0;i<ihdr->wCount;i++) {
-        bafh->usType    = BFT_BITMAPARRAY;
-        bafh->cbSize    = sizeof(BITMAPARRAYFILEHEADER2);
-        bafh->cxDisplay = 0;
-        bafh->cyDisplay = 0;
-	hRes = FindResourceA(hInstance, 
-                             (LPCSTR)rdir->wNameOrdinal, (LPSTR)NTRT_ICON);
-
-        if(hRes == NULL) {
-                dprintf(("Can't find icon!"));
-                rdir++;
-                continue;
-        }
-
-	iconhdr = (WINBITMAPINFOHEADER *)LockResource(LoadResource(hInstance, hRes));
-	os2icon = ConvertIcon(iconhdr, SizeofResource(hInstance, hRes), &os2iconsize, (int)bafh - (int)orgbafh + sizeof(BITMAPARRAYFILEHEADER2)-sizeof(BITMAPFILEHEADER2));
-
-        if(os2icon == NULL) {
-                dprintf(("Can't convert icon!"));
-                rdir++;
-                continue;
-        }
-
-        if(i != ihdr->wCount -1) {
-                bafh->offNext = (int)&bafh->bfh2 - (int)orgbafh + os2iconsize;
-        }
-        else    bafh->offNext = 0;
-
-        memcpy((char *)&bafh->bfh2, os2icon, os2iconsize);
-	free(os2icon);
-
-        bafh = (BITMAPARRAYFILEHEADER2 *)((int)&bafh->bfh2 + os2iconsize);
-
-        rdir++;
-  }
-  *ressize = groupsize;
-  return (void *)orgbafh;
-}
-//******************************************************************************
-//******************************************************************************
Index: trunk/src/kernel32/kernel32.mak
===================================================================
--- trunk/src/kernel32/kernel32.mak	(revision 6486)
+++ trunk/src/kernel32/kernel32.mak	(revision 6487)
@@ -1,3 +1,3 @@
-# $Id: kernel32.mak,v 1.12 2001-08-07 21:34:16 sandervl Exp $
+# $Id: kernel32.mak,v 1.13 2001-08-08 10:06:53 sandervl Exp $
 
 #
@@ -132,7 +132,4 @@
 $(OBJDIR)\hmdisk.obj \
 $(OBJDIR)\version.obj \
-$(OBJDIR)\cvticon.obj \
-$(OBJDIR)\cvticongrp.obj \
-$(OBJDIR)\winres.obj \
 !ifdef DEBUG
 $(OBJDIR)\exceptstackdump.obj \
Index: trunk/src/kernel32/kernel32lib.mak
===================================================================
--- trunk/src/kernel32/kernel32lib.mak	(revision 6486)
+++ trunk/src/kernel32/kernel32lib.mak	(revision 6487)
@@ -1,3 +1,3 @@
-# $Id: kernel32lib.mak,v 1.4 2001-08-07 21:34:16 sandervl Exp $
+# $Id: kernel32lib.mak,v 1.5 2001-08-08 10:06:53 sandervl Exp $
 
 #
@@ -119,7 +119,4 @@
 $(OBJDIR)\hmdisk.obj \
 $(OBJDIR)\version.obj \
-$(OBJDIR)\cvticon.obj \
-$(OBJDIR)\cvticongrp.obj \
-$(OBJDIR)\winres.obj \
 !ifdef DEBUG
 $(OBJDIR)\exceptstackdump.obj \
Index: trunk/src/kernel32/winres.cpp
===================================================================
--- trunk/src/kernel32/winres.cpp	(revision 6486)
+++ 	(revision )
@@ -1,143 +1,0 @@
-/* $Id: winres.cpp,v 1.30 2001-08-07 21:34:16 sandervl Exp $ */
-
-/*
- * Win32 resource class
- *
- * Copyright 1998 Sander van Leeuwen (sandervl@xs4all.nl)
- *
- *
- * Project Odin Software License can be found in LICENSE.TXT
- *
- *
- */
-#define INCL_BASE
-#define INCL_WIN
-#define INCL_GPIBITMAPS
-#define INCL_BITMAPFILEFORMAT
-#define INCL_DOSMODULEMGR
-#include <os2wrap.h>    //Odin32 OS/2 api wrappers
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#define INCL_WINRES
-#include <win32type.h>
-#include <win32api.h>
-#include <winconst.h>
-#include <winres.h>
-#include <misc.h>
-#include <winimagebase.h>
-#include <winexebase.h>
-#include <windllbase.h>
-#include "cvtresource.h"
-
-#define DBG_LOCALLOG	DBG_winres
-#include "dbglocal.h"
-
-#if 0
-//******************************************************************************
-//******************************************************************************
-PVOID WIN32API ConvertResourceToOS2(HINSTANCE hInstance, LPSTR restype, HRSRC hResource)
-{
- PIMAGE_RESOURCE_DATA_ENTRY pData = (PIMAGE_RESOURCE_DATA_ENTRY)hResource;
- Win32ImageBase *module;
- char           *resdata;
- int             ressize, cvtressize;
-
-  if(hInstance == 0 || hInstance == -1 || (WinExe && hInstance == WinExe->getInstanceHandle())) {
-        module = (Win32ImageBase *)WinExe;
-  }
-  else {
-        module = (Win32ImageBase *)Win32DllBase::findModule(hInstance);
-  }
-  resdata = (char *)LockResource(LoadResource(hInstance, hResource));
-  ressize = SizeofResource(hInstance, hResource);
-
-  switch((int)restype) {
-    case NTRT_CURSOR:
-    	return ConvertCursor((CursorComponent *)resdata, ressize, &cvtressize);
-
-    case NTRT_GROUP_CURSOR:
-    	return ConvertCursorGroup((CursorHeader *)resdata, ressize, module);
-
-    case NTRT_NEWMENU:
-    case NTRT_MENU:
-    case NTRT_NEWDIALOG:
-    case NTRT_DIALOG:
-    case NTRT_FONTDIR:
-    case NTRT_FONT:
-    case NTRT_MESSAGETABLE:
-    case NTRT_RCDATA:
-    case NTRT_VERSION:
-    case NTRT_STRING:
-    	break;
-
-    default:
-        break;
-  }
-  dprintf(("ConvertResourceToOS2: Can't convert resource %x (inst %x)", hResource, hInstance));
-  return 0;
-}
-//******************************************************************************
-//******************************************************************************
-PVOID WIN32API ConvertCursorToOS2(LPVOID lpWinResData)
-{
- int ressize, cvtressize;
- 
-  ressize = QueryConvertedCursorSize((CursorComponent *)lpWinResData, 0);
-
-  return ConvertCursor((CursorComponent *)lpWinResData, ressize, &cvtressize);
-}
-//******************************************************************************
-//******************************************************************************
-VOID WIN32API FreeOS2Resource(LPVOID lpResource)
-{
-  free(lpResource);
-}
-#endif
-//******************************************************************************
-//******************************************************************************
-ULONG WIN32API QueryConvertedResourceSize(HINSTANCE hInstance, LPSTR restype, HRSRC hResource)
-{
- PIMAGE_RESOURCE_DATA_ENTRY pData = (PIMAGE_RESOURCE_DATA_ENTRY)hResource;
- Win32ImageBase *module;
- char           *resdata;
- int             ressize, cvtressize;
-
-  if(hInstance == 0 || hInstance == -1 || (WinExe && hInstance == WinExe->getInstanceHandle())) {
-        module = (Win32ImageBase *)WinExe;
-  }
-  else {
-        module = (Win32ImageBase *)Win32DllBase::findModule(hInstance);
-  }
-  resdata = (char *)LockResource(LoadResource(hInstance, hResource));
-  ressize = SizeofResource(hInstance, hResource);
-
-  switch((int)restype) {
-    case NTRT_ICON:
-    	return QueryConvertedIconSize((WINBITMAPINFOHEADER *)resdata, ressize);
-
-//    case NTRT_CURSOR:
-//    	return QueryConvertedCursorSize((CursorComponent *)resdata, ressize);
-
-    case NTRT_GROUP_ICON:
-    case NTRT_GROUP_CURSOR:
-    case NTRT_ACCELERATORS:
-    case NTRT_NEWMENU:
-    case NTRT_MENU:
-    case NTRT_NEWDIALOG:
-    case NTRT_DIALOG:
-    case NTRT_FONTDIR:
-    case NTRT_FONT:
-    case NTRT_MESSAGETABLE:
-    case NTRT_RCDATA:
-    case NTRT_VERSION:
-    case NTRT_STRING:
-    default:
-    	dprintf(("Win32Resource::getOS2Size SHOULDN'T BE CALLED for this resource type (%d) (NOT IMPLEMENTED)!!", restype));
-    	break;
-  }
-  return 0;
-}
-//******************************************************************************
-//******************************************************************************
Index: trunk/src/user32/USER32.DEF
===================================================================
--- trunk/src/user32/USER32.DEF	(revision 6486)
+++ trunk/src/user32/USER32.DEF	(revision 6487)
@@ -1,3 +1,3 @@
-; $Id: USER32.DEF,v 1.64 2001-08-07 21:35:35 sandervl Exp $
+; $Id: USER32.DEF,v 1.65 2001-08-08 10:07:18 sandervl Exp $
 
 LIBRARY USER32 INITINSTANCE TERMINSTANCE
@@ -703,2 +703,3 @@
 
     _OSLibWinCreateObject@32                                     @2031 NONAME
+    _ConvertIconGroup@12                                         @2032 NONAME
Index: trunk/src/user32/icon.cpp
===================================================================
--- trunk/src/user32/icon.cpp	(revision 6486)
+++ trunk/src/user32/icon.cpp	(revision 6487)
@@ -1,3 +1,3 @@
-/* $Id: icon.cpp,v 1.10 2000-02-16 14:34:19 sandervl Exp $ */
+/* $Id: icon.cpp,v 1.11 2001-08-08 10:07:18 sandervl Exp $ */
 
 /*
@@ -24,6 +24,7 @@
 #include <string.h>
 
+#include <win32api.h>
 #include <win32type.h>
-
+#include "dib.h"
 #include <winicon.h>
 #include <misc.h>
@@ -32,4 +33,9 @@
 #include "dbglocal.h"
 
+#define DIB_RGB_COLORS_W   0
+#define DIB_PAL_COLORS_W   1
+#define CBM_INIT_W         4
+
+#if 0
 //******************************************************************************
 //******************************************************************************
@@ -150,2 +156,217 @@
 //******************************************************************************
 //******************************************************************************
+#endif
+
+//******************************************************************************
+//******************************************************************************
+ULONG QueryConvertedIconSize(WINBITMAPINFOHEADER *bmpHdr, int size)
+{
+ int bwsize, colorsize, rgbsize, iconsize;
+
+  bwsize    = DIB_GetDIBImageBytes(bmpHdr->biWidth, (bmpHdr->biHeight/2), 1);
+  colorsize = DIB_GetDIBImageBytes(bmpHdr->biWidth, (bmpHdr->biHeight/2), bmpHdr->biBitCount);
+
+  //SvL: 28-09-'98: only for <= 8
+  if(bmpHdr->biBitCount <= 8)
+        rgbsize = (1<<bmpHdr->biBitCount)*sizeof(RGB2);
+  else  rgbsize = 0;
+
+  if(bmpHdr->biSizeImage == 0 && bmpHdr->biCompression == 0) {
+        bmpHdr->biSizeImage = bwsize + colorsize;
+  }
+
+  //SvL: 28-09-'98: cllngenu.dll has an incorrect size in the header
+  if(bmpHdr->biSizeImage < colorsize) {
+        bmpHdr->biSizeImage = colorsize;
+  }
+  //bitmapfileheader for AndXor mask + 2 RGB structs + bitmapfileheader
+  //for color bitmap + RGB structs for all the colors
+  //SvL, 3-3-98: 2*bwsize
+  iconsize = 2*sizeof(BITMAPFILEHEADER2) + 2*sizeof(RGB2) +
+             rgbsize + 2*bwsize + bmpHdr->biSizeImage;
+
+  return iconsize;
+}
+//******************************************************************************
+//NOTE: offsetBits is the value added to the offBits bitmap structure members
+//      (handy for converting icon groups)
+//******************************************************************************
+void *ConvertIcon(WINBITMAPINFOHEADER *bmpHdr, int size, int *os2size, int offsetBits)
+{
+ RGBQUAD *rgb;
+ RGB2    *os2rgb;
+ int bwsize, i, colorsize, rgbsize, iconsize;
+ BITMAPFILEHEADER2 *iconhdr;
+ BITMAPFILEHEADER2 *iconhdr2;
+ char *pAnd, *pXor;
+
+  bwsize    = DIB_GetDIBImageBytes(bmpHdr->biWidth, (bmpHdr->biHeight/2), 1);
+  colorsize = DIB_GetDIBImageBytes(bmpHdr->biWidth, (bmpHdr->biHeight/2), bmpHdr->biBitCount);
+  //SvL: 28-09-'98: only for <= 8
+  if(bmpHdr->biBitCount <= 8)
+        rgbsize = (1<<bmpHdr->biBitCount)*sizeof(RGB2);
+  else  rgbsize = 0;
+
+  if(bmpHdr->biSizeImage == 0 && bmpHdr->biCompression == 0) {
+        bmpHdr->biSizeImage = bwsize + colorsize;
+  }
+  dprintf(("Icon size    : %d", bmpHdr->biSizeImage));
+  dprintf(("Icon Width   : %d", bmpHdr->biWidth));
+  //height for both the XOR and AND bitmap (color & BW)
+  dprintf(("Height       : %d", bmpHdr->biHeight));
+  dprintf(("Icon Bitcount: %d", bmpHdr->biBitCount));
+  dprintf(("Icon Compress: %d", bmpHdr->biCompression));
+
+  //SvL: 28-09-'98: cllngenu.dll has an incorrect size in the header
+  if(bmpHdr->biSizeImage < colorsize) {
+        bmpHdr->biSizeImage = colorsize;
+  }
+  //bitmapfileheader for AndXor mask + 2 RGB structs + bitmapfileheader
+  //for color bitmap + RGB structs for all the colors
+  //SvL, 3-3-98: 2*bwsize
+  iconsize = 2*sizeof(BITMAPFILEHEADER2) + 2*sizeof(RGB2) +
+             rgbsize + 2*bwsize + bmpHdr->biSizeImage;
+
+  iconhdr  = (BITMAPFILEHEADER2 *)malloc(iconsize);
+  memset(iconhdr, 0, iconsize);
+  iconhdr->usType        = BFT_COLORICON;
+  iconhdr->cbSize        = sizeof(BITMAPFILEHEADER2);
+  iconhdr->xHotspot      = 0;
+  iconhdr->yHotspot      = 0;
+  iconhdr->offBits       = 2*sizeof(BITMAPFILEHEADER2) +
+                           2*sizeof(RGB2) + rgbsize + offsetBits;
+  iconhdr->bmp2.cbFix    = sizeof(BITMAPINFOHEADER2);
+  iconhdr->bmp2.cx       = (USHORT)bmpHdr->biWidth;
+  iconhdr->bmp2.cy       = (USHORT)bmpHdr->biHeight;
+  iconhdr->bmp2.cPlanes  = 1;
+  iconhdr->bmp2.cBitCount= 1;
+  iconhdr->bmp2.ulCompression   = BCA_UNCOMP;
+  iconhdr->bmp2.ulColorEncoding = BCE_RGB;
+  os2rgb                 = (RGB2 *)(iconhdr+1);
+  memset(os2rgb, 0, sizeof(RGB2));
+  memset(os2rgb+1, 0xff, sizeof(RGB)); //not reserved byte!
+  iconhdr2               = (BITMAPFILEHEADER2 *)(os2rgb+2);
+  iconhdr2->usType       = BFT_COLORICON;
+  iconhdr2->cbSize       = sizeof(BITMAPFILEHEADER2);
+  iconhdr2->xHotspot     = 0;
+  iconhdr2->yHotspot     = 0;
+  iconhdr2->offBits      = 2*sizeof(BITMAPFILEHEADER2) +
+                           2*sizeof(RGB2) + rgbsize + 2*bwsize + offsetBits;
+  iconhdr2->bmp2.cbFix   = sizeof(BITMAPINFOHEADER2);
+  iconhdr2->bmp2.cx      = (USHORT)bmpHdr->biWidth;
+  iconhdr2->bmp2.cy      = (USHORT)(bmpHdr->biHeight/2);
+  iconhdr2->bmp2.cPlanes = bmpHdr->biPlanes;
+  iconhdr2->bmp2.cBitCount= bmpHdr->biBitCount;
+  iconhdr2->bmp2.ulCompression   = BCA_UNCOMP;
+  iconhdr2->bmp2.ulColorEncoding = BCE_RGB;
+  os2rgb                 = (RGB2 *)(iconhdr2+1);
+  rgb                    = (RGBQUAD *)(bmpHdr+1);
+  if(bmpHdr->biBitCount <= 8) {
+        for(i=0;i<(1<<bmpHdr->biBitCount);i++) {
+                os2rgb->bRed   = rgb->red;
+                os2rgb->bBlue  = rgb->blue;
+                os2rgb->bGreen = rgb->green;
+                os2rgb++;
+                rgb++;
+        }
+  }
+
+  pXor = (char *)os2rgb;
+  pAnd = (char *)os2rgb + bwsize;
+
+  if ((size - (bmpHdr->biSize + rgbsize + colorsize + bwsize)) == bwsize) 
+  {//this means an AND and XOR mask is present (interleaved; and/xor)
+    char *q;
+    int i, linesize;
+
+    linesize = bmpHdr->biWidth / 8;
+    q = (char *)rgb + colorsize;
+    for (i = 0; i < (bmpHdr->biHeight/2); i++) {
+      memcpy (pAnd, q, linesize);
+      pAnd += linesize;
+      q += linesize;
+
+      memcpy (pXor, q, linesize);
+      pXor += linesize;
+      q += linesize;
+    }
+  } else {
+    memcpy (pAnd, (char *)rgb + colorsize, bwsize);
+    memset (pXor, 0, bwsize);
+  }
+  memcpy((char *)os2rgb+2*bwsize, (char *)rgb, colorsize);
+
+  *os2size = iconsize;
+  return (void *)iconhdr;
+}
+//******************************************************************************
+//******************************************************************************
+void * WIN32API ConvertIconGroup(void *hdr, HINSTANCE hInstance, DWORD *ressize)
+{
+ IconHeader *ihdr = (IconHeader *)hdr;
+ ResourceDirectory *rdir = (ResourceDirectory *)(ihdr + 1);
+ int i, groupsize = 0, os2iconsize;
+ BITMAPARRAYFILEHEADER2 *bafh, *orgbafh;
+ WINBITMAPINFOHEADER    *iconhdr;
+ void                   *os2icon;
+ HRSRC                   hRes;
+
+  dprintf(("Icon Group type :%d", ihdr->wType));
+  dprintf(("Icon Group count:%d", ihdr->wCount));
+  for(i=0;i<ihdr->wCount;i++) {
+        dprintf2(("Icon    : %d", rdir->wNameOrdinal));
+        dprintf2(("Width   : %d", (int)rdir->bWidth));
+        dprintf2(("Height  : %d", (int)rdir->bHeight));
+        dprintf2(("Colors  : %d", (int)rdir->bColorCount));
+        dprintf2(("Bits    : %d", rdir->wBitCount));
+        dprintf2(("ResBytes: %d", rdir->lBytesInRes));
+	hRes = FindResourceA(hInstance, 
+                             (LPCSTR)rdir->wNameOrdinal, (LPSTR)NTRT_ICON);
+
+        groupsize += QueryConvertedIconSize((WINBITMAPINFOHEADER *)LockResource(LoadResource(hInstance, hRes)),
+                                            SizeofResource(hInstance, hRes));
+        rdir++;
+  }
+  groupsize = groupsize+ihdr->wCount*sizeof(BITMAPARRAYFILEHEADER2);
+  bafh    = (BITMAPARRAYFILEHEADER2 *)malloc(groupsize);
+  memset(bafh, 0, groupsize);
+  orgbafh = bafh;
+
+  rdir = (ResourceDirectory *)(ihdr + 1);
+  for(i=0;i<ihdr->wCount;i++) {
+        bafh->usType    = BFT_BITMAPARRAY;
+        bafh->cbSize    = sizeof(BITMAPARRAYFILEHEADER2);
+        bafh->cxDisplay = 0;
+        bafh->cyDisplay = 0;
+	hRes = FindResourceA(hInstance, 
+                             (LPCSTR)rdir->wNameOrdinal, (LPSTR)NTRT_ICON);
+        if(hRes == NULL) {
+                dprintf(("Can't find icon!"));
+                rdir++;
+                continue;
+        }
+	iconhdr = (WINBITMAPINFOHEADER *)LockResource(LoadResource(hInstance, hRes));
+	os2icon = ConvertIcon(iconhdr, SizeofResource(hInstance, hRes), &os2iconsize, (ULONG)bafh - (ULONG)orgbafh + sizeof(BITMAPARRAYFILEHEADER2)-sizeof(BITMAPFILEHEADER2));
+        if(os2icon == NULL) {
+                dprintf(("Can't convert icon!"));
+                rdir++;
+                continue;
+        }
+
+        if(i != ihdr->wCount -1) {
+                bafh->offNext = (ULONG)&bafh->bfh2 - (ULONG)orgbafh + os2iconsize;
+        }
+        else    bafh->offNext = 0;
+
+        memcpy((char *)&bafh->bfh2, os2icon, os2iconsize);
+	free(os2icon);
+
+        bafh = (BITMAPARRAYFILEHEADER2 *)((ULONG)&bafh->bfh2 + os2iconsize);
+
+        rdir++;
+  }
+  *ressize = groupsize;
+  return (void *)orgbafh;
+}
+//******************************************************************************
+//******************************************************************************
Index: trunk/src/user32/winicon.cpp
===================================================================
--- trunk/src/user32/winicon.cpp	(revision 6486)
+++ trunk/src/user32/winicon.cpp	(revision 6487)
@@ -1,3 +1,3 @@
-/* $Id: winicon.cpp,v 1.27 2001-07-08 07:15:10 sandervl Exp $ */
+/* $Id: winicon.cpp,v 1.28 2001-08-08 10:07:19 sandervl Exp $ */
 /*
  * Win32 Icon Code for OS/2
@@ -836,6 +836,5 @@
     hotspot.y = ICON_HOTSPOT;
 
-//testestest
-    dprintf(("CURSORICON_CreateFromResource %x %x %x %x %d", hInstance, dwResGroupId, hObj, bits, cbSize));
+    dprintf2(("CURSORICON_CreateFromResource %x %x %x %x %d", hInstance, dwResGroupId, hObj, bits, cbSize));
 
     if (dwVersion == 0x00020000)
