mirror of
https://github.com/VincentWei/MiniGUI.git
synced 2026-10-01 12:23:22 +08:00
tune code for 64b (MiniGUI-Processes runmode)
This commit is contained in:
@@ -18,7 +18,7 @@ libkernel_la_SOURCES = timer.c \
|
||||
endif
|
||||
# hash.c
|
||||
|
||||
EXTRA_DIST= desktop.c desktop-comm.c makefile.ng makefile.msvc
|
||||
EXTRA_DIST= desktop.c desktop-comm.c cursor-comm.c makefile.ng makefile.msvc
|
||||
|
||||
# for makefile.ng and makefile.msvc
|
||||
LIB_NAME = libkernel
|
||||
|
||||
@@ -0,0 +1,174 @@
|
||||
|
||||
static HCURSOR load_cursor_from_file (const char* filename)
|
||||
{
|
||||
FILE* fp;
|
||||
WORD16 wTemp;
|
||||
int w, h, xhot, yhot, colornum;
|
||||
#if 0
|
||||
DWORD32 size;
|
||||
#endif
|
||||
DWORD32 offset, imagesize, imagew, imageh;
|
||||
BYTE* image;
|
||||
HCURSOR csr = 0;
|
||||
|
||||
if (!(fp = fopen(filename, "rb")))
|
||||
return 0;
|
||||
|
||||
fseek(fp, sizeof(WORD16), SEEK_SET);
|
||||
|
||||
/* the cbType of struct CURSORDIR. */
|
||||
wTemp = MGUI_ReadLE16FP (fp);
|
||||
if(wTemp != 2) {
|
||||
_MG_PRINTF ("LoadCursorFromFile: bad file type: %d\n", wTemp);
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* skip the cdCount of struct CURSORDIR, we always use the first cursor. */
|
||||
fseek(fp, sizeof(WORD16), SEEK_CUR);
|
||||
|
||||
/* cursor info, read the members of struct CURSORDIRENTRY. */
|
||||
w = fgetc (fp); /* the width of first cursor. */
|
||||
h = fgetc (fp); /* the height of first cursor. */
|
||||
if (w != CURSORWIDTH || h != CURSORHEIGHT) {
|
||||
_MG_PRINTF ("LoadCursorFromFile: bad first cursor width (%d) and height (%d)\n", w, h);
|
||||
goto error;
|
||||
}
|
||||
|
||||
fseek(fp, sizeof(BYTE)*2, SEEK_CUR); /* skip bColorCount and bReserved. */
|
||||
wTemp = MGUI_ReadLE16FP (fp);
|
||||
xhot = wTemp;
|
||||
wTemp = MGUI_ReadLE16FP (fp);
|
||||
yhot = wTemp;
|
||||
#if 0
|
||||
size = MGUI_ReadLE32FP (fp);
|
||||
#else
|
||||
fseek (fp, sizeof(DWORD32), SEEK_CUR); /* skip size. */
|
||||
#endif
|
||||
offset = MGUI_ReadLE32FP (fp);
|
||||
|
||||
/* read the cursor image info. */
|
||||
fseek(fp, offset, SEEK_SET);
|
||||
fseek(fp, sizeof(DWORD32), SEEK_CUR); /* skip the biSize member. */
|
||||
imagew = MGUI_ReadLE32FP (fp);
|
||||
imageh = MGUI_ReadLE32FP (fp);
|
||||
if (imagew != CURSORWIDTH || imageh != (CURSORHEIGHT*2)) {
|
||||
_MG_PRINTF ("LoadCursorFromFile: bad cursor image width (%d) and height (%d)\n", imagew, imageh);
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* check the biPlanes member; */
|
||||
wTemp = MGUI_ReadLE16FP (fp);
|
||||
if (wTemp != 1) {
|
||||
_MG_PRINTF ("LoadCursorFromFile: bad planes (%d)\n", wTemp);
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* check the biBitCount member; */
|
||||
wTemp = MGUI_ReadLE16FP (fp);
|
||||
if (wTemp > 4) {
|
||||
_MG_PRINTF ("LoadCursorFromFile: bad bit count (%d)\n", wTemp);
|
||||
goto error;
|
||||
}
|
||||
|
||||
colornum = (int)wTemp;
|
||||
fseek(fp, sizeof(DWORD32), SEEK_CUR); /* skip the biCompression members. */
|
||||
imagesize = MGUI_ReadLE32FP (fp);
|
||||
|
||||
/* skip the rest members and the color table. */
|
||||
fseek(fp, sizeof(DWORD32)*4 + sizeof(BYTE)*(4<<colornum), SEEK_CUR);
|
||||
|
||||
/* allocate memory for image. */
|
||||
if ((image = (BYTE*)ALLOCATE_LOCAL (imagesize)) == NULL) {
|
||||
_MG_PRINTF ("LoadCursorFromFile: error when allocating memory for image (%d)\n", imagesize);
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* read image */
|
||||
if (fread (image, 1, imagesize, fp) < imagesize) {
|
||||
_MG_PRINTF ("LoadCursorFromFile: error when reading data from file\n");
|
||||
goto error;
|
||||
}
|
||||
|
||||
csr = CreateCursor (xhot, yhot, w, h,
|
||||
image + (imagesize - MONOSIZE), image, colornum);
|
||||
|
||||
DEALLOCATE_LOCAL (image);
|
||||
fclose (fp);
|
||||
return csr;
|
||||
|
||||
error:
|
||||
_MG_PRINTF ("LoadCursorFromFile: failed when loading cursor from %s\n", filename);
|
||||
fclose (fp);
|
||||
return csr;
|
||||
}
|
||||
|
||||
static HCURSOR load_cursor_from_mem (const void* area)
|
||||
{
|
||||
const Uint8* p = (Uint8*)area;
|
||||
WORD16 wTemp;
|
||||
|
||||
int w, h, xhot, yhot, colornum;
|
||||
#if 0
|
||||
DWORD32 size;
|
||||
#endif
|
||||
DWORD32 offset, imagesize, imagew, imageh;
|
||||
|
||||
p += sizeof (WORD16);
|
||||
wTemp = MGUI_ReadLE16Mem (&p);
|
||||
if(wTemp != 2) goto error;
|
||||
|
||||
/* skip the cdCount of struct CURSORDIR, we always use the first cursor. */
|
||||
p += sizeof (WORD16);
|
||||
|
||||
/* cursor info, read the members of struct CURSORDIRENTRY. */
|
||||
w = *p++; /* the width of first cursor. */
|
||||
h = *p++; /* the height of first cursor. */
|
||||
if (w != CURSORWIDTH || h != CURSORHEIGHT)
|
||||
goto error;
|
||||
|
||||
/* skip the bColorCount and bReserved. */
|
||||
p += sizeof(BYTE)*2;
|
||||
xhot = MGUI_ReadLE16Mem (&p);
|
||||
yhot = MGUI_ReadLE16Mem (&p);
|
||||
#if 0
|
||||
size = MGUI_ReadLE32Mem (&p);
|
||||
#else
|
||||
p += sizeof(DWORD32); /* skip size. */
|
||||
#endif
|
||||
offset = MGUI_ReadLE32Mem (&p);
|
||||
|
||||
/* read the cursor image info. */
|
||||
p = (Uint8*)area + offset;
|
||||
|
||||
/* skip the biSize member. */
|
||||
p += sizeof (DWORD32);
|
||||
imagew = MGUI_ReadLE32Mem (&p);
|
||||
imageh = MGUI_ReadLE32Mem (&p);
|
||||
if (imagew > 32 || imageh > 32) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* check the biPlanes member; */
|
||||
wTemp = MGUI_ReadLE16Mem (&p);
|
||||
if (wTemp != 1) goto error;
|
||||
|
||||
/* check the biBitCount member; */
|
||||
wTemp = MGUI_ReadLE16Mem (&p);
|
||||
if (wTemp > 4) goto error;
|
||||
colornum = wTemp;
|
||||
|
||||
/* skip the biCompression members. */
|
||||
p += sizeof (DWORD32);
|
||||
imagesize = MGUI_ReadLE32Mem (&p);
|
||||
|
||||
/* skip the rest members and the color table. */
|
||||
p += sizeof(DWORD32)*4 + sizeof(BYTE)*(4<<colornum);
|
||||
|
||||
return CreateCursor (xhot, yhot, w, h,
|
||||
p + (imagesize - MONOSIZE), p, colornum);
|
||||
|
||||
error:
|
||||
_MG_PRINTF ("LoadCursorFromMem: failed when loading cursor from %p\n", area);
|
||||
return 0;
|
||||
}
|
||||
|
||||
+5
-127
@@ -1,13 +1,11 @@
|
||||
/*
|
||||
** $Id: cursor-lite.c 7188 2007-05-16 11:01:59Z weiym $
|
||||
** $Id: cursor-procs.c 7188 2007-05-16 11:01:59Z weiym $
|
||||
**
|
||||
** cursor-lite.c: Cursor support module for MiniGUI-Processes.
|
||||
**
|
||||
** Copyright (C) 2003 ~ 2008 Feynman Software.
|
||||
** Copyright (C) 2003 ~ 2018 FMSoft
|
||||
** Copyright (C) 1999 ~ 2002 Wei Yongming.
|
||||
**
|
||||
** All right reserved by Feynman Software.
|
||||
**
|
||||
** Current maintainer: Wei Yongming.
|
||||
**
|
||||
** Create date: 1999/01/06
|
||||
@@ -226,77 +224,12 @@ HCURSOR GUIAPI CreateCursor (int xhotspot, int yhotspot, int w, int h,
|
||||
}
|
||||
}
|
||||
|
||||
static HCURSOR srvLoadCursorFromFile (const char* filename)
|
||||
{
|
||||
FILE* fp;
|
||||
WORD16 wTemp;
|
||||
int ret = 0;
|
||||
int w, h, xhot, yhot, colornum;
|
||||
DWORD32 size, offset;
|
||||
DWORD32 imagesize, imagew, imageh;
|
||||
BYTE* image;
|
||||
|
||||
if( !(fp = fopen(filename, "rb")) ) return 0;
|
||||
|
||||
fseek(fp, sizeof(WORD16), SEEK_SET);
|
||||
|
||||
/* the cbType of struct CURSORDIR. */
|
||||
wTemp = MGUI_ReadLE16FP (fp);
|
||||
if(wTemp != 2) goto error;
|
||||
|
||||
/* skip the cdCount of struct CURSORDIR, we always use the first cursor. */
|
||||
fseek(fp, sizeof(WORD16), SEEK_CUR);
|
||||
|
||||
/* cursor info, read the members of struct CURSORDIRENTRY. */
|
||||
w = fgetc (fp); /* the width of first cursor. */
|
||||
h = fgetc (fp); /* the height of first cursor. */
|
||||
if (w != CURSORWIDTH || h != CURSORHEIGHT) goto error;
|
||||
fseek(fp, sizeof(BYTE)*2, SEEK_CUR); /* skip bColorCount and bReserved. */
|
||||
wTemp = MGUI_ReadLE16FP (fp);
|
||||
xhot = wTemp;
|
||||
wTemp = MGUI_ReadLE16FP (fp);
|
||||
yhot = wTemp;
|
||||
size = MGUI_ReadLE32FP (fp);
|
||||
offset = MGUI_ReadLE32FP (fp);
|
||||
|
||||
/* read the cursor image info. */
|
||||
fseek(fp, offset, SEEK_SET);
|
||||
fseek(fp, sizeof(DWORD32), SEEK_CUR); /* skip biSize member. */
|
||||
imagew = MGUI_ReadLE32FP (fp);
|
||||
imageh = MGUI_ReadLE32FP (fp);
|
||||
/* check the biPlanes member; */
|
||||
wTemp = MGUI_ReadLE16FP (fp);
|
||||
if(wTemp != 1) goto error;
|
||||
/* check the biBitCount member; */
|
||||
wTemp = MGUI_ReadLE16FP (fp);
|
||||
if(wTemp > 4) goto error;
|
||||
colornum = (int)wTemp;
|
||||
fseek(fp, sizeof(DWORD32), SEEK_CUR); /* skip the biCompression members. */
|
||||
imagesize = MGUI_ReadLE32FP (fp);
|
||||
|
||||
/* skip the rest members and the color table. */
|
||||
fseek(fp, sizeof(DWORD32)*4 + sizeof(BYTE)*(4<<colornum), SEEK_CUR);
|
||||
|
||||
/* allocate memory for image. */
|
||||
if ((image = (BYTE*)ALLOCATE_LOCAL (imagesize)) == NULL)
|
||||
goto error;
|
||||
|
||||
/* read image */
|
||||
fread (image, imagesize, 1, fp);
|
||||
|
||||
ret = srvCreateCursor (xhot, yhot, w, h,
|
||||
image + (imagesize - MONOSIZE), image, colornum);
|
||||
DEALLOCATE_LOCAL (image);
|
||||
|
||||
error:
|
||||
fclose (fp);
|
||||
return ret;
|
||||
}
|
||||
#include "cursor-comm.c"
|
||||
|
||||
HCURSOR GUIAPI LoadCursorFromFile (const char* filename)
|
||||
{
|
||||
if (mgIsServer) {
|
||||
return srvLoadCursorFromFile (filename);
|
||||
return load_cursor_from_file (filename);
|
||||
}
|
||||
else {
|
||||
HCURSOR hcursor;
|
||||
@@ -315,62 +248,7 @@ HCURSOR GUIAPI LoadCursorFromFile (const char* filename)
|
||||
|
||||
HCURSOR GUIAPI LoadCursorFromMem (const void* area)
|
||||
{
|
||||
const Uint8* p = (Uint8*)area;
|
||||
WORD16 wTemp;
|
||||
|
||||
int w, h, xhot, yhot, colornum;
|
||||
DWORD32 size, offset;
|
||||
DWORD32 imagesize, imagew, imageh;
|
||||
|
||||
p += sizeof (WORD16);
|
||||
wTemp = MGUI_ReadLE16Mem (&p);
|
||||
if(wTemp != 2) goto error;
|
||||
|
||||
/* skip the cdCount of struct CURSORDIR, we always use the first cursor. */
|
||||
p += sizeof (WORD16);
|
||||
|
||||
/* cursor info, read the members of struct CURSORDIRENTRY. */
|
||||
w = *p++; /* the width of first cursor. */
|
||||
h = *p++; /* the height of first cursor. */
|
||||
if (w != CURSORWIDTH || h != CURSORHEIGHT)
|
||||
goto error;
|
||||
|
||||
/* skip the bColorCount and bReserved. */
|
||||
p += sizeof(BYTE)*2;
|
||||
xhot = MGUI_ReadLE16Mem (&p);
|
||||
yhot = MGUI_ReadLE16Mem (&p);
|
||||
size = MGUI_ReadLE32Mem (&p);
|
||||
offset = MGUI_ReadLE32Mem (&p);
|
||||
|
||||
/* read the cursor image info. */
|
||||
p = (Uint8*)area + offset;
|
||||
|
||||
/* skip the biSize member. */
|
||||
p += sizeof (DWORD32);
|
||||
imagew = MGUI_ReadLE32Mem (&p);
|
||||
imageh = MGUI_ReadLE32Mem (&p);
|
||||
|
||||
/* check the biPlanes member; */
|
||||
wTemp = MGUI_ReadLE16Mem (&p);
|
||||
if (wTemp != 1) goto error;
|
||||
|
||||
/* check the biBitCount member; */
|
||||
wTemp = MGUI_ReadLE16Mem (&p);
|
||||
if (wTemp > 4) goto error;
|
||||
colornum = wTemp;
|
||||
|
||||
/* skip the biCompression members. */
|
||||
p += sizeof (DWORD32);
|
||||
imagesize = MGUI_ReadLE32Mem (&p);
|
||||
|
||||
/* skip the rest members and the color table. */
|
||||
p += sizeof(DWORD32)*4 + sizeof(BYTE)*(4<<colornum);
|
||||
|
||||
return CreateCursor (xhot, yhot, w, h,
|
||||
p + (imagesize - MONOSIZE), p, colornum);
|
||||
|
||||
error:
|
||||
return 0;
|
||||
return load_cursor_from_mem (area);
|
||||
}
|
||||
|
||||
static BOOL srvDestroyCursor (HCURSOR hcsr)
|
||||
|
||||
+4
-120
@@ -58,132 +58,16 @@ static int nShowCount = 0;
|
||||
static PCURSOR pCurCsr = NULL;
|
||||
|
||||
/* Cursor creating and destroying. */
|
||||
#include "cursor-comm.c"
|
||||
|
||||
HCURSOR GUIAPI LoadCursorFromFile(const char* filename)
|
||||
{
|
||||
FILE* fp;
|
||||
WORD16 wTemp;
|
||||
int w, h, xhot, yhot, colornum;
|
||||
DWORD32 size, offset;
|
||||
DWORD32 imagesize, imagew, imageh;
|
||||
BYTE* image;
|
||||
HCURSOR csr = 0;
|
||||
|
||||
if( !(fp = fopen(filename, "rb")) ) return 0;
|
||||
|
||||
fseek(fp, sizeof(WORD16), SEEK_SET);
|
||||
|
||||
/* the cbType of struct CURSORDIR. */
|
||||
wTemp = MGUI_ReadLE16FP (fp);
|
||||
if(wTemp != 2) goto error;
|
||||
|
||||
/* skip the cdCount of struct CURSORDIR, we always use the first cursor. */
|
||||
fseek(fp, sizeof(WORD16), SEEK_CUR);
|
||||
|
||||
/* cursor info, read the members of struct CURSORDIRENTRY. */
|
||||
w = fgetc (fp); /* the width of first cursor. */
|
||||
h = fgetc (fp); /* the height of first cursor. */
|
||||
if(w != CURSORWIDTH || h != CURSORHEIGHT) goto error;
|
||||
fseek(fp, sizeof(BYTE)*2, SEEK_CUR); /* skip bColorCount and bReserved. */
|
||||
wTemp = MGUI_ReadLE16FP (fp);
|
||||
xhot = wTemp;
|
||||
wTemp = MGUI_ReadLE16FP (fp);
|
||||
yhot = wTemp;
|
||||
size = MGUI_ReadLE32FP (fp);
|
||||
offset = MGUI_ReadLE32FP (fp);
|
||||
|
||||
/* read the cursor image info. */
|
||||
fseek(fp, offset, SEEK_SET);
|
||||
fseek(fp, sizeof(DWORD32), SEEK_CUR); /* skip the biSize member. */
|
||||
imagew = MGUI_ReadLE32FP (fp);
|
||||
imageh = MGUI_ReadLE32FP (fp);
|
||||
/* check the biPlanes member; */
|
||||
wTemp = MGUI_ReadLE16FP (fp);
|
||||
if(wTemp != 1) goto error;
|
||||
/* check the biBitCount member; */
|
||||
wTemp = MGUI_ReadLE16FP (fp);
|
||||
if(wTemp > 4) goto error;
|
||||
colornum = (int)wTemp;
|
||||
fseek(fp, sizeof(DWORD32), SEEK_CUR); /* skip the biCompression members. */
|
||||
imagesize = MGUI_ReadLE32FP (fp);
|
||||
|
||||
/* skip the rest members and the color table. */
|
||||
fseek(fp, sizeof(DWORD32)*4 + sizeof(BYTE)*(4<<colornum), SEEK_CUR);
|
||||
|
||||
/* allocate memory for image. */
|
||||
if ((image = (BYTE*)ALLOCATE_LOCAL (imagesize)) == NULL)
|
||||
goto error;
|
||||
|
||||
/* read image */
|
||||
fread (image, imagesize, 1, fp);
|
||||
|
||||
csr = CreateCursor(xhot, yhot, w, h,
|
||||
image + (imagesize - MONOSIZE), image, colornum);
|
||||
|
||||
DEALLOCATE_LOCAL (image);
|
||||
|
||||
error:
|
||||
fclose (fp);
|
||||
return csr;
|
||||
return load_cursor_from_file (filename);
|
||||
}
|
||||
|
||||
HCURSOR GUIAPI LoadCursorFromMem (const void* area)
|
||||
{
|
||||
const Uint8* p = (Uint8*)area;
|
||||
WORD16 wTemp;
|
||||
|
||||
int w, h, xhot, yhot, colornum;
|
||||
DWORD32 size, offset;
|
||||
DWORD32 imagesize, imagew, imageh;
|
||||
|
||||
p += sizeof (WORD16);
|
||||
wTemp = MGUI_ReadLE16Mem (&p);
|
||||
if(wTemp != 2) goto error;
|
||||
|
||||
/* skip the cdCount of struct CURSORDIR, we always use the first cursor. */
|
||||
p += sizeof (WORD16);
|
||||
|
||||
/* cursor info, read the members of struct CURSORDIRENTRY. */
|
||||
w = *p++; /* the width of first cursor. */
|
||||
h = *p++; /* the height of first cursor. */
|
||||
if (w != CURSORWIDTH || h != CURSORHEIGHT)
|
||||
goto error;
|
||||
|
||||
/* skip the bColorCount and bReserved. */
|
||||
p += sizeof(BYTE)*2;
|
||||
xhot = MGUI_ReadLE16Mem (&p);
|
||||
yhot = MGUI_ReadLE16Mem (&p);
|
||||
size = MGUI_ReadLE32Mem (&p);
|
||||
offset = MGUI_ReadLE32Mem (&p);
|
||||
|
||||
/* read the cursor image info. */
|
||||
p = (Uint8*)area + offset;
|
||||
|
||||
/* skip the biSize member. */
|
||||
p += sizeof (DWORD32);
|
||||
imagew = MGUI_ReadLE32Mem (&p);
|
||||
imageh = MGUI_ReadLE32Mem (&p);
|
||||
|
||||
/* check the biPlanes member; */
|
||||
wTemp = MGUI_ReadLE16Mem (&p);
|
||||
if (wTemp != 1) goto error;
|
||||
|
||||
/* check the biBitCount member; */
|
||||
wTemp = MGUI_ReadLE16Mem (&p);
|
||||
if (wTemp > 4) goto error;
|
||||
colornum = wTemp;
|
||||
|
||||
/* skip the biCompression members. */
|
||||
p += sizeof (DWORD32);
|
||||
imagesize = MGUI_ReadLE32Mem (&p);
|
||||
|
||||
/* skip the rest members and the color table. */
|
||||
p += sizeof(DWORD32)*4 + sizeof(BYTE)*(4<<colornum);
|
||||
|
||||
return CreateCursor (xhot, yhot, w, h,
|
||||
p + (imagesize - MONOSIZE), p, colornum);
|
||||
|
||||
error:
|
||||
return 0;
|
||||
return load_cursor_from_mem (area);
|
||||
}
|
||||
|
||||
static BITMAP csr_bmp = {
|
||||
|
||||
+5
-167
@@ -89,178 +89,16 @@ Uint8* GetPixelUnderCursor (int x, int y, gal_pixel* pixel)
|
||||
}
|
||||
|
||||
/* Cursor creating and destroying. */
|
||||
/* Only called from InitCursor and client code. */
|
||||
HCURSOR GUIAPI LoadCursorFromFile(const char* filename)
|
||||
#include "cursor-comm.c"
|
||||
|
||||
HCURSOR GUIAPI LoadCursorFromFile (const char* filename)
|
||||
{
|
||||
FILE* fp;
|
||||
WORD16 wTemp;
|
||||
int w, h, xhot, yhot, colornum;
|
||||
#if 0
|
||||
DWORD32 size;
|
||||
#endif
|
||||
DWORD32 offset, imagesize, imagew, imageh;
|
||||
BYTE* image;
|
||||
HCURSOR csr = 0;
|
||||
|
||||
if (!(fp = fopen(filename, "rb")))
|
||||
return 0;
|
||||
|
||||
fseek(fp, sizeof(WORD16), SEEK_SET);
|
||||
|
||||
/* the cbType of struct CURSORDIR. */
|
||||
wTemp = MGUI_ReadLE16FP (fp);
|
||||
if(wTemp != 2) {
|
||||
_MG_PRINTF ("LoadCursorFromFile: bad file type: %d\n", wTemp);
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* skip the cdCount of struct CURSORDIR, we always use the first cursor. */
|
||||
fseek(fp, sizeof(WORD16), SEEK_CUR);
|
||||
|
||||
/* cursor info, read the members of struct CURSORDIRENTRY. */
|
||||
w = fgetc (fp); /* the width of first cursor. */
|
||||
h = fgetc (fp); /* the height of first cursor. */
|
||||
if (w != CURSORWIDTH || h != CURSORHEIGHT) {
|
||||
_MG_PRINTF ("LoadCursorFromFile: bad first cursor width (%d) and height (%d)\n", w, h);
|
||||
goto error;
|
||||
}
|
||||
|
||||
fseek(fp, sizeof(BYTE)*2, SEEK_CUR); /* skip bColorCount and bReserved. */
|
||||
wTemp = MGUI_ReadLE16FP (fp);
|
||||
xhot = wTemp;
|
||||
wTemp = MGUI_ReadLE16FP (fp);
|
||||
yhot = wTemp;
|
||||
#if 0
|
||||
size = MGUI_ReadLE32FP (fp);
|
||||
#else
|
||||
fseek (fp, sizeof(DWORD32), SEEK_CUR); /* skip size. */
|
||||
#endif
|
||||
offset = MGUI_ReadLE32FP (fp);
|
||||
|
||||
/* read the cursor image info. */
|
||||
fseek(fp, offset, SEEK_SET);
|
||||
fseek(fp, sizeof(DWORD32), SEEK_CUR); /* skip the biSize member. */
|
||||
imagew = MGUI_ReadLE32FP (fp);
|
||||
imageh = MGUI_ReadLE32FP (fp);
|
||||
if (imagew != CURSORWIDTH || imageh != (CURSORHEIGHT*2)) {
|
||||
_MG_PRINTF ("LoadCursorFromFile: bad cursor image width (%d) and height (%d)\n", imagew, imageh);
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* check the biPlanes member; */
|
||||
wTemp = MGUI_ReadLE16FP (fp);
|
||||
if (wTemp != 1) {
|
||||
_MG_PRINTF ("LoadCursorFromFile: bad planes (%d)\n", wTemp);
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* check the biBitCount member; */
|
||||
wTemp = MGUI_ReadLE16FP (fp);
|
||||
if (wTemp > 4) {
|
||||
_MG_PRINTF ("LoadCursorFromFile: bad bit count (%d)\n", wTemp);
|
||||
goto error;
|
||||
}
|
||||
|
||||
colornum = (int)wTemp;
|
||||
fseek(fp, sizeof(DWORD32), SEEK_CUR); /* skip the biCompression members. */
|
||||
imagesize = MGUI_ReadLE32FP (fp);
|
||||
|
||||
/* skip the rest members and the color table. */
|
||||
fseek(fp, sizeof(DWORD32)*4 + sizeof(BYTE)*(4<<colornum), SEEK_CUR);
|
||||
|
||||
/* allocate memory for image. */
|
||||
if ((image = (BYTE*)ALLOCATE_LOCAL (imagesize)) == NULL) {
|
||||
_MG_PRINTF ("LoadCursorFromFile: error when allocating memory for image (%d)\n", imagesize);
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* read image */
|
||||
if (fread (image, 1, imagesize, fp) < imagesize) {
|
||||
_MG_PRINTF ("LoadCursorFromFile: error when reading data from file\n");
|
||||
goto error;
|
||||
}
|
||||
|
||||
csr = CreateCursor (xhot, yhot, w, h,
|
||||
image + (imagesize - MONOSIZE), image, colornum);
|
||||
|
||||
DEALLOCATE_LOCAL (image);
|
||||
fclose (fp);
|
||||
return csr;
|
||||
|
||||
error:
|
||||
_MG_PRINTF ("LoadCursorFromFile: failed when loading cursor from %s\n", filename);
|
||||
fclose (fp);
|
||||
return csr;
|
||||
return __mgLoadCursorFromFile (filename);
|
||||
}
|
||||
|
||||
HCURSOR GUIAPI LoadCursorFromMem (const void* area)
|
||||
{
|
||||
const Uint8* p = (Uint8*)area;
|
||||
WORD16 wTemp;
|
||||
|
||||
int w, h, xhot, yhot, colornum;
|
||||
#if 0
|
||||
DWORD32 size;
|
||||
#endif
|
||||
DWORD32 offset, imagesize, imagew, imageh;
|
||||
|
||||
p += sizeof (WORD16);
|
||||
wTemp = MGUI_ReadLE16Mem (&p);
|
||||
if(wTemp != 2) goto error;
|
||||
|
||||
/* skip the cdCount of struct CURSORDIR, we always use the first cursor. */
|
||||
p += sizeof (WORD16);
|
||||
|
||||
/* cursor info, read the members of struct CURSORDIRENTRY. */
|
||||
w = *p++; /* the width of first cursor. */
|
||||
h = *p++; /* the height of first cursor. */
|
||||
if (w != CURSORWIDTH || h != CURSORHEIGHT)
|
||||
goto error;
|
||||
|
||||
/* skip the bColorCount and bReserved. */
|
||||
p += sizeof(BYTE)*2;
|
||||
xhot = MGUI_ReadLE16Mem (&p);
|
||||
yhot = MGUI_ReadLE16Mem (&p);
|
||||
#if 0
|
||||
size = MGUI_ReadLE32Mem (&p);
|
||||
#else
|
||||
p += sizeof(DWORD32); /* skip size. */
|
||||
#endif
|
||||
offset = MGUI_ReadLE32Mem (&p);
|
||||
|
||||
/* read the cursor image info. */
|
||||
p = (Uint8*)area + offset;
|
||||
|
||||
/* skip the biSize member. */
|
||||
p += sizeof (DWORD32);
|
||||
imagew = MGUI_ReadLE32Mem (&p);
|
||||
imageh = MGUI_ReadLE32Mem (&p);
|
||||
if (imagew > 32 || imageh > 32) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* check the biPlanes member; */
|
||||
wTemp = MGUI_ReadLE16Mem (&p);
|
||||
if (wTemp != 1) goto error;
|
||||
|
||||
/* check the biBitCount member; */
|
||||
wTemp = MGUI_ReadLE16Mem (&p);
|
||||
if (wTemp > 4) goto error;
|
||||
colornum = wTemp;
|
||||
|
||||
/* skip the biCompression members. */
|
||||
p += sizeof (DWORD32);
|
||||
imagesize = MGUI_ReadLE32Mem (&p);
|
||||
|
||||
/* skip the rest members and the color table. */
|
||||
p += sizeof(DWORD32)*4 + sizeof(BYTE)*(4<<colornum);
|
||||
|
||||
return CreateCursor (xhot, yhot, w, h,
|
||||
p + (imagesize - MONOSIZE), p, colornum);
|
||||
|
||||
error:
|
||||
_MG_PRINTF ("LoadCursorFromMem: failed when loading cursor from %p\n", area);
|
||||
return 0;
|
||||
return __mgLoadCursorFromMem (area);
|
||||
}
|
||||
|
||||
static BITMAP csr_bmp = {
|
||||
|
||||
+75
-75
File diff suppressed because it is too large
Load Diff
@@ -2558,8 +2558,7 @@ static int dskMoveWindow (int cli, int idx_znode, const RECT* rcWin)
|
||||
nodes [idx_znode].age ++;
|
||||
|
||||
#if defined (_MGRM_PROCESSES) && !defined (_MGRM_STANDALONE)
|
||||
if (cli == 0
|
||||
|| (DWORD)mgClients [cli].layer == SHAREDRES_TOPMOST_LAYER) {
|
||||
if (cli == 0 || mgClients [cli].layer == SHAREDRES_TOPMOST_LAYER) {
|
||||
#endif
|
||||
/* Copy window content to new postion */
|
||||
InitClipRgn (&bblt_rgn, &sg_FreeClipRectList);
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "timer.h"
|
||||
|
||||
#ifdef _MGRM_PROCESSES
|
||||
#include "ourhdr.h"
|
||||
#include "client.h"
|
||||
#include "sharedres.h"
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user