diff --git a/dlls/d3dx9_36/surface.c b/dlls/d3dx9_36/surface.c index c3d341e216d..ef6cd57c7da 100644 --- a/dlls/d3dx9_36/surface.c +++ b/dlls/d3dx9_36/surface.c @@ -2116,8 +2116,8 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface, D3DFORMAT src_format, UINT src_pitch, const PALETTEENTRY *src_palette, const RECT *src_rect, DWORD filter, D3DCOLOR color_key) { + RECT dst_rect_temp, dst_rect_aligned, dst_locked_rect, dst_locked_rect_aligned; const struct pixel_format_desc *srcformatdesc, *destformatdesc; - RECT dst_rect_temp, dst_rect_aligned; IDirect3DSurface9 *surface; D3DSURFACE_DESC surfdesc; D3DLOCKED_RECT lockrect; @@ -2192,8 +2192,12 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface, if (FAILED(hr = lock_surface(dst_surface, &dst_rect_aligned, &lockrect, &surface, TRUE))) return hr; - hr = d3dx_load_image_from_memory(lockrect.pBits, lockrect.Pitch, destformatdesc, dst_palette, dst_rect, - &dst_rect_aligned, src_memory, src_pitch, srcformatdesc, src_palette, src_rect, filter, color_key); + dst_locked_rect_aligned = dst_rect_aligned; + dst_locked_rect = *dst_rect; + OffsetRect(&dst_locked_rect_aligned, -dst_rect_aligned.left, -dst_rect_aligned.top); + OffsetRect(&dst_locked_rect, -dst_rect_aligned.left, -dst_rect_aligned.top); + hr = d3dx_load_image_from_memory(lockrect.pBits, lockrect.Pitch, destformatdesc, dst_palette, &dst_locked_rect, + &dst_locked_rect_aligned, src_memory, src_pitch, srcformatdesc, src_palette, src_rect, filter, color_key); if (FAILED(hr)) WARN("d3dx_load_image_from_memory failed with hr %#lx\n", hr); diff --git a/dlls/d3dx9_36/tests/surface.c b/dlls/d3dx9_36/tests/surface.c index 2a4bc5c1652..3c88eec5dcb 100644 --- a/dlls/d3dx9_36/tests/surface.c +++ b/dlls/d3dx9_36/tests/surface.c @@ -1697,7 +1697,7 @@ static void test_D3DXLoadSurface(IDirect3DDevice9 *device) * Bottom left of green block, should still be black from prior * operation. */ - check_readback_pixel_4bpp(&surface_rb, 4, 3, 0xff000000, TRUE); + check_readback_pixel_4bpp(&surface_rb, 4, 3, 0xff000000, FALSE); release_surface_readback(&surface_rb);