Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
2407a747
Commit
2407a747
authored
Dec 07, 2018
by
Dmitry Timoshkov
Committed by
Alexandre Julliard
Dec 07, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
windowscodecs/tests: Add some tests for IWICPalette::InitializeFromBitmap.
Signed-off-by:
Dmitry Timoshkov
<
dmitry@baikal.ru
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
b9bb5120
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
143 additions
and
15 deletions
+143
-15
palette.c
dlls/windowscodecs/tests/palette.c
+143
-15
No files found.
dlls/windowscodecs/tests/palette.c
View file @
2407a747
/*
/*
* Copyright 2009 Vincent Povirk for CodeWeavers
* Copyright 2009 Vincent Povirk for CodeWeavers
* Copyright 2012 Dmitry Timoshkov
* Copyright 2012
,2016
Dmitry Timoshkov
*
*
* This library is free software; you can redistribute it and/or
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* modify it under the terms of the GNU Lesser General Public
...
@@ -27,9 +27,10 @@
...
@@ -27,9 +27,10 @@
#include "wincodec.h"
#include "wincodec.h"
#include "wine/test.h"
#include "wine/test.h"
static
IWICImagingFactory
*
factory
;
static
void
test_custom_palette
(
void
)
static
void
test_custom_palette
(
void
)
{
{
IWICImagingFactory
*
factory
;
IWICPalette
*
palette
,
*
palette2
;
IWICPalette
*
palette
,
*
palette2
;
HRESULT
hr
;
HRESULT
hr
;
WICBitmapPaletteType
type
=
0xffffffff
;
WICBitmapPaletteType
type
=
0xffffffff
;
...
@@ -38,11 +39,6 @@ static void test_custom_palette(void)
...
@@ -38,11 +39,6 @@ static void test_custom_palette(void)
WICColor
colors
[
4
];
WICColor
colors
[
4
];
BOOL
boolresult
;
BOOL
boolresult
;
hr
=
CoCreateInstance
(
&
CLSID_WICImagingFactory
,
NULL
,
CLSCTX_INPROC_SERVER
,
&
IID_IWICImagingFactory
,
(
void
**
)
&
factory
);
ok
(
SUCCEEDED
(
hr
),
"CoCreateInstance failed, hr=%x
\n
"
,
hr
);
if
(
FAILED
(
hr
))
return
;
hr
=
IWICImagingFactory_CreatePalette
(
factory
,
&
palette
);
hr
=
IWICImagingFactory_CreatePalette
(
factory
,
&
palette
);
ok
(
SUCCEEDED
(
hr
),
"CreatePalette failed, hr=%x
\n
"
,
hr
);
ok
(
SUCCEEDED
(
hr
),
"CreatePalette failed, hr=%x
\n
"
,
hr
);
if
(
SUCCEEDED
(
hr
))
if
(
SUCCEEDED
(
hr
))
...
@@ -207,8 +203,6 @@ static void test_custom_palette(void)
...
@@ -207,8 +203,6 @@ static void test_custom_palette(void)
IWICPalette_Release
(
palette2
);
IWICPalette_Release
(
palette2
);
IWICPalette_Release
(
palette
);
IWICPalette_Release
(
palette
);
}
}
IWICImagingFactory_Release
(
factory
);
}
}
static
void
generate_gray16_palette
(
DWORD
*
entries
,
UINT
count
)
static
void
generate_gray16_palette
(
DWORD
*
entries
,
UINT
count
)
...
@@ -451,7 +445,6 @@ static void test_predefined_palette(void)
...
@@ -451,7 +445,6 @@ static void test_predefined_palette(void)
{
WICBitmapPaletteTypeFixedHalftone256
,
0
,
0
,
256
,
{
0
}
},
{
WICBitmapPaletteTypeFixedHalftone256
,
0
,
0
,
256
,
{
0
}
},
{
WICBitmapPaletteTypeFixedHalftone256
,
0
,
0
,
256
,
{
0
},
1
}
{
WICBitmapPaletteTypeFixedHalftone256
,
0
,
0
,
256
,
{
0
},
1
}
};
};
IWICImagingFactory
*
factory
;
IWICPalette
*
palette
;
IWICPalette
*
palette
;
HRESULT
hr
;
HRESULT
hr
;
WICBitmapPaletteType
type
;
WICBitmapPaletteType
type
;
...
@@ -459,10 +452,6 @@ static void test_predefined_palette(void)
...
@@ -459,10 +452,6 @@ static void test_predefined_palette(void)
BOOL
bret
;
BOOL
bret
;
WICColor
color
[
256
];
WICColor
color
[
256
];
hr
=
CoCreateInstance
(
&
CLSID_WICImagingFactory
,
NULL
,
CLSCTX_INPROC_SERVER
,
&
IID_IWICImagingFactory
,
(
void
**
)
&
factory
);
ok
(
hr
==
S_OK
,
"CoCreateInstance error %#x
\n
"
,
hr
);
hr
=
IWICImagingFactory_CreatePalette
(
factory
,
&
palette
);
hr
=
IWICImagingFactory_CreatePalette
(
factory
,
&
palette
);
ok
(
hr
==
S_OK
,
"CreatePalette error %#x
\n
"
,
hr
);
ok
(
hr
==
S_OK
,
"CreatePalette error %#x
\n
"
,
hr
);
hr
=
IWICPalette_InitializePredefined
(
palette
,
WICBitmapPaletteTypeCustom
,
FALSE
);
hr
=
IWICPalette_InitializePredefined
(
palette
,
WICBitmapPaletteTypeCustom
,
FALSE
);
...
@@ -538,16 +527,155 @@ static void test_predefined_palette(void)
...
@@ -538,16 +527,155 @@ static void test_predefined_palette(void)
IWICPalette_Release
(
palette
);
IWICPalette_Release
(
palette
);
}
}
}
IWICImagingFactory_Release
(
factory
);
static
BYTE
*
init_bitmap
(
UINT
*
width
,
UINT
*
height
,
UINT
*
stride
)
{
BYTE
*
src
;
UINT
i
,
j
,
scale
;
*
width
=
256
;
*
height
=
256
;
*
stride
=
(
*
width
*
3
+
3
)
&
~
3
;
trace
(
"width %d, height %d, stride %d
\n
"
,
*
width
,
*
height
,
*
stride
);
src
=
HeapAlloc
(
GetProcessHeap
(),
0
,
*
stride
*
*
height
);
scale
=
256
/
*
width
;
if
(
!
scale
)
scale
=
1
;
for
(
i
=
0
;
i
<
*
height
;
i
++
)
{
for
(
j
=
0
;
j
<
*
width
;
j
++
)
{
src
[
i
*
*
stride
+
j
*
3
+
0
]
=
scale
*
i
;
src
[
i
*
*
stride
+
j
*
3
+
1
]
=
scale
*
(
255
-
(
i
+
j
)
/
2
);
src
[
i
*
*
stride
+
j
*
3
+
2
]
=
scale
*
j
;
}
}
return
src
;
}
static
void
test_palette_from_bitmap
(
void
)
{
HRESULT
hr
;
BYTE
*
data
;
IWICBitmap
*
bitmap
;
IWICPalette
*
palette
;
WICBitmapPaletteType
type
;
UINT
width
,
height
,
stride
,
count
,
ret
;
WICColor
color
[
257
];
data
=
init_bitmap
(
&
width
,
&
height
,
&
stride
);
hr
=
IWICImagingFactory_CreateBitmapFromMemory
(
factory
,
width
,
height
,
&
GUID_WICPixelFormat24bppRGB
,
stride
,
stride
*
height
,
data
,
&
bitmap
);
ok
(
hr
==
S_OK
,
"CreateBitmapFromMemory error %#x
\n
"
,
hr
);
hr
=
IWICImagingFactory_CreatePalette
(
factory
,
&
palette
);
ok
(
hr
==
S_OK
,
"CreatePalette error %#x
\n
"
,
hr
);
hr
=
IWICPalette_InitializeFromBitmap
(
palette
,
(
IWICBitmapSource
*
)
bitmap
,
0
,
FALSE
);
todo_wine
ok
(
hr
==
E_INVALIDARG
,
"expected E_INVALIDARG, got %#x
\n
"
,
hr
);
hr
=
IWICPalette_InitializeFromBitmap
(
palette
,
(
IWICBitmapSource
*
)
bitmap
,
1
,
FALSE
);
todo_wine
ok
(
hr
==
E_INVALIDARG
,
"expected E_INVALIDARG, got %#x
\n
"
,
hr
);
hr
=
IWICPalette_InitializeFromBitmap
(
palette
,
(
IWICBitmapSource
*
)
bitmap
,
257
,
FALSE
);
todo_wine
ok
(
hr
==
E_INVALIDARG
,
"expected E_INVALIDARG, got %#x
\n
"
,
hr
);
hr
=
IWICPalette_InitializeFromBitmap
(
palette
,
NULL
,
16
,
FALSE
);
todo_wine
ok
(
hr
==
E_INVALIDARG
,
"expected E_INVALIDARG, got %#x
\n
"
,
hr
);
hr
=
IWICPalette_InitializeFromBitmap
(
palette
,
(
IWICBitmapSource
*
)
bitmap
,
2
,
FALSE
);
todo_wine
ok
(
hr
==
S_OK
,
"InitializeFromBitmap error %#x
\n
"
,
hr
);
if
(
hr
==
S_OK
)
{
hr
=
IWICPalette_GetColorCount
(
palette
,
&
count
);
ok
(
hr
==
S_OK
,
"GetColorCount error %#x
\n
"
,
hr
);
ok
(
count
==
2
,
"expected 2, got %u
\n
"
,
count
);
}
hr
=
IWICPalette_InitializeFromBitmap
(
palette
,
(
IWICBitmapSource
*
)
bitmap
,
2
,
TRUE
);
todo_wine
ok
(
hr
==
S_OK
,
"InitializeFromBitmap error %#x
\n
"
,
hr
);
if
(
hr
==
S_OK
)
{
count
=
0
;
hr
=
IWICPalette_GetColorCount
(
palette
,
&
count
);
ok
(
hr
==
S_OK
,
"GetColorCount error %#x
\n
"
,
hr
);
ok
(
count
==
2
,
"expected 2, got %u
\n
"
,
count
);
}
/* without trasparent color */
hr
=
IWICPalette_InitializeFromBitmap
(
palette
,
(
IWICBitmapSource
*
)
bitmap
,
16
,
FALSE
);
todo_wine
ok
(
hr
==
S_OK
,
"InitializeFromBitmap error %#x
\n
"
,
hr
);
if
(
hr
==
S_OK
)
{
type
=
-
1
;
hr
=
IWICPalette_GetType
(
palette
,
&
type
);
ok
(
hr
==
S_OK
,
"GetType error %#x
\n
"
,
hr
);
ok
(
type
==
WICBitmapPaletteTypeCustom
,
"expected WICBitmapPaletteTypeCustom, got %#x
\n
"
,
type
);
count
=
0
;
hr
=
IWICPalette_GetColorCount
(
palette
,
&
count
);
ok
(
hr
==
S_OK
,
"GetColorCount error %#x
\n
"
,
hr
);
ok
(
count
==
16
,
"expected 16, got %u
\n
"
,
count
);
memset
(
color
,
0
,
sizeof
(
color
));
hr
=
IWICPalette_GetColors
(
palette
,
count
,
color
,
&
ret
);
ok
(
hr
==
S_OK
,
"GetColors error %#x
\n
"
,
hr
);
ok
(
ret
==
count
,
"expected %u, got %u
\n
"
,
count
,
ret
);
ok
(
color
[
count
-
1
]
!=
0
,
"expected !0, got %08x
\n
"
,
color
[
count
-
1
]);
}
/* with trasparent color */
hr
=
IWICPalette_InitializeFromBitmap
(
palette
,
(
IWICBitmapSource
*
)
bitmap
,
16
,
TRUE
);
todo_wine
ok
(
hr
==
S_OK
,
"InitializeFromBitmap error %#x
\n
"
,
hr
);
if
(
hr
==
S_OK
)
{
type
=
-
1
;
hr
=
IWICPalette_GetType
(
palette
,
&
type
);
ok
(
hr
==
S_OK
,
"GetType error %#x
\n
"
,
hr
);
ok
(
type
==
WICBitmapPaletteTypeCustom
,
"expected WICBitmapPaletteTypeCustom, got %#x
\n
"
,
type
);
count
=
0
;
hr
=
IWICPalette_GetColorCount
(
palette
,
&
count
);
ok
(
hr
==
S_OK
,
"GetColorCount error %#x
\n
"
,
hr
);
ok
(
count
==
16
,
"expected 16, got %u
\n
"
,
count
);
memset
(
color
,
0xff
,
sizeof
(
color
));
hr
=
IWICPalette_GetColors
(
palette
,
count
,
color
,
&
ret
);
ok
(
hr
==
S_OK
,
"GetColors error %#x
\n
"
,
hr
);
ok
(
ret
==
count
,
"expected %u, got %u
\n
"
,
count
,
ret
);
ok
(
color
[
count
-
1
]
==
0
,
"expected 0, got %08x
\n
"
,
color
[
count
-
1
]);
}
IWICPalette_Release
(
palette
);
IWICBitmap_Release
(
bitmap
);
HeapFree
(
GetProcessHeap
(),
0
,
data
);
}
}
START_TEST
(
palette
)
START_TEST
(
palette
)
{
{
HRESULT
hr
;
CoInitializeEx
(
NULL
,
COINIT_APARTMENTTHREADED
);
CoInitializeEx
(
NULL
,
COINIT_APARTMENTTHREADED
);
hr
=
CoCreateInstance
(
&
CLSID_WICImagingFactory
,
NULL
,
CLSCTX_INPROC_SERVER
,
&
IID_IWICImagingFactory
,
(
void
**
)
&
factory
);
ok
(
hr
==
S_OK
,
"CoCreateInstance error %#x
\n
"
,
hr
);
test_custom_palette
();
test_custom_palette
();
test_predefined_palette
();
test_predefined_palette
();
test_palette_from_bitmap
();
IWICImagingFactory_Release
(
factory
);
CoUninitialize
();
CoUninitialize
();
}
}
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