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
b64eb8a8
Commit
b64eb8a8
authored
Feb 06, 2013
by
Hans Leidekker
Committed by
Alexandre Julliard
Feb 06, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
windowscodecs: Implement IWICColorContext::InitializeFromFilename.
parent
956ec432
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
123 additions
and
7 deletions
+123
-7
colorcontext.c
dlls/windowscodecs/colorcontext.c
+62
-7
pngformat.c
dlls/windowscodecs/tests/pngformat.c
+61
-0
No files found.
dlls/windowscodecs/colorcontext.c
View file @
b64eb8a8
...
...
@@ -96,27 +96,82 @@ static ULONG WINAPI ColorContext_Release(IWICColorContext *iface)
return
ref
;
}
static
HRESULT
load_profile
(
const
WCHAR
*
filename
,
BYTE
**
profile
,
UINT
*
len
)
{
HANDLE
handle
;
DWORD
count
;
LARGE_INTEGER
size
;
BOOL
ret
;
*
len
=
0
;
*
profile
=
NULL
;
handle
=
CreateFileW
(
filename
,
GENERIC_READ
,
0
,
NULL
,
OPEN_EXISTING
,
0
,
NULL
);
if
(
handle
==
INVALID_HANDLE_VALUE
)
return
HRESULT_FROM_WIN32
(
GetLastError
());
if
(
!
(
GetFileSizeEx
(
handle
,
&
size
)))
{
CloseHandle
(
handle
);
return
HRESULT_FROM_WIN32
(
GetLastError
());
}
if
(
size
.
u
.
HighPart
)
{
WARN
(
"file too large
\n
"
);
CloseHandle
(
handle
);
return
E_FAIL
;
}
if
(
!
(
*
profile
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
.
u
.
LowPart
)))
{
CloseHandle
(
handle
);
return
E_OUTOFMEMORY
;
}
ret
=
ReadFile
(
handle
,
*
profile
,
size
.
u
.
LowPart
,
&
count
,
NULL
);
CloseHandle
(
handle
);
if
(
!
ret
)
return
HRESULT_FROM_WIN32
(
GetLastError
());
if
(
count
!=
size
.
u
.
LowPart
)
return
E_FAIL
;
*
len
=
count
;
return
S_OK
;
}
static
HRESULT
WINAPI
ColorContext_InitializeFromFilename
(
IWICColorContext
*
iface
,
LPCWSTR
wzFilename
)
{
FIXME
(
"(%p,%s)
\n
"
,
iface
,
debugstr_w
(
wzFilename
));
return
E_NOTIMPL
;
ColorContext
*
This
=
impl_from_IWICColorContext
(
iface
);
BYTE
*
profile
;
UINT
len
;
HRESULT
hr
;
TRACE
(
"(%p,%s)
\n
"
,
iface
,
debugstr_w
(
wzFilename
));
if
(
This
->
type
!=
WICColorContextUninitialized
&&
This
->
type
!=
WICColorContextProfile
)
return
WINCODEC_ERR_WRONGSTATE
;
if
(
!
wzFilename
)
return
E_INVALIDARG
;
hr
=
load_profile
(
wzFilename
,
&
profile
,
&
len
);
if
(
FAILED
(
hr
))
return
hr
;
HeapFree
(
GetProcessHeap
(),
0
,
This
->
profile
);
This
->
profile
=
profile
;
This
->
profile_len
=
len
;
This
->
type
=
WICColorContextProfile
;
return
S_OK
;
}
static
HRESULT
WINAPI
ColorContext_InitializeFromMemory
(
IWICColorContext
*
iface
,
const
BYTE
*
pbBuffer
,
UINT
cbBufferSize
)
{
ColorContext
*
This
=
impl_from_IWICColorContext
(
iface
);
BYTE
*
profile
;
TRACE
(
"(%p,%p,%u)
\n
"
,
iface
,
pbBuffer
,
cbBufferSize
);
if
(
This
->
type
!=
WICColorContextUninitialized
)
if
(
This
->
type
!=
WICColorContextUninitialized
&&
This
->
type
!=
WICColorContextProfile
)
return
WINCODEC_ERR_WRONGSTATE
;
HeapFree
(
GetProcessHeap
(),
0
,
This
->
profile
);
if
(
!
(
This
->
profile
=
HeapAlloc
(
GetProcessHeap
(),
0
,
cbBufferSize
)))
return
E_OUTOFMEMORY
;
if
(
!
(
profile
=
HeapAlloc
(
GetProcessHeap
(),
0
,
cbBufferSize
)))
return
E_OUTOFMEMORY
;
memcpy
(
profile
,
pbBuffer
,
cbBufferSize
);
memcpy
(
This
->
profile
,
pbBuffer
,
cbBufferSize
);
HeapFree
(
GetProcessHeap
(),
0
,
This
->
profile
);
This
->
profile
=
profile
;
This
->
profile_len
=
cbBufferSize
;
This
->
type
=
WICColorContextProfile
;
...
...
dlls/windowscodecs/tests/pngformat.c
View file @
b64eb8a8
...
...
@@ -317,6 +317,27 @@ static IWICBitmapDecoder *create_decoder(const void *image_data, UINT image_size
return
decoder
;
}
static
WCHAR
*
save_profile
(
BYTE
*
buffer
,
UINT
size
)
{
static
const
WCHAR
tstW
[]
=
{
't'
,
's'
,
't'
,
0
};
WCHAR
path
[
MAX_PATH
],
filename
[
MAX_PATH
],
*
ret
;
HANDLE
handle
;
DWORD
count
;
GetTempPathW
(
MAX_PATH
,
path
);
GetTempFileNameW
(
path
,
tstW
,
0
,
filename
);
handle
=
CreateFileW
(
filename
,
GENERIC_WRITE
,
0
,
NULL
,
CREATE_ALWAYS
,
0
,
NULL
);
if
(
handle
==
INVALID_HANDLE_VALUE
)
return
NULL
;
WriteFile
(
handle
,
buffer
,
size
,
&
count
,
NULL
);
CloseHandle
(
handle
);
ret
=
HeapAlloc
(
GetProcessHeap
(),
0
,
(
lstrlenW
(
filename
)
+
1
)
*
sizeof
(
WCHAR
));
lstrcpyW
(
ret
,
filename
);
return
ret
;
}
static
void
test_color_contexts
(
void
)
{
HRESULT
hr
;
...
...
@@ -325,7 +346,9 @@ static void test_color_contexts(void)
IWICColorContext
*
context
;
WICColorContextType
type
;
UINT
count
,
colorspace
,
size
;
WCHAR
*
tmpfile
;
BYTE
*
buffer
;
BOOL
ret
;
decoder
=
create_decoder
(
png_no_color_profile
,
sizeof
(
png_no_color_profile
));
ok
(
decoder
!=
0
,
"Failed to load PNG image data
\n
"
);
...
...
@@ -453,6 +476,8 @@ static void test_color_contexts(void)
buffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
);
hr
=
IWICColorContext_GetProfileBytes
(
context
,
size
,
buffer
,
&
size
);
ok
(
hr
==
S_OK
,
"GetProfileBytes error %#x
\n
"
,
hr
);
tmpfile
=
save_profile
(
buffer
,
size
);
HeapFree
(
GetProcessHeap
(),
0
,
buffer
);
type
=
0xdeadbeef
;
...
...
@@ -468,6 +493,42 @@ static void test_color_contexts(void)
hr
=
IWICColorContext_InitializeFromExifColorSpace
(
context
,
1
);
ok
(
hr
==
WINCODEC_ERR_WRONGSTATE
,
"InitializeFromExifColorSpace error %#x
\n
"
,
hr
);
if
(
tmpfile
)
{
hr
=
IWICColorContext_InitializeFromFilename
(
context
,
NULL
);
ok
(
hr
==
E_INVALIDARG
,
"InitializeFromFilename error %#x
\n
"
,
hr
);
hr
=
IWICColorContext_InitializeFromFilename
(
context
,
tmpfile
);
ok
(
hr
==
S_OK
,
"InitializeFromFilename error %#x
\n
"
,
hr
);
ret
=
DeleteFileW
(
tmpfile
);
ok
(
ret
,
"DeleteFileW failed %u
\n
"
,
GetLastError
());
type
=
0xdeadbeef
;
hr
=
IWICColorContext_GetType
(
context
,
&
type
);
ok
(
hr
==
S_OK
,
"GetType error %#x
\n
"
,
hr
);
ok
(
type
==
WICColorContextProfile
,
"unexpected type %u
\n
"
,
type
);
colorspace
=
0xdeadbeef
;
hr
=
IWICColorContext_GetExifColorSpace
(
context
,
&
colorspace
);
ok
(
hr
==
S_OK
,
"GetExifColorSpace error %#x
\n
"
,
hr
);
ok
(
colorspace
==
0xffffffff
,
"unexpected color space %u
\n
"
,
colorspace
);
hr
=
IWICColorContext_InitializeFromExifColorSpace
(
context
,
1
);
ok
(
hr
==
WINCODEC_ERR_WRONGSTATE
,
"InitializeFromExifColorSpace error %#x
\n
"
,
hr
);
size
=
0
;
hr
=
IWICColorContext_GetProfileBytes
(
context
,
0
,
NULL
,
&
size
);
ok
(
hr
==
S_OK
,
"GetProfileBytes error %#x
\n
"
,
hr
);
ok
(
size
,
"unexpected size %u
\n
"
,
size
);
buffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
);
hr
=
IWICColorContext_GetProfileBytes
(
context
,
size
,
buffer
,
&
size
);
ok
(
hr
==
S_OK
,
"GetProfileBytes error %#x
\n
"
,
hr
);
HeapFree
(
GetProcessHeap
(),
0
,
buffer
);
HeapFree
(
GetProcessHeap
(),
0
,
tmpfile
);
}
IWICColorContext_Release
(
context
);
IWICBitmapFrameDecode_Release
(
frame
);
IWICBitmapDecoder_Release
(
decoder
);
...
...
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