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
9ecc1e07
Commit
9ecc1e07
authored
Jan 10, 2012
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gdi32: Simplify the CreateCompatibleBitmap implementation.
parent
765fca34
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
67 deletions
+23
-67
bitmap.c
dlls/gdi32/bitmap.c
+23
-67
No files found.
dlls/gdi32/bitmap.c
View file @
9ecc1e07
...
@@ -135,78 +135,34 @@ HBITMAP WINAPI CreateBitmap( INT width, INT height, UINT planes,
...
@@ -135,78 +135,34 @@ HBITMAP WINAPI CreateBitmap( INT width, INT height, UINT planes,
*/
*/
HBITMAP
WINAPI
CreateCompatibleBitmap
(
HDC
hdc
,
INT
width
,
INT
height
)
HBITMAP
WINAPI
CreateCompatibleBitmap
(
HDC
hdc
,
INT
width
,
INT
height
)
{
{
HBITMAP
hbmpRet
=
0
;
char
buffer
[
FIELD_OFFSET
(
BITMAPINFO
,
bmiColors
[
256
]
)];
BITMAPINFO
*
bi
=
(
BITMAPINFO
*
)
buffer
;
DIBSECTION
dib
;
TRACE
(
"(%p,%d,%d)
=
\n
"
,
hdc
,
width
,
height
);
TRACE
(
"(%p,%d,%d)
\n
"
,
hdc
,
width
,
height
);
if
(
GetObjectType
(
hdc
)
!=
OBJ_MEMDC
)
if
(
GetObjectType
(
hdc
)
!=
OBJ_MEMDC
)
{
return
CreateBitmap
(
width
,
height
,
hbmpRet
=
CreateBitmap
(
width
,
height
,
GetDeviceCaps
(
hdc
,
PLANES
),
GetDeviceCaps
(
hdc
,
BITSPIXEL
),
NULL
);
GetDeviceCaps
(
hdc
,
PLANES
),
GetDeviceCaps
(
hdc
,
BITSPIXEL
),
NULL
);
}
else
/* Memory DC */
{
DIBSECTION
dib
;
HBITMAP
bitmap
=
GetCurrentObject
(
hdc
,
OBJ_BITMAP
);
INT
size
=
GetObjectW
(
bitmap
,
sizeof
(
dib
),
&
dib
);
if
(
!
size
)
return
0
;
if
(
size
==
sizeof
(
BITMAP
))
{
/* A device-dependent bitmap is selected in the DC */
hbmpRet
=
CreateBitmap
(
width
,
height
,
dib
.
dsBm
.
bmPlanes
,
dib
.
dsBm
.
bmBitsPixel
,
NULL
);
}
else
{
/* A DIB section is selected in the DC */
BITMAPINFO
*
bi
;
void
*
bits
;
/* Allocate memory for a BITMAPINFOHEADER structure and a
color table. The maximum number of colors in a color table
is 256 which corresponds to a bitmap with depth 8.
Bitmaps with higher depths don't have color tables. */
bi
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
BITMAPINFOHEADER
)
+
256
*
sizeof
(
RGBQUAD
));
if
(
bi
)
switch
(
GetObjectW
(
GetCurrentObject
(
hdc
,
OBJ_BITMAP
),
sizeof
(
dib
),
&
dib
))
{
{
bi
->
bmiHeader
.
biSize
=
sizeof
(
bi
->
bmiHeader
);
case
sizeof
(
BITMAP
):
/* A device-dependent bitmap is selected in the DC */
bi
->
bmiHeader
.
biWidth
=
width
;
return
CreateBitmap
(
width
,
height
,
dib
.
dsBm
.
bmPlanes
,
dib
.
dsBm
.
bmBitsPixel
,
NULL
);
bi
->
bmiHeader
.
biHeight
=
height
;
bi
->
bmiHeader
.
biPlanes
=
dib
.
dsBmih
.
biPlanes
;
case
sizeof
(
DIBSECTION
):
/* A DIB section is selected in the DC */
bi
->
bmiHeader
.
biBitCount
=
dib
.
dsBmih
.
biBitCount
;
bi
->
bmiHeader
=
dib
.
dsBmih
;
bi
->
bmiHeader
.
biCompression
=
dib
.
dsBmih
.
biCompression
;
bi
->
bmiHeader
.
biWidth
=
width
;
bi
->
bmiHeader
.
biSizeImage
=
0
;
bi
->
bmiHeader
.
biHeight
=
height
;
bi
->
bmiHeader
.
biXPelsPerMeter
=
dib
.
dsBmih
.
biXPelsPerMeter
;
if
(
dib
.
dsBmih
.
biCompression
==
BI_BITFIELDS
)
/* copy the color masks */
bi
->
bmiHeader
.
biYPelsPerMeter
=
dib
.
dsBmih
.
biYPelsPerMeter
;
memcpy
(
bi
->
bmiColors
,
dib
.
dsBitfields
,
sizeof
(
dib
.
dsBitfields
));
bi
->
bmiHeader
.
biClrUsed
=
dib
.
dsBmih
.
biClrUsed
;
else
if
(
dib
.
dsBmih
.
biBitCount
<=
8
)
/* copy the color table */
bi
->
bmiHeader
.
biClrImportant
=
dib
.
dsBmih
.
biClrImportant
;
GetDIBColorTable
(
hdc
,
0
,
256
,
bi
->
bmiColors
);
return
CreateDIBSection
(
hdc
,
bi
,
DIB_RGB_COLORS
,
NULL
,
NULL
,
0
);
if
(
bi
->
bmiHeader
.
biCompression
==
BI_BITFIELDS
)
{
default:
/* Copy the color masks */
return
0
;
CopyMemory
(
bi
->
bmiColors
,
dib
.
dsBitfields
,
3
*
sizeof
(
DWORD
));
}
else
if
(
bi
->
bmiHeader
.
biBitCount
<=
8
)
{
/* Copy the color table */
GetDIBColorTable
(
hdc
,
0
,
256
,
bi
->
bmiColors
);
}
hbmpRet
=
CreateDIBSection
(
hdc
,
bi
,
DIB_RGB_COLORS
,
&
bits
,
NULL
,
0
);
HeapFree
(
GetProcessHeap
(),
0
,
bi
);
}
}
}
}
TRACE
(
"
\t\t
%p
\n
"
,
hbmpRet
);
return
hbmpRet
;
}
}
...
...
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