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
0316a1b4
Commit
0316a1b4
authored
Jul 30, 2012
by
Dmitry Timoshkov
Committed by
Alexandre Julliard
Jul 30, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
windowscodecs: Implement IWICPalette_InitializeFromPalette.
parent
4d7f510b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
93 additions
and
4 deletions
+93
-4
palette.c
dlls/windowscodecs/palette.c
+31
-3
palette.c
dlls/windowscodecs/tests/palette.c
+62
-1
No files found.
dlls/windowscodecs/palette.c
View file @
0316a1b4
...
...
@@ -455,10 +455,38 @@ static HRESULT WINAPI PaletteImpl_InitializeFromBitmap(IWICPalette *iface,
}
static
HRESULT
WINAPI
PaletteImpl_InitializeFromPalette
(
IWICPalette
*
iface
,
IWICPalette
*
pIPalett
e
)
IWICPalette
*
sourc
e
)
{
FIXME
(
"(%p,%p): stub
\n
"
,
iface
,
pIPalette
);
return
E_NOTIMPL
;
PaletteImpl
*
This
=
impl_from_IWICPalette
(
iface
);
UINT
count
;
WICColor
*
colors
=
NULL
;
WICBitmapPaletteType
type
;
HRESULT
hr
;
TRACE
(
"(%p,%p)
\n
"
,
iface
,
source
);
if
(
!
source
)
return
E_INVALIDARG
;
hr
=
IWICPalette_GetType
(
source
,
&
type
);
if
(
hr
!=
S_OK
)
return
hr
;
hr
=
IWICPalette_GetColorCount
(
source
,
&
count
);
if
(
hr
!=
S_OK
)
return
hr
;
if
(
count
)
{
colors
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
WICColor
)
*
count
);
if
(
!
colors
)
return
E_OUTOFMEMORY
;
hr
=
IWICPalette_GetColors
(
source
,
count
,
colors
,
&
count
);
if
(
hr
!=
S_OK
)
return
hr
;
}
EnterCriticalSection
(
&
This
->
lock
);
HeapFree
(
GetProcessHeap
(),
0
,
This
->
colors
);
This
->
colors
=
colors
;
This
->
count
=
count
;
This
->
type
=
type
;
LeaveCriticalSection
(
&
This
->
lock
);
return
S_OK
;
}
static
HRESULT
WINAPI
PaletteImpl_GetType
(
IWICPalette
*
iface
,
...
...
dlls/windowscodecs/tests/palette.c
View file @
0316a1b4
...
...
@@ -30,7 +30,7 @@
static
void
test_custom_palette
(
void
)
{
IWICImagingFactory
*
factory
;
IWICPalette
*
palette
;
IWICPalette
*
palette
,
*
palette2
;
HRESULT
hr
;
WICBitmapPaletteType
type
=
0xffffffff
;
UINT
count
=
1
;
...
...
@@ -106,6 +106,29 @@ static void test_custom_palette(void)
ok
(
SUCCEEDED
(
hr
),
"IsGrayscale failed, hr=%x
\n
"
,
hr
);
ok
(
!
boolresult
,
"expected FALSE, got TRUE
\n
"
);
hr
=
IWICImagingFactory_CreatePalette
(
factory
,
&
palette2
);
ok
(
SUCCEEDED
(
hr
),
"CreatePalette failed, hr=%x
\n
"
,
hr
);
hr
=
IWICPalette_InitializeFromPalette
(
palette2
,
palette
);
ok
(
SUCCEEDED
(
hr
),
"InitializeFromPalette failed, hr=%x
\n
"
,
hr
);
type
=
0xdeadbeef
;
hr
=
IWICPalette_GetType
(
palette2
,
&
type
);
ok
(
SUCCEEDED
(
hr
),
"GetType failed, hr=%x
\n
"
,
hr
);
ok
(
type
==
WICBitmapPaletteTypeCustom
,
"expected WICBitmapPaletteTypeCustom, got %x
\n
"
,
type
);
count
=
0xdeadbeef
;
hr
=
IWICPalette_GetColorCount
(
palette2
,
&
count
);
ok
(
SUCCEEDED
(
hr
),
"GetColorCount failed, hr=%x
\n
"
,
hr
);
ok
(
count
==
4
,
"expected 4, got %u
\n
"
,
count
);
memset
(
colors
,
0
,
sizeof
(
colors
));
count
=
0xdeadbeef
;
hr
=
IWICPalette_GetColors
(
palette2
,
4
,
colors
,
&
count
);
ok
(
SUCCEEDED
(
hr
),
"GetColors failed, hr=%x
\n
"
,
hr
);
ok
(
count
==
4
,
"expected 4, got %u
\n
"
,
count
);
ok
(
!
memcmp
(
colors
,
initcolors
,
sizeof
(
colors
)),
"got unexpected palette data
\n
"
);
/* try a palette with some alpha in it */
colors
[
2
]
=
0x80ffffff
;
hr
=
IWICPalette_InitializeCustom
(
palette
,
colors
,
4
);
...
...
@@ -119,6 +142,40 @@ static void test_custom_palette(void)
hr
=
IWICPalette_InitializeCustom
(
palette
,
NULL
,
0
);
ok
(
SUCCEEDED
(
hr
),
"InitializeCustom failed, hr=%x
\n
"
,
hr
);
type
=
0xdeadbeef
;
hr
=
IWICPalette_GetType
(
palette
,
&
type
);
ok
(
SUCCEEDED
(
hr
),
"GetType failed, hr=%x
\n
"
,
hr
);
ok
(
type
==
WICBitmapPaletteTypeCustom
,
"expected WICBitmapPaletteTypeCustom, got %x
\n
"
,
type
);
count
=
0xdeadbeef
;
hr
=
IWICPalette_GetColorCount
(
palette
,
&
count
);
ok
(
SUCCEEDED
(
hr
),
"GetColorCount failed, hr=%x
\n
"
,
hr
);
ok
(
count
==
0
,
"expected 0, got %u
\n
"
,
count
);
count
=
0xdeadbeef
;
hr
=
IWICPalette_GetColors
(
palette
,
4
,
colors
,
&
count
);
ok
(
SUCCEEDED
(
hr
),
"GetColors failed, hr=%x
\n
"
,
hr
);
ok
(
count
==
0
,
"expected 0, got %u
\n
"
,
count
);
hr
=
IWICPalette_InitializeFromPalette
(
palette2
,
palette
);
ok
(
SUCCEEDED
(
hr
),
"InitializeFromPalette failed, hr=%x
\n
"
,
hr
);
type
=
0xdeadbeef
;
hr
=
IWICPalette_GetType
(
palette2
,
&
type
);
ok
(
SUCCEEDED
(
hr
),
"GetType failed, hr=%x
\n
"
,
hr
);
ok
(
type
==
WICBitmapPaletteTypeCustom
,
"expected WICBitmapPaletteTypeCustom, got %x
\n
"
,
type
);
count
=
0xdeadbeef
;
hr
=
IWICPalette_GetColorCount
(
palette2
,
&
count
);
ok
(
SUCCEEDED
(
hr
),
"GetColorCount failed, hr=%x
\n
"
,
hr
);
ok
(
count
==
0
,
"expected 0, got %u
\n
"
,
count
);
memset
(
colors
,
0
,
sizeof
(
colors
));
count
=
0xdeadbeef
;
hr
=
IWICPalette_GetColors
(
palette2
,
4
,
colors
,
&
count
);
ok
(
SUCCEEDED
(
hr
),
"GetColors failed, hr=%x
\n
"
,
hr
);
ok
(
count
==
0
,
"expected 0, got %u
\n
"
,
count
);
/* IWICPalette is paranoid about NULL pointers */
hr
=
IWICPalette_GetType
(
palette
,
NULL
);
ok
(
hr
==
E_INVALIDARG
,
"expected E_INVALIDARG, got %x
\n
"
,
hr
);
...
...
@@ -144,6 +201,10 @@ static void test_custom_palette(void)
hr
=
IWICPalette_IsGrayscale
(
palette
,
NULL
);
ok
(
hr
==
E_INVALIDARG
,
"expected E_INVALIDARG, got %x
\n
"
,
hr
);
hr
=
IWICPalette_InitializeFromPalette
(
palette
,
NULL
);
ok
(
hr
==
E_INVALIDARG
,
"expected E_INVALIDARG, got %x
\n
"
,
hr
);
IWICPalette_Release
(
palette2
);
IWICPalette_Release
(
palette
);
}
...
...
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