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
00572958
Commit
00572958
authored
Aug 22, 2005
by
Glenn Wurster
Committed by
Alexandre Julliard
Aug 22, 2005
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Start to add some tests for basic palette operations.
parent
2aef956c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
129 additions
and
1 deletion
+129
-1
.cvsignore
dlls/gdi/tests/.cvsignore
+1
-0
Makefile.in
dlls/gdi/tests/Makefile.in
+2
-1
palette.c
dlls/gdi/tests/palette.c
+126
-0
No files found.
dlls/gdi/tests/.cvsignore
View file @
00572958
...
...
@@ -4,4 +4,5 @@ brush.ok
gdiobj.ok
generated.ok
metafile.ok
palette.ok
testlist.c
dlls/gdi/tests/Makefile.in
View file @
00572958
...
...
@@ -10,7 +10,8 @@ CTESTS = \
brush.c
\
gdiobj.c
\
generated.c
\
metafile.c
metafile.c
\
palette.c
@MAKE_TEST_RULES@
...
...
dlls/gdi/tests/palette.c
0 → 100644
View file @
00572958
/*
* Unit test suite for palettes
*
* Copyright 2005 Glenn Wurster
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdarg.h>
#include <assert.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "mmsystem.h"
#include "wine/test.h"
static
PALETTEENTRY
logpalettedata
[
8
]
=
{
{
0x10
,
0x20
,
0x30
,
PC_NOCOLLAPSE
},
{
0x20
,
0x30
,
0x40
,
PC_NOCOLLAPSE
},
{
0x30
,
0x40
,
0x50
,
PC_NOCOLLAPSE
},
{
0x40
,
0x50
,
0x60
,
PC_NOCOLLAPSE
},
{
0x50
,
0x60
,
0x70
,
PC_NOCOLLAPSE
},
{
0x60
,
0x70
,
0x80
,
PC_NOCOLLAPSE
},
{
0x70
,
0x80
,
0x90
,
PC_NOCOLLAPSE
},
{
0x80
,
0x90
,
0xA0
,
PC_NOCOLLAPSE
},
};
static
void
test_DIB_PAL_COLORS
(
void
)
{
HDC
hdc
=
GetDC
(
NULL
);
HDC
memhdc
=
CreateCompatibleDC
(
hdc
);
HBITMAP
hbmp
,
hbmpOld
;
char
bmpbuf
[
sizeof
(
BITMAPINFO
)
+
10
*
sizeof
(
WORD
)];
PBITMAPINFO
bmp
=
(
PBITMAPINFO
)
bmpbuf
;
WORD
*
bmpPalPtr
;
char
logpalettebuf
[
sizeof
(
LOGPALETTE
)
+
sizeof
(
logpalettedata
)];
PLOGPALETTE
logpalette
=
(
PLOGPALETTE
)
logpalettebuf
;
HPALETTE
hpal
,
hpalOld
;
COLORREF
setColor
,
chkColor
,
getColor
;
int
i
;
/* Initalize the logical palette with a few colours */
logpalette
->
palVersion
=
0x300
;
logpalette
->
palNumEntries
=
8
;
memcpy
(
logpalette
->
palPalEntry
,
logpalettedata
,
sizeof
(
logpalettedata
)
);
hpal
=
CreatePalette
(
logpalette
);
hpalOld
=
SelectPalette
(
memhdc
,
hpal
,
FALSE
);
ok
(
hpalOld
!=
NULL
,
"error=%ld
\n
"
,
GetLastError
()
);
/* Create a DIB BMP which references colours in the logical palette */
memset
(
bmp
,
0x00
,
sizeof
(
BITMAPINFO
)
);
bmp
->
bmiHeader
.
biSize
=
sizeof
(
BITMAPINFOHEADER
);
bmp
->
bmiHeader
.
biWidth
=
1
;
bmp
->
bmiHeader
.
biHeight
=
1
;
bmp
->
bmiHeader
.
biPlanes
=
1
;
bmp
->
bmiHeader
.
biBitCount
=
8
;
bmp
->
bmiHeader
.
biCompression
=
BI_RGB
;
bmp
->
bmiHeader
.
biClrUsed
=
10
;
bmp
->
bmiHeader
.
biClrImportant
=
0
;
bmpPalPtr
=
(
WORD
*
)
&
bmp
->
bmiColors
;
for
(
i
=
0
;
i
<
8
;
i
++
)
{
*
bmpPalPtr
++
=
i
;
}
*
bmpPalPtr
++
=
8
;
/* Pointer to logical palette index just outside range */
*
bmpPalPtr
++
=
19
;
/* Pointer to bad logical palette index */
hbmp
=
CreateDIBSection
(
memhdc
,
bmp
,
DIB_PAL_COLORS
,
0
,
0
,
0
);
ok
(
hbmp
!=
NULL
,
"error=%ld
\n
"
,
GetLastError
()
);
hbmpOld
=
SelectObject
(
memhdc
,
hbmp
);
ok
(
hbmpOld
!=
NULL
,
"error=%ld
\n
"
,
GetLastError
()
);
/* Test with a RGB to DIB_PAL_COLORS */
setColor
=
RGB
(
logpalettedata
[
1
].
peRed
,
logpalettedata
[
1
].
peGreen
,
logpalettedata
[
1
].
peBlue
);
SetPixel
(
memhdc
,
0
,
0
,
setColor
);
chkColor
=
RGB
(
logpalettedata
[
1
].
peRed
,
logpalettedata
[
1
].
peGreen
,
logpalettedata
[
1
].
peBlue
);
getColor
=
GetPixel
(
memhdc
,
0
,
0
);
ok
(
getColor
==
chkColor
,
"getColor=%08X
\n
"
,
(
UINT
)
getColor
);
/* Test with a valid DIBINDEX to DIB_PAL_COLORS */
setColor
=
DIBINDEX
(
2
);
SetPixel
(
memhdc
,
0
,
0
,
setColor
);
chkColor
=
RGB
(
logpalettedata
[
2
].
peRed
,
logpalettedata
[
2
].
peGreen
,
logpalettedata
[
2
].
peBlue
);
getColor
=
GetPixel
(
memhdc
,
0
,
0
);
ok
(
getColor
==
chkColor
,
"getColor=%08X
\n
"
,
(
UINT
)
getColor
);
/* Test with a invalid DIBINDEX to DIB_PAL_COLORS */
setColor
=
DIBINDEX
(
12
);
SetPixel
(
memhdc
,
0
,
0
,
setColor
);
chkColor
=
RGB
(
0
,
0
,
0
);
getColor
=
GetPixel
(
memhdc
,
0
,
0
);
ok
(
getColor
==
chkColor
,
"getColor=%08X
\n
"
,
(
UINT
)
getColor
);
/* Test for double wraparound on logical palette references from */
/* DIBINDEX by DIB_PAL_COLORS. */
setColor
=
DIBINDEX
(
9
);
SetPixel
(
memhdc
,
0
,
0
,
setColor
);
chkColor
=
RGB
(
logpalettedata
[
3
].
peRed
,
logpalettedata
[
3
].
peGreen
,
logpalettedata
[
3
].
peBlue
);
getColor
=
GetPixel
(
memhdc
,
0
,
0
);
ok
(
getColor
==
chkColor
,
"getColor=%08X
\n
"
,
(
UINT
)
getColor
);
SelectPalette
(
memhdc
,
hpalOld
,
FALSE
);
DeleteObject
(
hpal
);
SelectObject
(
memhdc
,
hbmpOld
);
DeleteObject
(
hbmp
);
DeleteDC
(
memhdc
);
ReleaseDC
(
NULL
,
hdc
);
}
START_TEST
(
palette
)
{
test_DIB_PAL_COLORS
();
}
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