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
31682b3d
Commit
31682b3d
authored
Nov 08, 2010
by
Vincent Povirk
Committed by
Alexandre Julliard
Nov 09, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
d3dx9_36: Don't check the image format in D3DXLoadSurfaceFromFileInMemory.
If the format is not supported, D3DXGetImageInfoFromFileInMemory will fail.
parent
384b9553
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
69 additions
and
83 deletions
+69
-83
surface.c
dlls/d3dx9_36/surface.c
+69
-83
No files found.
dlls/d3dx9_36/surface.c
View file @
31682b3d
...
...
@@ -314,6 +314,15 @@ HRESULT WINAPI D3DXLoadSurfaceFromFileInMemory(LPDIRECT3DSURFACE9 pDestSurface,
D3DXIMAGE_INFO
imginfo
;
HRESULT
hr
;
IWICImagingFactory
*
factory
;
IWICBitmapDecoder
*
decoder
;
IWICBitmapFrameDecode
*
bitmapframe
;
IWICStream
*
stream
;
const
PixelFormatDesc
*
formatdesc
;
WICRect
wicrect
;
RECT
rect
;
TRACE
(
"(%p, %p, %p, %p, %d, %p, %d, %x, %p)
\n
"
,
pDestSurface
,
pDestPalette
,
pDestRect
,
pSrcData
,
SrcDataSize
,
pSrcRect
,
dwFilter
,
Colorkey
,
pSrcInfo
);
...
...
@@ -325,109 +334,86 @@ HRESULT WINAPI D3DXLoadSurfaceFromFileInMemory(LPDIRECT3DSURFACE9 pDestSurface,
if
(
FAILED
(
hr
))
return
hr
;
switch
(
imginfo
.
ImageFileFormat
)
{
case
D3DXIFF_BMP
:
case
D3DXIFF_PNG
:
case
D3DXIFF_JPG
:
{
IWICImagingFactory
*
factory
;
IWICBitmapDecoder
*
decoder
;
IWICBitmapFrameDecode
*
bitmapframe
;
IWICStream
*
stream
;
CoInitializeEx
(
NULL
,
COINIT_APARTMENTTHREADED
);
const
PixelFormatDesc
*
formatdesc
;
WICRect
wicrect
;
RECT
rect
;
if
(
FAILED
(
CoCreateInstance
(
&
CLSID_WICImagingFactory
,
NULL
,
CLSCTX_INPROC_SERVER
,
&
IID_IWICImagingFactory
,
(
void
**
)
&
factory
)))
goto
cleanup_err
;
CoInitializeEx
(
NULL
,
COINIT_APARTMENTTHREADED
);
if
(
FAILED
(
IWICImagingFactory_CreateStream
(
factory
,
&
stream
)))
{
IWICImagingFactory_Release
(
factory
);
goto
cleanup_err
;
}
if
(
FAILED
(
CoCreateInstance
(
&
CLSID_WICImagingFactory
,
NULL
,
CLSCTX_INPROC_SERVER
,
&
IID_IWICImagingFactory
,
(
void
**
)
&
factory
)))
goto
cleanup_err
;
IWICStream_InitializeFromMemory
(
stream
,
(
BYTE
*
)
pSrcData
,
SrcDataSize
);
if
(
FAILED
(
IWICImagingFactory_CreateStream
(
factory
,
&
stream
)))
{
IWICImagingFactory_Release
(
factory
);
goto
cleanup_err
;
}
hr
=
IWICImagingFactory_CreateDecoderFromStream
(
factory
,
(
IStream
*
)
stream
,
NULL
,
0
,
&
decoder
);
IWICStream_InitializeFromMemory
(
stream
,
(
BYTE
*
)
pSrcData
,
SrcDataSize
);
IStream_Release
(
stream
);
IWICImagingFactory_Release
(
factory
);
hr
=
IWICImagingFactory_CreateDecoderFromStream
(
factory
,
(
IStream
*
)
stream
,
NULL
,
0
,
&
decoder
);
if
(
FAILED
(
hr
))
goto
cleanup_err
;
IStream_Release
(
stream
);
IWICImagingFactory_Release
(
factory
);
hr
=
IWICBitmapDecoder_GetFrame
(
decoder
,
0
,
&
bitmapframe
);
if
(
FAILED
(
hr
))
goto
cleanup_err
;
if
(
FAILED
(
hr
))
goto
cleanup_bmp
;
hr
=
IWICBitmapDecoder_GetFrame
(
decoder
,
0
,
&
bitmapframe
);
if
(
pSrcRect
)
{
wicrect
.
X
=
pSrcRect
->
left
;
wicrect
.
Y
=
pSrcRect
->
top
;
wicrect
.
Width
=
pSrcRect
->
right
-
pSrcRect
->
left
;
wicrect
.
Height
=
pSrcRect
->
bottom
-
pSrcRect
->
top
;
}
else
{
wicrect
.
X
=
0
;
wicrect
.
Y
=
0
;
wicrect
.
Width
=
imginfo
.
Width
;
wicrect
.
Height
=
imginfo
.
Height
;
}
if
(
FAILED
(
hr
))
goto
cleanup_bmp
;
SetRect
(
&
rect
,
0
,
0
,
wicrect
.
Width
,
wicrect
.
Height
);
if
(
pSrcRect
)
{
wicrect
.
X
=
pSrcRect
->
left
;
wicrect
.
Y
=
pSrcRect
->
top
;
wicrect
.
Width
=
pSrcRect
->
right
-
pSrcRect
->
left
;
wicrect
.
Height
=
pSrcRect
->
bottom
-
pSrcRect
->
top
;
}
else
{
wicrect
.
X
=
0
;
wicrect
.
Y
=
0
;
wicrect
.
Width
=
imginfo
.
Width
;
wicrect
.
Height
=
imginfo
.
Height
;
}
formatdesc
=
get_format_info
(
imginfo
.
Format
);
SetRect
(
&
rect
,
0
,
0
,
wicrect
.
Width
,
wicrect
.
Height
);
if
(
formatdesc
->
format
==
D3DFMT_UNKNOWN
)
{
FIXME
(
"Unsupported pixel format
\n
"
);
hr
=
D3DXERR_INVALIDDATA
;
}
else
{
BYTE
*
buffer
;
DWORD
pitch
;
formatdesc
=
get_format_info
(
imginfo
.
Format
);
pitch
=
formatdesc
->
bytes_per_pixel
*
wicrect
.
Width
;
buffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
pitch
*
wicrect
.
Height
);
if
(
formatdesc
->
format
==
D3DFMT_UNKNOWN
)
{
FIXME
(
"Unsupported pixel format
\n
"
);
hr
=
D3DXERR_INVALIDDATA
;
}
else
{
BYTE
*
buffer
;
DWORD
pitch
;
pitch
=
formatdesc
->
bytes_per_pixel
*
wicrect
.
Width
;
buffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
pitch
*
wicrect
.
Height
);
hr
=
IWICBitmapFrameDecode_CopyPixels
(
bitmapframe
,
&
wicrect
,
pitch
,
pitch
*
wicrect
.
Height
,
buffer
);
if
(
SUCCEEDED
(
hr
))
{
hr
=
D3DXLoadSurfaceFromMemory
(
pDestSurface
,
pDestPalette
,
pDestRect
,
buffer
,
imginfo
.
Format
,
pitch
,
NULL
,
&
rect
,
dwFilter
,
Colorkey
);
}
hr
=
IWICBitmapFrameDecode_CopyPixels
(
bitmapframe
,
&
wicrect
,
pitch
,
pitch
*
wicrect
.
Height
,
buffer
);
HeapFree
(
GetProcessHeap
(),
0
,
buffer
);
}
if
(
SUCCEEDED
(
hr
))
{
hr
=
D3DXLoadSurfaceFromMemory
(
pDestSurface
,
pDestPalette
,
pDestRect
,
buffer
,
imginfo
.
Format
,
pitch
,
NULL
,
&
rect
,
dwFilter
,
Colorkey
);
}
HeapFree
(
GetProcessHeap
(),
0
,
buffer
);
}
cleanup_bmp:
IWICBitmapFrameDecode_Release
(
bitmapframe
);
IWICBitmapDecoder_Release
(
decoder
);
IWICBitmapFrameDecode_Release
(
bitmapframe
);
IWICBitmapDecoder_Release
(
decoder
);
cleanup_err:
CoUninitialize
();
CoUninitialize
();
if
(
FAILED
(
hr
))
return
D3DXERR_INVALIDDATA
;
break
;
}
default:
FIXME
(
"Unsupported image file format
\n
"
);
return
E_NOTIMPL
;
}
if
(
FAILED
(
hr
))
return
D3DXERR_INVALIDDATA
;
if
(
pSrcInfo
)
*
pSrcInfo
=
imginfo
;
...
...
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