Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
53145d96
Commit
53145d96
authored
Jan 13, 2004
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved some code around to avoid exporting DIB functions from gdi32.
parent
d160d46c
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
204 additions
and
111 deletions
+204
-111
gdi32.spec
dlls/gdi/gdi32.spec
+0
-4
bitmap.c
dlls/x11drv/bitmap.c
+1
-1
brush.c
dlls/x11drv/brush.c
+1
-1
dib.c
dlls/x11drv/dib.c
+138
-8
x11drv.h
dlls/x11drv/x11drv.h
+5
-0
bitmap.h
include/bitmap.h
+0
-4
dib.c
objects/dib.c
+0
-86
cursoricon.c
windows/cursoricon.c
+59
-7
No files found.
dlls/gdi/gdi32.spec
View file @
53145d96
...
@@ -442,10 +442,6 @@
...
@@ -442,10 +442,6 @@
# Wine dll separation hacks, these will go away, don't use them
# Wine dll separation hacks, these will go away, don't use them
#
#
@ cdecl DC_GetDCPtr(long)
@ cdecl DC_GetDCPtr(long)
@ cdecl DIB_BitmapInfoSize(ptr long)
@ cdecl DIB_CreateDIBFromBitmap(long long)
@ cdecl DIB_CreateDIBSection(long ptr long ptr long long long)
@ cdecl DIB_CreateDIBSection(long ptr long ptr long long long)
@ cdecl DIB_GetDIBImageBytes(long long long)
@ cdecl DIB_GetDIBWidthBytes(long long)
@ cdecl GDI_GetObjPtr(long long)
@ cdecl GDI_GetObjPtr(long long)
@ cdecl GDI_ReleaseObj(long)
@ cdecl GDI_ReleaseObj(long)
dlls/x11drv/bitmap.c
View file @
53145d96
...
@@ -537,7 +537,7 @@ Pixmap X11DRV_BITMAP_CreatePixmapFromBitmap( HBITMAP hBmp, HDC hdc )
...
@@ -537,7 +537,7 @@ Pixmap X11DRV_BITMAP_CreatePixmapFromBitmap( HBITMAP hBmp, HDC hdc )
* A packed DIB contains a BITMAPINFO structure followed immediately by
* A packed DIB contains a BITMAPINFO structure followed immediately by
* an optional color palette and the pixel data.
* an optional color palette and the pixel data.
*/
*/
hPackedDIB
=
DIB_CreateDIBFromBitmap
(
hdc
,
hBmp
);
hPackedDIB
=
X11DRV_
DIB_CreateDIBFromBitmap
(
hdc
,
hBmp
);
/* Create a Pixmap from the packed DIB */
/* Create a Pixmap from the packed DIB */
pixmap
=
X11DRV_DIB_CreatePixmapFromDIB
(
hPackedDIB
,
hdc
);
pixmap
=
X11DRV_DIB_CreatePixmapFromDIB
(
hPackedDIB
,
hdc
);
...
...
dlls/x11drv/brush.c
View file @
53145d96
...
@@ -273,7 +273,7 @@ HBRUSH X11DRV_SelectBrush( X11DRV_PDEVICE *physDev, HBRUSH hbrush )
...
@@ -273,7 +273,7 @@ HBRUSH X11DRV_SelectBrush( X11DRV_PDEVICE *physDev, HBRUSH hbrush )
TRACE
(
"BS_DIBPATTERN
\n
"
);
TRACE
(
"BS_DIBPATTERN
\n
"
);
if
((
bmpInfo
=
(
BITMAPINFO
*
)
GlobalLock16
(
(
HGLOBAL16
)
logbrush
.
lbHatch
)))
if
((
bmpInfo
=
(
BITMAPINFO
*
)
GlobalLock16
(
(
HGLOBAL16
)
logbrush
.
lbHatch
)))
{
{
int
size
=
DIB_BitmapInfoSize
(
bmpInfo
,
logbrush
.
lbColor
);
int
size
=
X11DRV_
DIB_BitmapInfoSize
(
bmpInfo
,
logbrush
.
lbColor
);
hBitmap
=
CreateDIBitmap
(
physDev
->
hdc
,
&
bmpInfo
->
bmiHeader
,
hBitmap
=
CreateDIBitmap
(
physDev
->
hdc
,
&
bmpInfo
->
bmiHeader
,
CBM_INIT
,
((
char
*
)
bmpInfo
)
+
size
,
CBM_INIT
,
((
char
*
)
bmpInfo
)
+
size
,
bmpInfo
,
bmpInfo
,
...
...
dlls/x11drv/dib.c
View file @
53145d96
...
@@ -113,6 +113,60 @@ inline static int X11DRV_DIB_GetXImageWidthBytes( int width, int depth )
...
@@ -113,6 +113,60 @@ inline static int X11DRV_DIB_GetXImageWidthBytes( int width, int depth )
/***********************************************************************
/***********************************************************************
* X11DRV_DIB_GetDIBWidthBytes
*
* Return the width of a DIB bitmap in bytes. DIB bitmap data is 32-bit aligned.
*/
static
int
X11DRV_DIB_GetDIBWidthBytes
(
int
width
,
int
depth
)
{
int
words
;
switch
(
depth
)
{
case
1
:
words
=
(
width
+
31
)
/
32
;
break
;
case
4
:
words
=
(
width
+
7
)
/
8
;
break
;
case
8
:
words
=
(
width
+
3
)
/
4
;
break
;
case
15
:
case
16
:
words
=
(
width
+
1
)
/
2
;
break
;
case
24
:
words
=
(
width
*
3
+
3
)
/
4
;
break
;
default:
WARN
(
"(%d): Unsupported depth
\n
"
,
depth
);
/* fall through */
case
32
:
words
=
width
;
}
return
4
*
words
;
}
/***********************************************************************
* X11DRV_DIB_BitmapInfoSize
*
* Return the size of the bitmap info structure including color table.
*/
int
X11DRV_DIB_BitmapInfoSize
(
const
BITMAPINFO
*
info
,
WORD
coloruse
)
{
int
colors
;
if
(
info
->
bmiHeader
.
biSize
==
sizeof
(
BITMAPCOREHEADER
))
{
BITMAPCOREHEADER
*
core
=
(
BITMAPCOREHEADER
*
)
info
;
colors
=
(
core
->
bcBitCount
<=
8
)
?
1
<<
core
->
bcBitCount
:
0
;
return
sizeof
(
BITMAPCOREHEADER
)
+
colors
*
((
coloruse
==
DIB_RGB_COLORS
)
?
sizeof
(
RGBTRIPLE
)
:
sizeof
(
WORD
));
}
else
/* assume BITMAPINFOHEADER */
{
colors
=
info
->
bmiHeader
.
biClrUsed
;
if
(
!
colors
&&
(
info
->
bmiHeader
.
biBitCount
<=
8
))
colors
=
1
<<
info
->
bmiHeader
.
biBitCount
;
return
sizeof
(
BITMAPINFOHEADER
)
+
colors
*
((
coloruse
==
DIB_RGB_COLORS
)
?
sizeof
(
RGBQUAD
)
:
sizeof
(
WORD
));
}
}
/***********************************************************************
* X11DRV_DIB_CreateXImage
* X11DRV_DIB_CreateXImage
*
*
* Create an X image.
* Create an X image.
...
@@ -3829,10 +3883,9 @@ INT X11DRV_GetDIBits( X11DRV_PDEVICE *physDev, HBITMAP hbitmap, UINT startscan,
...
@@ -3829,10 +3883,9 @@ INT X11DRV_GetDIBits( X11DRV_PDEVICE *physDev, HBITMAP hbitmap, UINT startscan,
X11DRV_DIB_Unlock
(
bmp
,
TRUE
);
X11DRV_DIB_Unlock
(
bmp
,
TRUE
);
if
(
info
->
bmiHeader
.
biSizeImage
==
0
)
/* Fill in biSizeImage */
if
(
info
->
bmiHeader
.
biSizeImage
==
0
)
/* Fill in biSizeImage */
info
->
bmiHeader
.
biSizeImage
=
DIB_GetDIBImageBytes
(
info
->
bmiHeader
.
biSizeImage
=
X11DRV_DIB_GetDIBWidthBytes
(
info
->
bmiHeader
.
biWidth
,
info
->
bmiHeader
.
biWidth
,
info
->
bmiHeader
.
biBitCount
)
info
->
bmiHeader
.
biHeight
,
*
abs
(
info
->
bmiHeader
.
biHeight
);
info
->
bmiHeader
.
biBitCount
);
if
(
descr
.
compression
==
BI_BITFIELDS
)
if
(
descr
.
compression
==
BI_BITFIELDS
)
{
{
...
@@ -4475,8 +4528,7 @@ HBITMAP X11DRV_DIB_CreateDIBSection(
...
@@ -4475,8 +4528,7 @@ HBITMAP X11DRV_DIB_CreateDIBSection(
bm
.
bmType
=
0
;
bm
.
bmType
=
0
;
bm
.
bmWidth
=
bi
->
biWidth
;
bm
.
bmWidth
=
bi
->
biWidth
;
bm
.
bmHeight
=
effHeight
;
bm
.
bmHeight
=
effHeight
;
bm
.
bmWidthBytes
=
ovr_pitch
?
ovr_pitch
bm
.
bmWidthBytes
=
ovr_pitch
?
ovr_pitch
:
X11DRV_DIB_GetDIBWidthBytes
(
bm
.
bmWidth
,
bi
->
biBitCount
);
:
DIB_GetDIBWidthBytes
(
bm
.
bmWidth
,
bi
->
biBitCount
);
bm
.
bmPlanes
=
bi
->
biPlanes
;
bm
.
bmPlanes
=
bi
->
biPlanes
;
bm
.
bmBitsPixel
=
bi
->
biBitCount
;
bm
.
bmBitsPixel
=
bi
->
biBitCount
;
bm
.
bmBits
=
NULL
;
bm
.
bmBits
=
NULL
;
...
@@ -4711,6 +4763,84 @@ UINT X11DRV_GetDIBColorTable( X11DRV_PDEVICE *physDev, UINT start, UINT count, R
...
@@ -4711,6 +4763,84 @@ UINT X11DRV_GetDIBColorTable( X11DRV_PDEVICE *physDev, UINT start, UINT count, R
}
}
/***********************************************************************
* X11DRV_DIB_CreateDIBFromBitmap
*
* Allocates a packed DIB and copies the bitmap data into it.
*/
HGLOBAL
X11DRV_DIB_CreateDIBFromBitmap
(
HDC
hdc
,
HBITMAP
hBmp
)
{
BITMAP
bmp
;
HGLOBAL
hPackedDIB
;
LPBYTE
pPackedDIB
;
LPBITMAPINFOHEADER
pbmiHeader
;
unsigned
int
cDataSize
,
cPackedSize
,
OffsetBits
,
nLinesCopied
;
if
(
!
GetObjectW
(
hBmp
,
sizeof
(
bmp
),
&
bmp
))
return
0
;
/*
* A packed DIB contains a BITMAPINFO structure followed immediately by
* an optional color palette and the pixel data.
*/
/* Calculate the size of the packed DIB */
cDataSize
=
X11DRV_DIB_GetDIBWidthBytes
(
bmp
.
bmWidth
,
bmp
.
bmBitsPixel
)
*
abs
(
bmp
.
bmHeight
);
cPackedSize
=
sizeof
(
BITMAPINFOHEADER
)
+
(
(
bmp
.
bmBitsPixel
<=
8
)
?
(
sizeof
(
RGBQUAD
)
*
(
1
<<
bmp
.
bmBitsPixel
))
:
0
)
+
cDataSize
;
/* Get the offset to the bits */
OffsetBits
=
cPackedSize
-
cDataSize
;
/* Allocate the packed DIB */
TRACE
(
"
\t
Allocating packed DIB of size %d
\n
"
,
cPackedSize
);
hPackedDIB
=
GlobalAlloc
(
GMEM_MOVEABLE
|
GMEM_DDESHARE
/*| GMEM_ZEROINIT*/
,
cPackedSize
);
if
(
!
hPackedDIB
)
{
WARN
(
"Could not allocate packed DIB!
\n
"
);
return
0
;
}
/* A packed DIB starts with a BITMAPINFOHEADER */
pPackedDIB
=
GlobalLock
(
hPackedDIB
);
pbmiHeader
=
(
LPBITMAPINFOHEADER
)
pPackedDIB
;
/* Init the BITMAPINFOHEADER */
pbmiHeader
->
biSize
=
sizeof
(
BITMAPINFOHEADER
);
pbmiHeader
->
biWidth
=
bmp
.
bmWidth
;
pbmiHeader
->
biHeight
=
bmp
.
bmHeight
;
pbmiHeader
->
biPlanes
=
1
;
pbmiHeader
->
biBitCount
=
bmp
.
bmBitsPixel
;
pbmiHeader
->
biCompression
=
BI_RGB
;
pbmiHeader
->
biSizeImage
=
0
;
pbmiHeader
->
biXPelsPerMeter
=
pbmiHeader
->
biYPelsPerMeter
=
0
;
pbmiHeader
->
biClrUsed
=
0
;
pbmiHeader
->
biClrImportant
=
0
;
/* Retrieve the DIB bits from the bitmap and fill in the
* DIB color table if present */
nLinesCopied
=
GetDIBits
(
hdc
,
/* Handle to device context */
hBmp
,
/* Handle to bitmap */
0
,
/* First scan line to set in dest bitmap */
bmp
.
bmHeight
,
/* Number of scan lines to copy */
pPackedDIB
+
OffsetBits
,
/* [out] Address of array for bitmap bits */
(
LPBITMAPINFO
)
pbmiHeader
,
/* [out] Address of BITMAPINFO structure */
0
);
/* RGB or palette index */
GlobalUnlock
(
hPackedDIB
);
/* Cleanup if GetDIBits failed */
if
(
nLinesCopied
!=
bmp
.
bmHeight
)
{
TRACE
(
"
\t
GetDIBits returned %d. Actual lines=%d
\n
"
,
nLinesCopied
,
bmp
.
bmHeight
);
GlobalFree
(
hPackedDIB
);
hPackedDIB
=
0
;
}
return
hPackedDIB
;
}
/**************************************************************************
/**************************************************************************
* X11DRV_DIB_CreateDIBFromPixmap
* X11DRV_DIB_CreateDIBFromPixmap
*
*
...
@@ -4736,7 +4866,7 @@ HGLOBAL X11DRV_DIB_CreateDIBFromPixmap(Pixmap pixmap, HDC hdc, BOOL bDeletePixma
...
@@ -4736,7 +4866,7 @@ HGLOBAL X11DRV_DIB_CreateDIBFromPixmap(Pixmap pixmap, HDC hdc, BOOL bDeletePixma
* A packed DIB contains a BITMAPINFO structure followed immediately by
* A packed DIB contains a BITMAPINFO structure followed immediately by
* an optional color palette and the pixel data.
* an optional color palette and the pixel data.
*/
*/
hPackedDIB
=
DIB_CreateDIBFromBitmap
(
hdc
,
hBmp
);
hPackedDIB
=
X11DRV_
DIB_CreateDIBFromBitmap
(
hdc
,
hBmp
);
/* Get a pointer to the BITMAPOBJ structure */
/* Get a pointer to the BITMAPOBJ structure */
pBmp
=
(
BITMAPOBJ
*
)
GDI_GetObjPtr
(
hBmp
,
BITMAP_MAGIC
);
pBmp
=
(
BITMAPOBJ
*
)
GDI_GetObjPtr
(
hBmp
,
BITMAP_MAGIC
);
...
@@ -4779,7 +4909,7 @@ Pixmap X11DRV_DIB_CreatePixmapFromDIB( HGLOBAL hPackedDIB, HDC hdc )
...
@@ -4779,7 +4909,7 @@ Pixmap X11DRV_DIB_CreatePixmapFromDIB( HGLOBAL hPackedDIB, HDC hdc )
pbmiHeader
=
(
LPBITMAPINFOHEADER
)
pPackedDIB
;
pbmiHeader
=
(
LPBITMAPINFOHEADER
)
pPackedDIB
;
pbmi
=
(
LPBITMAPINFO
)
pPackedDIB
;
pbmi
=
(
LPBITMAPINFO
)
pPackedDIB
;
pbits
=
(
LPBYTE
)(
pPackedDIB
pbits
=
(
LPBYTE
)(
pPackedDIB
+
DIB_BitmapInfoSize
(
(
LPBITMAPINFO
)
pbmiHeader
,
DIB_RGB_COLORS
));
+
X11DRV_
DIB_BitmapInfoSize
(
(
LPBITMAPINFO
)
pbmiHeader
,
DIB_RGB_COLORS
));
/* Create a DDB from the DIB */
/* Create a DDB from the DIB */
...
...
dlls/x11drv/x11drv.h
View file @
53145d96
...
@@ -194,9 +194,11 @@ extern BOOL X11DRV_BITMAP_Init(void);
...
@@ -194,9 +194,11 @@ extern BOOL X11DRV_BITMAP_Init(void);
extern
void
X11DRV_FONT_Init
(
int
*
log_pixels_x
,
int
*
log_pixels_y
);
extern
void
X11DRV_FONT_Init
(
int
*
log_pixels_x
,
int
*
log_pixels_y
);
struct
tagBITMAPOBJ
;
struct
tagBITMAPOBJ
;
extern
int
X11DRV_DIB_BitmapInfoSize
(
const
BITMAPINFO
*
info
,
WORD
coloruse
);
extern
XImage
*
X11DRV_BITMAP_GetXImage
(
const
struct
tagBITMAPOBJ
*
bmp
);
extern
XImage
*
X11DRV_BITMAP_GetXImage
(
const
struct
tagBITMAPOBJ
*
bmp
);
extern
XImage
*
X11DRV_DIB_CreateXImage
(
int
width
,
int
height
,
int
depth
);
extern
XImage
*
X11DRV_DIB_CreateXImage
(
int
width
,
int
height
,
int
depth
);
extern
HBITMAP
X11DRV_BITMAP_CreateBitmapHeaderFromPixmap
(
Pixmap
pixmap
);
extern
HBITMAP
X11DRV_BITMAP_CreateBitmapHeaderFromPixmap
(
Pixmap
pixmap
);
extern
HGLOBAL
X11DRV_DIB_CreateDIBFromBitmap
(
HDC
hdc
,
HBITMAP
hBmp
);
extern
HGLOBAL
X11DRV_DIB_CreateDIBFromPixmap
(
Pixmap
pixmap
,
HDC
hdc
,
BOOL
bDeletePixmap
);
extern
HGLOBAL
X11DRV_DIB_CreateDIBFromPixmap
(
Pixmap
pixmap
,
HDC
hdc
,
BOOL
bDeletePixmap
);
extern
HBITMAP
X11DRV_BITMAP_CreateBitmapFromPixmap
(
Pixmap
pixmap
,
BOOL
bDeletePixmap
);
extern
HBITMAP
X11DRV_BITMAP_CreateBitmapFromPixmap
(
Pixmap
pixmap
,
BOOL
bDeletePixmap
);
extern
Pixmap
X11DRV_DIB_CreatePixmapFromDIB
(
HGLOBAL
hPackedDIB
,
HDC
hdc
);
extern
Pixmap
X11DRV_DIB_CreatePixmapFromDIB
(
HGLOBAL
hPackedDIB
,
HDC
hdc
);
...
@@ -268,6 +270,9 @@ typedef struct
...
@@ -268,6 +270,9 @@ typedef struct
}
X11DRV_DIBSECTION
;
}
X11DRV_DIBSECTION
;
/* DIB Section sync state */
enum
{
DIB_Status_None
,
DIB_Status_InSync
,
DIB_Status_GdiMod
,
DIB_Status_AppMod
,
DIB_Status_AuxMod
};
extern
int
*
X11DRV_DIB_BuildColorMap
(
X11DRV_PDEVICE
*
physDev
,
WORD
coloruse
,
extern
int
*
X11DRV_DIB_BuildColorMap
(
X11DRV_PDEVICE
*
physDev
,
WORD
coloruse
,
WORD
depth
,
const
BITMAPINFO
*
info
,
WORD
depth
,
const
BITMAPINFO
*
info
,
int
*
nColors
);
int
*
nColors
);
...
...
include/bitmap.h
View file @
53145d96
...
@@ -23,9 +23,6 @@
...
@@ -23,9 +23,6 @@
#include <gdi.h>
#include <gdi.h>
/* DIB Section sync state */
enum
{
DIB_Status_None
,
DIB_Status_InSync
,
DIB_Status_GdiMod
,
DIB_Status_AppMod
,
DIB_Status_AuxMod
};
/* GDI logical bitmap object */
/* GDI logical bitmap object */
typedef
struct
tagBITMAPOBJ
typedef
struct
tagBITMAPOBJ
{
{
...
@@ -51,6 +48,5 @@ extern HBITMAP DIB_CreateDIBSection( HDC hdc, BITMAPINFO *bmi, UINT usage, LPVOI
...
@@ -51,6 +48,5 @@ extern HBITMAP DIB_CreateDIBSection( HDC hdc, BITMAPINFO *bmi, UINT usage, LPVOI
HANDLE
section
,
DWORD
offset
,
DWORD
ovr_pitch
);
HANDLE
section
,
DWORD
offset
,
DWORD
ovr_pitch
);
extern
void
DIB_UpdateDIBSection
(
DC
*
dc
,
BOOL
toDIB
);
extern
void
DIB_UpdateDIBSection
(
DC
*
dc
,
BOOL
toDIB
);
extern
void
DIB_SelectDIBSection
(
DC
*
dc
,
BITMAPOBJ
*
bmp
);
extern
void
DIB_SelectDIBSection
(
DC
*
dc
,
BITMAPOBJ
*
bmp
);
extern
HGLOBAL
DIB_CreateDIBFromBitmap
(
HDC
hdc
,
HBITMAP
hBmp
);
#endif
/* __WINE_BITMAP_H */
#endif
/* __WINE_BITMAP_H */
objects/dib.c
View file @
53145d96
...
@@ -921,89 +921,3 @@ HBITMAP WINAPI CreateDIBSection(HDC hdc, BITMAPINFO *bmi, UINT usage,
...
@@ -921,89 +921,3 @@ HBITMAP WINAPI CreateDIBSection(HDC hdc, BITMAPINFO *bmi, UINT usage,
{
{
return
DIB_CreateDIBSection
(
hdc
,
bmi
,
usage
,
bits
,
section
,
offset
,
0
);
return
DIB_CreateDIBSection
(
hdc
,
bmi
,
usage
,
bits
,
section
,
offset
,
0
);
}
}
/***********************************************************************
* DIB_CreateDIBFromBitmap
* Allocates a packed DIB and copies the bitmap data into it.
*/
HGLOBAL
DIB_CreateDIBFromBitmap
(
HDC
hdc
,
HBITMAP
hBmp
)
{
BITMAPOBJ
*
pBmp
=
NULL
;
HGLOBAL
hPackedDIB
=
0
;
LPBYTE
pPackedDIB
=
NULL
;
LPBITMAPINFOHEADER
pbmiHeader
=
NULL
;
unsigned
int
width
,
height
,
depth
,
cDataSize
=
0
,
cPackedSize
=
0
,
OffsetBits
=
0
,
nLinesCopied
=
0
;
/* Get a pointer to the BITMAPOBJ structure */
pBmp
=
(
BITMAPOBJ
*
)
GDI_GetObjPtr
(
hBmp
,
BITMAP_MAGIC
);
if
(
!
pBmp
)
return
hPackedDIB
;
/* Get the bitmap dimensions */
width
=
pBmp
->
bitmap
.
bmWidth
;
height
=
pBmp
->
bitmap
.
bmHeight
;
depth
=
pBmp
->
bitmap
.
bmBitsPixel
;
/*
* A packed DIB contains a BITMAPINFO structure followed immediately by
* an optional color palette and the pixel data.
*/
/* Calculate the size of the packed DIB */
cDataSize
=
DIB_GetDIBImageBytes
(
width
,
height
,
depth
);
cPackedSize
=
sizeof
(
BITMAPINFOHEADER
)
+
(
(
depth
<=
8
)
?
(
sizeof
(
RGBQUAD
)
*
(
1
<<
depth
))
:
0
)
+
cDataSize
;
/* Get the offset to the bits */
OffsetBits
=
cPackedSize
-
cDataSize
;
/* Allocate the packed DIB */
TRACE
(
"
\t
Allocating packed DIB of size %d
\n
"
,
cPackedSize
);
hPackedDIB
=
GlobalAlloc
(
GMEM_MOVEABLE
|
GMEM_DDESHARE
/*| GMEM_ZEROINIT*/
,
cPackedSize
);
if
(
!
hPackedDIB
)
{
WARN
(
"Could not allocate packed DIB!
\n
"
);
goto
END
;
}
/* A packed DIB starts with a BITMAPINFOHEADER */
pPackedDIB
=
(
LPBYTE
)
GlobalLock
(
hPackedDIB
);
pbmiHeader
=
(
LPBITMAPINFOHEADER
)
pPackedDIB
;
/* Init the BITMAPINFOHEADER */
pbmiHeader
->
biSize
=
sizeof
(
BITMAPINFOHEADER
);
pbmiHeader
->
biWidth
=
width
;
pbmiHeader
->
biHeight
=
height
;
pbmiHeader
->
biPlanes
=
1
;
pbmiHeader
->
biBitCount
=
depth
;
pbmiHeader
->
biCompression
=
BI_RGB
;
pbmiHeader
->
biSizeImage
=
0
;
pbmiHeader
->
biXPelsPerMeter
=
pbmiHeader
->
biYPelsPerMeter
=
0
;
pbmiHeader
->
biClrUsed
=
0
;
pbmiHeader
->
biClrImportant
=
0
;
/* Retrieve the DIB bits from the bitmap and fill in the
* DIB color table if present */
nLinesCopied
=
GetDIBits
(
hdc
,
/* Handle to device context */
hBmp
,
/* Handle to bitmap */
0
,
/* First scan line to set in dest bitmap */
height
,
/* Number of scan lines to copy */
pPackedDIB
+
OffsetBits
,
/* [out] Address of array for bitmap bits */
(
LPBITMAPINFO
)
pbmiHeader
,
/* [out] Address of BITMAPINFO structure */
0
);
/* RGB or palette index */
GlobalUnlock
(
hPackedDIB
);
/* Cleanup if GetDIBits failed */
if
(
nLinesCopied
!=
height
)
{
TRACE
(
"
\t
GetDIBits returned %d. Actual lines=%d
\n
"
,
nLinesCopied
,
height
);
GlobalFree
(
hPackedDIB
);
hPackedDIB
=
0
;
}
END:
GDI_ReleaseObj
(
hBmp
);
return
hPackedDIB
;
}
windows/cursoricon.c
View file @
53145d96
...
@@ -60,7 +60,6 @@
...
@@ -60,7 +60,6 @@
#include "wine/winbase16.h"
#include "wine/winbase16.h"
#include "wine/winuser16.h"
#include "wine/winuser16.h"
#include "wine/exception.h"
#include "wine/exception.h"
#include "bitmap.h"
#include "cursoricon.h"
#include "cursoricon.h"
#include "module.h"
#include "module.h"
#include "wine/debug.h"
#include "wine/debug.h"
...
@@ -171,6 +170,60 @@ static int get_bitmap_width_bytes( int width, int bpp )
...
@@ -171,6 +170,60 @@ static int get_bitmap_width_bytes( int width, int bpp )
}
}
/***********************************************************************
* get_dib_width_bytes
*
* Return the width of a DIB bitmap in bytes. DIB bitmap data is 32-bit aligned.
*/
static
int
get_dib_width_bytes
(
int
width
,
int
depth
)
{
int
words
;
switch
(
depth
)
{
case
1
:
words
=
(
width
+
31
)
/
32
;
break
;
case
4
:
words
=
(
width
+
7
)
/
8
;
break
;
case
8
:
words
=
(
width
+
3
)
/
4
;
break
;
case
15
:
case
16
:
words
=
(
width
+
1
)
/
2
;
break
;
case
24
:
words
=
(
width
*
3
+
3
)
/
4
;
break
;
default:
WARN
(
"(%d): Unsupported depth
\n
"
,
depth
);
/* fall through */
case
32
:
words
=
width
;
}
return
4
*
words
;
}
/***********************************************************************
* bitmap_info_size
*
* Return the size of the bitmap info structure including color table.
*/
static
int
bitmap_info_size
(
const
BITMAPINFO
*
info
,
WORD
coloruse
)
{
int
colors
;
if
(
info
->
bmiHeader
.
biSize
==
sizeof
(
BITMAPCOREHEADER
))
{
BITMAPCOREHEADER
*
core
=
(
BITMAPCOREHEADER
*
)
info
;
colors
=
(
core
->
bcBitCount
<=
8
)
?
1
<<
core
->
bcBitCount
:
0
;
return
sizeof
(
BITMAPCOREHEADER
)
+
colors
*
((
coloruse
==
DIB_RGB_COLORS
)
?
sizeof
(
RGBTRIPLE
)
:
sizeof
(
WORD
));
}
else
/* assume BITMAPINFOHEADER */
{
colors
=
info
->
bmiHeader
.
biClrUsed
;
if
(
!
colors
&&
(
info
->
bmiHeader
.
biBitCount
<=
8
))
colors
=
1
<<
info
->
bmiHeader
.
biBitCount
;
return
sizeof
(
BITMAPINFOHEADER
)
+
colors
*
((
coloruse
==
DIB_RGB_COLORS
)
?
sizeof
(
RGBQUAD
)
:
sizeof
(
WORD
));
}
}
/**********************************************************************
/**********************************************************************
* CURSORICON_FindSharedIcon
* CURSORICON_FindSharedIcon
*/
*/
...
@@ -539,7 +592,7 @@ static HICON CURSORICON_CreateFromResource( HMODULE16 hModule, HGLOBAL16 hObj, L
...
@@ -539,7 +592,7 @@ static HICON CURSORICON_CreateFromResource( HMODULE16 hModule, HGLOBAL16 hObj, L
hotspot
=
*
pt
;
hotspot
=
*
pt
;
bmi
=
(
BITMAPINFO
*
)(
pt
+
1
);
bmi
=
(
BITMAPINFO
*
)(
pt
+
1
);
}
}
size
=
DIB_BitmapInfoS
ize
(
bmi
,
DIB_RGB_COLORS
);
size
=
bitmap_info_s
ize
(
bmi
,
DIB_RGB_COLORS
);
if
(
!
width
)
width
=
bmi
->
bmiHeader
.
biWidth
;
if
(
!
width
)
width
=
bmi
->
bmiHeader
.
biWidth
;
if
(
!
height
)
height
=
bmi
->
bmiHeader
.
biHeight
/
2
;
if
(
!
height
)
height
=
bmi
->
bmiHeader
.
biHeight
/
2
;
...
@@ -609,9 +662,8 @@ static HICON CURSORICON_CreateFromResource( HMODULE16 hModule, HGLOBAL16 hObj, L
...
@@ -609,9 +662,8 @@ static HICON CURSORICON_CreateFromResource( HMODULE16 hModule, HGLOBAL16 hObj, L
if
(
hXorBits
)
if
(
hXorBits
)
{
{
char
*
xbits
=
(
char
*
)
bmi
+
size
+
char
*
xbits
=
(
char
*
)
bmi
+
size
+
DIB_GetDIBImageBytes
(
bmi
->
bmiHeader
.
biWidth
,
get_dib_width_bytes
(
bmi
->
bmiHeader
.
biWidth
,
bmi
->
bmiHeader
.
biHeight
,
bmi
->
bmiHeader
.
biBitCount
)
*
abs
(
bmi
->
bmiHeader
.
biHeight
)
/
2
;
bmi
->
bmiHeader
.
biBitCount
)
/
2
;
pInfo
->
bmiHeader
.
biBitCount
=
1
;
pInfo
->
bmiHeader
.
biBitCount
=
1
;
if
(
pInfo
->
bmiHeader
.
biSize
==
sizeof
(
BITMAPINFOHEADER
))
if
(
pInfo
->
bmiHeader
.
biSize
==
sizeof
(
BITMAPINFOHEADER
))
...
@@ -1956,13 +2008,13 @@ static HBITMAP BITMAP_Load( HINSTANCE instance,LPCWSTR name, UINT loadflags )
...
@@ -1956,13 +2008,13 @@ static HBITMAP BITMAP_Load( HINSTANCE instance,LPCWSTR name, UINT loadflags )
if
(
!
(
ptr
=
map_fileW
(
name
)))
return
0
;
if
(
!
(
ptr
=
map_fileW
(
name
)))
return
0
;
info
=
(
BITMAPINFO
*
)(
ptr
+
sizeof
(
BITMAPFILEHEADER
));
info
=
(
BITMAPINFO
*
)(
ptr
+
sizeof
(
BITMAPFILEHEADER
));
}
}
size
=
DIB_BitmapInfoS
ize
(
info
,
DIB_RGB_COLORS
);
size
=
bitmap_info_s
ize
(
info
,
DIB_RGB_COLORS
);
if
((
hFix
=
GlobalAlloc
(
0
,
size
)))
fix_info
=
GlobalLock
(
hFix
);
if
((
hFix
=
GlobalAlloc
(
0
,
size
)))
fix_info
=
GlobalLock
(
hFix
);
if
(
fix_info
)
{
if
(
fix_info
)
{
BYTE
pix
;
BYTE
pix
;
memcpy
(
fix_info
,
info
,
size
);
memcpy
(
fix_info
,
info
,
size
);
pix
=
*
((
LPBYTE
)
info
+
DIB_BitmapInfoSize
(
info
,
DIB_RGB_COLORS
)
);
pix
=
*
((
LPBYTE
)
info
+
size
);
DIB_FixColorsToLoadflags
(
fix_info
,
loadflags
,
pix
);
DIB_FixColorsToLoadflags
(
fix_info
,
loadflags
,
pix
);
if
(
!
screen_dc
)
screen_dc
=
CreateDCA
(
"DISPLAY"
,
NULL
,
NULL
,
NULL
);
if
(
!
screen_dc
)
screen_dc
=
CreateDCA
(
"DISPLAY"
,
NULL
,
NULL
,
NULL
);
if
(
screen_dc
)
if
(
screen_dc
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment