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
d5d8a5be
Commit
d5d8a5be
authored
Dec 07, 2007
by
Stefan Dösinger
Committed by
Alexandre Julliard
Dec 12, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gdi32: Test bitmap depths.
parent
aa390e84
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
1 deletion
+67
-1
bitmap.c
dlls/gdi32/bitmap.c
+13
-0
bitmap.c
dlls/gdi32/tests/bitmap.c
+54
-0
bitmap.c
dlls/winex11.drv/bitmap.c
+0
-1
No files found.
dlls/gdi32/bitmap.c
View file @
d5d8a5be
...
...
@@ -263,6 +263,19 @@ HBITMAP WINAPI CreateBitmapIndirect( const BITMAP *bmp )
return
NULL
;
}
/* Windows only uses 1, 4, 8, 16, 24 and 32 bpp */
if
(
bm
.
bmBitsPixel
==
1
)
bm
.
bmBitsPixel
=
1
;
else
if
(
bm
.
bmBitsPixel
<=
4
)
bm
.
bmBitsPixel
=
4
;
else
if
(
bm
.
bmBitsPixel
<=
8
)
bm
.
bmBitsPixel
=
8
;
else
if
(
bm
.
bmBitsPixel
<=
16
)
bm
.
bmBitsPixel
=
16
;
else
if
(
bm
.
bmBitsPixel
<=
24
)
bm
.
bmBitsPixel
=
24
;
else
if
(
bm
.
bmBitsPixel
<=
32
)
bm
.
bmBitsPixel
=
32
;
else
{
WARN
(
"Invalid bmBitsPixel %d, returning ERROR_INVALID_PARAMETER
\n
"
,
bm
.
bmBitsPixel
);
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
NULL
;
}
/* Windows ignores the provided bm.bmWidthBytes */
bm
.
bmWidthBytes
=
BITMAP_GetWidthBytes
(
bm
.
bmWidth
,
bm
.
bmBitsPixel
);
...
...
dlls/gdi32/tests/bitmap.c
View file @
d5d8a5be
...
...
@@ -1557,6 +1557,8 @@ static void test_select_object(void)
HBITMAP
hbm
,
hbm_old
;
INT
planes
,
bpp
,
i
;
DWORD
depths
[]
=
{
8
,
15
,
16
,
24
,
32
};
BITMAP
bm
;
DWORD
bytes
;
hdc
=
GetDC
(
0
);
ok
(
hdc
!=
0
,
"GetDC(0) failed
\n
"
);
...
...
@@ -1617,6 +1619,21 @@ static void test_select_object(void)
}
}
memset
(
&
bm
,
0xAA
,
sizeof
(
bm
));
bytes
=
GetObject
(
hbm
,
sizeof
(
bm
),
&
bm
);
ok
(
bytes
==
sizeof
(
bm
),
"GetObject returned %d
\n
"
,
bytes
);
ok
(
bm
.
bmType
==
0
,
"wrong bmType %d
\n
"
,
bm
.
bmType
);
ok
(
bm
.
bmWidth
==
10
,
"wrong bmWidth %d
\n
"
,
bm
.
bmWidth
);
ok
(
bm
.
bmHeight
==
10
,
"wrong bmHeight %d
\n
"
,
bm
.
bmHeight
);
ok
(
bm
.
bmWidthBytes
==
BITMAP_GetWidthBytes
(
bm
.
bmWidth
,
bm
.
bmBitsPixel
),
"wrong bmWidthBytes %d
\n
"
,
bm
.
bmWidthBytes
);
ok
(
bm
.
bmPlanes
==
planes
,
"wrong bmPlanes %u
\n
"
,
bm
.
bmPlanes
);
if
(
depths
[
i
]
==
15
)
{
ok
(
bm
.
bmBitsPixel
==
16
,
"wrong bmBitsPixel %d(15 bpp special)
\n
"
,
bm
.
bmBitsPixel
);
}
else
{
ok
(
bm
.
bmBitsPixel
==
depths
[
i
],
"wrong bmBitsPixel %d
\n
"
,
bm
.
bmBitsPixel
);
}
ok
(
!
bm
.
bmBits
,
"wrong bmBits %p
\n
"
,
bm
.
bmBits
);
DeleteObject
(
hbm
);
}
...
...
@@ -1658,6 +1675,7 @@ static void test_CreateBitmap(void)
BITMAP
bmp
;
HDC
screenDC
=
GetDC
(
0
);
HDC
hdc
=
CreateCompatibleDC
(
screenDC
);
UINT
i
,
expect
;
/* all of these are the stock monochrome bitmap */
HBITMAP
bm
=
CreateCompatibleBitmap
(
hdc
,
0
,
0
);
...
...
@@ -1716,6 +1734,42 @@ static void test_CreateBitmap(void)
ok
(
bm
!=
0
,
"CreateBitmapIndirect error %u
\n
"
,
GetLastError
());
test_mono_1x1_bmp
(
bm
);
DeleteObject
(
bm
);
/* Test how the bmBitsPixel field is treated */
for
(
i
=
1
;
i
<=
33
;
i
++
)
{
bmp
.
bmType
=
0
;
bmp
.
bmWidth
=
1
;
bmp
.
bmHeight
=
1
;
bmp
.
bmWidthBytes
=
28
;
bmp
.
bmPlanes
=
1
;
bmp
.
bmBitsPixel
=
i
;
bmp
.
bmBits
=
NULL
;
bm
=
CreateBitmapIndirect
(
&
bmp
);
if
(
i
>
32
)
{
DWORD
error
=
GetLastError
();
ok
(
bm
==
0
,
"CreateBitmapIndirect for %d bpp succeeded
\n
"
,
i
);
ok
(
error
==
ERROR_INVALID_PARAMETER
,
"Got error %d, expected ERROR_INVALID_PARAMETER
\n
"
,
error
);
continue
;
}
ok
(
bm
!=
0
,
"CreateBitmapIndirect error %u
\n
"
,
GetLastError
());
GetObject
(
bm
,
sizeof
(
bmp
),
&
bmp
);
if
(
i
==
1
)
{
expect
=
1
;
}
else
if
(
i
<=
4
)
{
expect
=
4
;
}
else
if
(
i
<=
8
)
{
expect
=
8
;
}
else
if
(
i
<=
16
)
{
expect
=
16
;
}
else
if
(
i
<=
24
)
{
expect
=
24
;
}
else
if
(
i
<=
32
)
{
expect
=
32
;
}
ok
(
bmp
.
bmBitsPixel
==
expect
,
"CreateBitmapIndirect for a %d bpp bitmap created a %d bpp bitmap, expected %d
\n
"
,
i
,
bmp
.
bmBitsPixel
,
expect
);
DeleteObject
(
bm
);
}
}
static
void
test_bitmapinfoheadersize
(
void
)
...
...
dlls/winex11.drv/bitmap.c
View file @
d5d8a5be
...
...
@@ -126,7 +126,6 @@ BOOL X11DRV_CreateBitmap( X11DRV_PDEVICE *physDev, HBITMAP hbitmap, LPVOID bmBit
(
bitmap
.
bmBitsPixel
==
screen_depth
)
||
(
bitmap
.
bmBitsPixel
==
24
&&
screen_depth
==
32
)
||
/* FIXME: Not compatible */
(
bitmap
.
bmBitsPixel
==
32
&&
screen_depth
==
24
)
||
/* FIXME: Not compatible */
(
bitmap
.
bmBitsPixel
==
15
&&
screen_depth
==
16
)
||
/* Confirmed by tests */
(
bitmap
.
bmBitsPixel
==
16
&&
screen_depth
==
15
)))
/* TODO: Confirm this */
{
ERR
(
"Trying to make bitmap with planes=%d, bpp=%d
\n
"
,
...
...
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