d3dx9: Add partial DDS support implementation for D3DXGetImageInfo functions.
[wine.git] / dlls / d3dx9_36 / surface.c
blobe361c80f7788b85dff7f371217d6648d8f561e11
1 /*
2 * Copyright (C) 2009-2010 Tony Wasserka
3 * Copyright (C) 2012 Józef Kucia
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "wine/debug.h"
22 #include "wine/unicode.h"
23 #include "d3dx9_36_private.h"
25 #include "initguid.h"
26 #include "wincodec.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(d3dx);
31 /* Wine-specific WIC GUIDs */
32 DEFINE_GUID(GUID_WineContainerFormatTga, 0x0c44fda1,0xa5c5,0x4298,0x96,0x85,0x47,0x3f,0xc1,0x7c,0xd3,0x22);
34 /* dds_header.flags */
35 #define DDS_CAPS 0x1
36 #define DDS_HEIGHT 0x2
37 #define DDS_WIDTH 0x2
38 #define DDS_PITCH 0x8
39 #define DDS_PIXELFORMAT 0x1000
40 #define DDS_MIPMAPCOUNT 0x20000
41 #define DDS_LINEARSIZE 0x80000
42 #define DDS_DEPTH 0x800000
44 /* dds_header.caps */
45 #define DDS_CAPS_COMPLEX 0x8
46 #define DDS_CAPS_TEXTURE 0x1000
47 #define DDS_CAPS_MIPMAP 0x400000
49 /* dds_header.caps2 */
50 #define DDS_CAPS2_CUBEMAP 0x200
51 #define DDS_CAPS2_CUBEMAP_POSITIVEX 0x400
52 #define DDS_CAPS2_CUBEMAP_NEGATIVEX 0x800
53 #define DDS_CAPS2_CUBEMAP_POSITIVEY 0x1000
54 #define DDS_CAPS2_CUBEMAP_NEGATIVEY 0x2000
55 #define DDS_CAPS2_CUBEMAP_POSITIVEZ 0x4000
56 #define DDS_CAPS2_CUBEMAP_NEGATIVEZ 0x8000
57 #define DDS_CAPS2_VOLUME 0x200000
59 /* dds_pixel_format.flags */
60 #define DDS_PF_ALPHA 0x1
61 #define DDS_PF_ALPHA_ONLY 0x2
62 #define DDS_PF_FOURCC 0x4
63 #define DDS_PF_RGB 0x40
64 #define DDS_PF_YUV 0x200
65 #define DDS_PF_LUMINANCE 0x20000
67 struct dds_pixel_format
69 DWORD size;
70 DWORD flags;
71 DWORD fourcc;
72 DWORD bpp;
73 DWORD rmask;
74 DWORD gmask;
75 DWORD bmask;
76 DWORD amask;
79 struct dds_header
81 DWORD signature;
82 DWORD size;
83 DWORD flags;
84 DWORD height;
85 DWORD width;
86 DWORD pitch_or_linear_size;
87 DWORD depth;
88 DWORD miplevels;
89 DWORD reserved[11];
90 struct dds_pixel_format pixel_format;
91 DWORD caps;
92 DWORD caps2;
93 DWORD caps3;
94 DWORD caps4;
95 DWORD reserved2;
98 static D3DFORMAT dds_pixel_format_to_d3dformat(const struct dds_pixel_format *pixel_format)
100 FIXME("Pixel format conversion not implemented.\n");
101 return D3DFMT_UNKNOWN;
104 /************************************************************
105 * get_image_info_from_dds
107 * Fills a D3DXIMAGE_INFO structure with information
108 * about a DDS file stored in the memory.
110 * PARAMS
111 * buffer [I] pointer to DDS data
112 * length [I] size of DDS data
113 * info [O] pointer to D3DXIMAGE_INFO structure
115 * RETURNS
116 * Success: D3D_OK
117 * Failure: D3DXERR_INVALIDDATA
120 static HRESULT get_image_info_from_dds(const void *buffer, DWORD length, D3DXIMAGE_INFO *info)
122 const struct dds_header *header = buffer;
124 if (length < sizeof(*header) || !info)
125 return D3DXERR_INVALIDDATA;
127 if (header->pixel_format.size != sizeof(header->pixel_format))
128 return D3DXERR_INVALIDDATA;
130 info->Width = header->width;
131 info->Height = header->height;
132 info->Depth = 1;
133 info->MipLevels = (header->flags & DDS_MIPMAPCOUNT) ? header->miplevels : 1;
135 info->Format = dds_pixel_format_to_d3dformat(&header->pixel_format);
136 if (info->Format == D3DFMT_UNKNOWN)
137 return D3DXERR_INVALIDDATA;
139 if (header->caps2 & DDS_CAPS2_VOLUME)
141 info->Depth = header->depth;
142 info->ResourceType = D3DRTYPE_VOLUMETEXTURE;
144 else if (header->caps2 & DDS_CAPS2_CUBEMAP)
146 info->ResourceType = D3DRTYPE_CUBETEXTURE;
148 else
150 info->ResourceType = D3DRTYPE_TEXTURE;
153 info->ImageFileFormat = D3DXIFF_DDS;
155 return D3D_OK;
158 /************************************************************
159 * D3DXGetImageInfoFromFileInMemory
161 * Fills a D3DXIMAGE_INFO structure with info about an image
163 * PARAMS
164 * data [I] pointer to the image file data
165 * datasize [I] size of the passed data
166 * info [O] pointer to the destination structure
168 * RETURNS
169 * Success: D3D_OK, if info is not NULL and data and datasize make up a valid image file or
170 * if info is NULL and data and datasize are not NULL
171 * Failure: D3DXERR_INVALIDDATA, if data is no valid image file and datasize and info are not NULL
172 * D3DERR_INVALIDCALL, if data is NULL or
173 * if datasize is 0
175 * NOTES
176 * datasize may be bigger than the actual file size
179 HRESULT WINAPI D3DXGetImageInfoFromFileInMemory(LPCVOID data, UINT datasize, D3DXIMAGE_INFO *info)
181 IWICImagingFactory *factory;
182 IWICBitmapDecoder *decoder = NULL;
183 IWICStream *stream;
184 HRESULT hr;
185 HRESULT initresult;
187 TRACE("(%p, %d, %p)\n", data, datasize, info);
189 if (!data || !datasize)
190 return D3DERR_INVALIDCALL;
192 if (!info)
193 return D3D_OK;
195 if ((datasize >= 4) && !strncmp(data, "DDS ", 4))
196 return get_image_info_from_dds(data, datasize, info);
198 initresult = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
200 hr = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, &IID_IWICImagingFactory, (void**)&factory);
202 if (SUCCEEDED(hr)) {
203 IWICImagingFactory_CreateStream(factory, &stream);
204 IWICStream_InitializeFromMemory(stream, (BYTE*)data, datasize);
205 hr = IWICImagingFactory_CreateDecoderFromStream(factory, (IStream*)stream, NULL, 0, &decoder);
206 IStream_Release(stream);
207 IWICImagingFactory_Release(factory);
210 if (FAILED(hr)) {
211 if ((datasize >= 2) && (!strncmp(data, "P3", 2) || !strncmp(data, "P6", 2)))
212 FIXME("File type PPM is not supported yet\n");
213 else if ((datasize >= 2) && !strncmp(data, "BM", 2))
214 FIXME("File type DIB is not supported yet\n");
215 else if ((datasize >= 10) && !strncmp(data, "#?RADIANCE", 10))
216 FIXME("File type HDR is not supported yet\n");
217 else if ((datasize >= 2) && (!strncmp(data, "PF", 2) || !strncmp(data, "Pf", 2)))
218 FIXME("File type PFM is not supported yet\n");
221 if (SUCCEEDED(hr)) {
222 GUID container_format;
223 UINT frame_count;
225 hr = IWICBitmapDecoder_GetContainerFormat(decoder, &container_format);
226 if (SUCCEEDED(hr)) {
227 if (IsEqualGUID(&container_format, &GUID_ContainerFormatBmp)) {
228 TRACE("File type is BMP\n");
229 info->ImageFileFormat = D3DXIFF_BMP;
230 } else if (IsEqualGUID(&container_format, &GUID_ContainerFormatPng)) {
231 TRACE("File type is PNG\n");
232 info->ImageFileFormat = D3DXIFF_PNG;
233 } else if(IsEqualGUID(&container_format, &GUID_ContainerFormatJpeg)) {
234 TRACE("File type is JPG\n");
235 info->ImageFileFormat = D3DXIFF_JPG;
236 } else if(IsEqualGUID(&container_format, &GUID_WineContainerFormatTga)) {
237 TRACE("File type is TGA\n");
238 info->ImageFileFormat = D3DXIFF_TGA;
239 } else {
240 WARN("Unsupported image file format %s\n", debugstr_guid(&container_format));
241 hr = D3DXERR_INVALIDDATA;
245 if (SUCCEEDED(hr))
246 hr = IWICBitmapDecoder_GetFrameCount(decoder, &frame_count);
247 if (SUCCEEDED(hr) && !frame_count)
248 hr = D3DXERR_INVALIDDATA;
250 if (SUCCEEDED(hr)) {
251 IWICBitmapFrameDecode *frame = NULL;
253 hr = IWICBitmapDecoder_GetFrame(decoder, 0, &frame);
255 if (SUCCEEDED(hr))
256 hr = IWICBitmapFrameDecode_GetSize(frame, &info->Width, &info->Height);
258 if (SUCCEEDED(hr)) {
259 WICPixelFormatGUID pixel_format;
261 hr = IWICBitmapFrameDecode_GetPixelFormat(frame, &pixel_format);
262 if (SUCCEEDED(hr)) {
263 if (IsEqualGUID(&pixel_format, &GUID_WICPixelFormat1bppIndexed))
264 info->Format = D3DFMT_L8;
265 else if (IsEqualGUID(&pixel_format, &GUID_WICPixelFormat4bppIndexed))
266 info->Format = D3DFMT_L8;
267 else if (IsEqualGUID(&pixel_format, &GUID_WICPixelFormat8bppIndexed))
268 info->Format = D3DFMT_L8;
269 else if (IsEqualGUID(&pixel_format, &GUID_WICPixelFormat16bppBGR555))
270 info->Format = D3DFMT_X1R5G5B5;
271 else if (IsEqualGUID(&pixel_format, &GUID_WICPixelFormat24bppBGR))
272 info->Format = D3DFMT_R8G8B8;
273 else if (IsEqualGUID(&pixel_format, &GUID_WICPixelFormat32bppBGR))
274 info->Format = D3DFMT_X8R8G8B8;
275 else if (IsEqualGUID(&pixel_format, &GUID_WICPixelFormat32bppBGRA))
276 info->Format = D3DFMT_A8R8G8B8;
277 else {
278 WARN("Unsupported pixel format %s\n", debugstr_guid(&pixel_format));
279 hr = D3DXERR_INVALIDDATA;
284 if (frame)
285 IWICBitmapFrameDecode_Release(frame);
287 info->Depth = 1;
288 info->MipLevels = 1;
289 info->ResourceType = D3DRTYPE_TEXTURE;
293 if (decoder)
294 IWICBitmapDecoder_Release(decoder);
296 if (SUCCEEDED(initresult))
297 CoUninitialize();
299 if (FAILED(hr)) {
300 TRACE("Invalid or unsupported image file\n");
301 return D3DXERR_INVALIDDATA;
304 return D3D_OK;
307 /************************************************************
308 * D3DXGetImageInfoFromFile
310 * RETURNS
311 * Success: D3D_OK, if we successfully load a valid image file or
312 * if we successfully load a file which is no valid image and info is NULL
313 * Failure: D3DXERR_INVALIDDATA, if we fail to load file or
314 * if file is not a valid image file and info is not NULL
315 * D3DERR_INVALIDCALL, if file is NULL
318 HRESULT WINAPI D3DXGetImageInfoFromFileA(LPCSTR file, D3DXIMAGE_INFO *info)
320 LPWSTR widename;
321 HRESULT hr;
322 int strlength;
324 TRACE("(%s, %p): relay\n", debugstr_a(file), info);
326 if( !file ) return D3DERR_INVALIDCALL;
328 strlength = MultiByteToWideChar(CP_ACP, 0, file, -1, NULL, 0);
329 widename = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, strlength * sizeof(WCHAR));
330 MultiByteToWideChar(CP_ACP, 0, file, -1, widename, strlength);
332 hr = D3DXGetImageInfoFromFileW(widename, info);
333 HeapFree(GetProcessHeap(), 0, widename);
335 return hr;
338 HRESULT WINAPI D3DXGetImageInfoFromFileW(LPCWSTR file, D3DXIMAGE_INFO *info)
340 HRESULT hr;
341 DWORD size;
342 LPVOID buffer;
344 TRACE("(%s, %p): relay\n", debugstr_w(file), info);
346 if( !file ) return D3DERR_INVALIDCALL;
348 hr = map_view_of_file(file, &buffer, &size);
349 if(FAILED(hr)) return D3DXERR_INVALIDDATA;
351 hr = D3DXGetImageInfoFromFileInMemory(buffer, size, info);
352 UnmapViewOfFile(buffer);
354 return hr;
357 /************************************************************
358 * D3DXGetImageInfoFromResource
360 * RETURNS
361 * Success: D3D_OK, if resource is a valid image file
362 * Failure: D3DXERR_INVALIDDATA, if resource is no valid image file or NULL or
363 * if we fail to load resource
366 HRESULT WINAPI D3DXGetImageInfoFromResourceA(HMODULE module, LPCSTR resource, D3DXIMAGE_INFO *info)
368 HRSRC resinfo;
370 TRACE("(%p, %s, %p)\n", module, debugstr_a(resource), info);
372 resinfo = FindResourceA(module, resource, (LPCSTR)RT_RCDATA);
373 if(resinfo) {
374 LPVOID buffer;
375 HRESULT hr;
376 DWORD size;
378 hr = load_resource_into_memory(module, resinfo, &buffer, &size);
379 if(FAILED(hr)) return D3DXERR_INVALIDDATA;
380 return D3DXGetImageInfoFromFileInMemory(buffer, size, info);
383 resinfo = FindResourceA(module, resource, (LPCSTR)RT_BITMAP);
384 if(resinfo) {
385 FIXME("Implement loading bitmaps from resource type RT_BITMAP\n");
386 return E_NOTIMPL;
388 return D3DXERR_INVALIDDATA;
391 HRESULT WINAPI D3DXGetImageInfoFromResourceW(HMODULE module, LPCWSTR resource, D3DXIMAGE_INFO *info)
393 HRSRC resinfo;
395 TRACE("(%p, %s, %p)\n", module, debugstr_w(resource), info);
397 resinfo = FindResourceW(module, resource, (LPCWSTR)RT_RCDATA);
398 if(resinfo) {
399 LPVOID buffer;
400 HRESULT hr;
401 DWORD size;
403 hr = load_resource_into_memory(module, resinfo, &buffer, &size);
404 if(FAILED(hr)) return D3DXERR_INVALIDDATA;
405 return D3DXGetImageInfoFromFileInMemory(buffer, size, info);
408 resinfo = FindResourceW(module, resource, (LPCWSTR)RT_BITMAP);
409 if(resinfo) {
410 FIXME("Implement loading bitmaps from resource type RT_BITMAP\n");
411 return E_NOTIMPL;
413 return D3DXERR_INVALIDDATA;
416 /************************************************************
417 * D3DXLoadSurfaceFromFileInMemory
419 * Loads data from a given buffer into a surface and fills a given
420 * D3DXIMAGE_INFO structure with info about the source data.
422 * PARAMS
423 * pDestSurface [I] pointer to the surface
424 * pDestPalette [I] palette to use
425 * pDestRect [I] to be filled area of the surface
426 * pSrcData [I] pointer to the source data
427 * SrcDataSize [I] size of the source data in bytes
428 * pSrcRect [I] area of the source data to load
429 * dwFilter [I] filter to apply on stretching
430 * Colorkey [I] colorkey
431 * pSrcInfo [O] pointer to a D3DXIMAGE_INFO structure
433 * RETURNS
434 * Success: D3D_OK
435 * Failure: D3DERR_INVALIDCALL, if pDestSurface or pSrcData or SrcDataSize are NULL
436 * D3DXERR_INVALIDDATA, if pSrcData is no valid image file
439 HRESULT WINAPI D3DXLoadSurfaceFromFileInMemory(LPDIRECT3DSURFACE9 pDestSurface,
440 CONST PALETTEENTRY *pDestPalette,
441 CONST RECT *pDestRect,
442 LPCVOID pSrcData,
443 UINT SrcDataSize,
444 CONST RECT *pSrcRect,
445 DWORD dwFilter,
446 D3DCOLOR Colorkey,
447 D3DXIMAGE_INFO *pSrcInfo)
449 D3DXIMAGE_INFO imginfo;
450 HRESULT hr;
452 IWICImagingFactory *factory;
453 IWICBitmapDecoder *decoder;
454 IWICBitmapFrameDecode *bitmapframe;
455 IWICStream *stream;
457 const PixelFormatDesc *formatdesc;
458 WICRect wicrect;
459 RECT rect;
461 TRACE("(%p, %p, %p, %p, %d, %p, %d, %x, %p)\n", pDestSurface, pDestPalette, pDestRect, pSrcData,
462 SrcDataSize, pSrcRect, dwFilter, Colorkey, pSrcInfo);
464 if (!pDestSurface || !pSrcData || !SrcDataSize)
465 return D3DERR_INVALIDCALL;
467 hr = D3DXGetImageInfoFromFileInMemory(pSrcData, SrcDataSize, &imginfo);
469 if (FAILED(hr))
470 return hr;
472 CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
474 if (FAILED(CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, &IID_IWICImagingFactory, (void**)&factory)))
475 goto cleanup_err;
477 if (FAILED(IWICImagingFactory_CreateStream(factory, &stream)))
479 IWICImagingFactory_Release(factory);
480 goto cleanup_err;
483 IWICStream_InitializeFromMemory(stream, (BYTE*)pSrcData, SrcDataSize);
485 hr = IWICImagingFactory_CreateDecoderFromStream(factory, (IStream*)stream, NULL, 0, &decoder);
487 IStream_Release(stream);
488 IWICImagingFactory_Release(factory);
490 if (FAILED(hr))
491 goto cleanup_err;
493 hr = IWICBitmapDecoder_GetFrame(decoder, 0, &bitmapframe);
495 if (FAILED(hr))
496 goto cleanup_bmp;
498 if (pSrcRect)
500 wicrect.X = pSrcRect->left;
501 wicrect.Y = pSrcRect->top;
502 wicrect.Width = pSrcRect->right - pSrcRect->left;
503 wicrect.Height = pSrcRect->bottom - pSrcRect->top;
505 else
507 wicrect.X = 0;
508 wicrect.Y = 0;
509 wicrect.Width = imginfo.Width;
510 wicrect.Height = imginfo.Height;
513 SetRect(&rect, 0, 0, wicrect.Width, wicrect.Height);
515 formatdesc = get_format_info(imginfo.Format);
517 if (formatdesc->format == D3DFMT_UNKNOWN)
519 FIXME("Unsupported pixel format\n");
520 hr = D3DXERR_INVALIDDATA;
522 else
524 BYTE *buffer;
525 DWORD pitch;
527 pitch = formatdesc->bytes_per_pixel * wicrect.Width;
528 buffer = HeapAlloc(GetProcessHeap(), 0, pitch * wicrect.Height);
530 hr = IWICBitmapFrameDecode_CopyPixels(bitmapframe, &wicrect, pitch,
531 pitch * wicrect.Height, buffer);
533 if (SUCCEEDED(hr))
535 hr = D3DXLoadSurfaceFromMemory(pDestSurface, pDestPalette, pDestRect,
536 buffer, imginfo.Format, pitch,
537 NULL, &rect, dwFilter, Colorkey);
540 HeapFree(GetProcessHeap(), 0, buffer);
543 IWICBitmapFrameDecode_Release(bitmapframe);
545 cleanup_bmp:
546 IWICBitmapDecoder_Release(decoder);
548 cleanup_err:
549 CoUninitialize();
551 if (FAILED(hr))
552 return D3DXERR_INVALIDDATA;
554 if (pSrcInfo)
555 *pSrcInfo = imginfo;
557 return D3D_OK;
560 /************************************************************
561 * D3DXLoadSurfaceFromFile
563 HRESULT WINAPI D3DXLoadSurfaceFromFileA(LPDIRECT3DSURFACE9 pDestSurface,
564 CONST PALETTEENTRY *pDestPalette,
565 CONST RECT *pDestRect,
566 LPCSTR pSrcFile,
567 CONST RECT *pSrcRect,
568 DWORD dwFilter,
569 D3DCOLOR Colorkey,
570 D3DXIMAGE_INFO *pSrcInfo)
572 LPWSTR pWidename;
573 HRESULT hr;
574 int strlength;
576 TRACE("(%p, %p, %p, %s, %p, %u, %#x, %p): relay\n", pDestSurface, pDestPalette, pDestRect, debugstr_a(pSrcFile),
577 pSrcRect, dwFilter, Colorkey, pSrcInfo);
579 if( !pSrcFile || !pDestSurface ) return D3DERR_INVALIDCALL;
581 strlength = MultiByteToWideChar(CP_ACP, 0, pSrcFile, -1, NULL, 0);
582 pWidename = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, strlength * sizeof(WCHAR));
583 MultiByteToWideChar(CP_ACP, 0, pSrcFile, -1, pWidename, strlength);
585 hr = D3DXLoadSurfaceFromFileW(pDestSurface, pDestPalette, pDestRect, pWidename, pSrcRect, dwFilter, Colorkey, pSrcInfo);
586 HeapFree(GetProcessHeap(), 0, pWidename);
588 return hr;
591 HRESULT WINAPI D3DXLoadSurfaceFromFileW(LPDIRECT3DSURFACE9 pDestSurface,
592 CONST PALETTEENTRY *pDestPalette,
593 CONST RECT *pDestRect,
594 LPCWSTR pSrcFile,
595 CONST RECT *pSrcRect,
596 DWORD Filter,
597 D3DCOLOR Colorkey,
598 D3DXIMAGE_INFO *pSrcInfo)
600 HRESULT hr;
601 DWORD dwSize;
602 LPVOID pBuffer;
604 TRACE("(%p, %p, %p, %s, %p, %u, %#x, %p): relay\n", pDestSurface, pDestPalette, pDestRect, debugstr_w(pSrcFile),
605 pSrcRect, Filter, Colorkey, pSrcInfo);
607 if( !pSrcFile || !pDestSurface ) return D3DERR_INVALIDCALL;
609 hr = map_view_of_file(pSrcFile, &pBuffer, &dwSize);
610 if(FAILED(hr)) return D3DXERR_INVALIDDATA;
612 hr = D3DXLoadSurfaceFromFileInMemory(pDestSurface, pDestPalette, pDestRect, pBuffer, dwSize, pSrcRect, Filter, Colorkey, pSrcInfo);
613 UnmapViewOfFile(pBuffer);
615 return hr;
618 /************************************************************
619 * D3DXLoadSurfaceFromResource
621 HRESULT WINAPI D3DXLoadSurfaceFromResourceA(LPDIRECT3DSURFACE9 pDestSurface,
622 CONST PALETTEENTRY *pDestPalette,
623 CONST RECT *pDestRect,
624 HMODULE hSrcModule,
625 LPCSTR pResource,
626 CONST RECT *pSrcRect,
627 DWORD dwFilter,
628 D3DCOLOR Colorkey,
629 D3DXIMAGE_INFO *pSrcInfo)
631 HRSRC hResInfo;
633 TRACE("(%p, %p, %p, %p, %s, %p, %u, %#x, %p): relay\n", pDestSurface, pDestPalette, pDestRect, hSrcModule,
634 debugstr_a(pResource), pSrcRect, dwFilter, Colorkey, pSrcInfo);
636 if( !pDestSurface ) return D3DERR_INVALIDCALL;
638 hResInfo = FindResourceA(hSrcModule, pResource, (LPCSTR)RT_RCDATA);
639 if(hResInfo) {
640 LPVOID pBuffer;
641 HRESULT hr;
642 DWORD dwSize;
644 hr = load_resource_into_memory(hSrcModule, hResInfo, &pBuffer, &dwSize);
645 if(FAILED(hr)) return D3DXERR_INVALIDDATA;
646 return D3DXLoadSurfaceFromFileInMemory(pDestSurface, pDestPalette, pDestRect, pBuffer, dwSize, pSrcRect, dwFilter, Colorkey, pSrcInfo);
649 hResInfo = FindResourceA(hSrcModule, pResource, (LPCSTR)RT_BITMAP);
650 if(hResInfo) {
651 FIXME("Implement loading bitmaps from resource type RT_BITMAP\n");
652 return E_NOTIMPL;
654 return D3DXERR_INVALIDDATA;
657 HRESULT WINAPI D3DXLoadSurfaceFromResourceW(LPDIRECT3DSURFACE9 pDestSurface,
658 CONST PALETTEENTRY *pDestPalette,
659 CONST RECT *pDestRect,
660 HMODULE hSrcModule,
661 LPCWSTR pResource,
662 CONST RECT *pSrcRect,
663 DWORD dwFilter,
664 D3DCOLOR Colorkey,
665 D3DXIMAGE_INFO *pSrcInfo)
667 HRSRC hResInfo;
669 TRACE("(%p, %p, %p, %p, %s, %p, %u, %#x, %p): relay\n", pDestSurface, pDestPalette, pDestRect, hSrcModule,
670 debugstr_w(pResource), pSrcRect, dwFilter, Colorkey, pSrcInfo);
672 if( !pDestSurface ) return D3DERR_INVALIDCALL;
674 hResInfo = FindResourceW(hSrcModule, pResource, (LPCWSTR)RT_RCDATA);
675 if(hResInfo) {
676 LPVOID pBuffer;
677 HRESULT hr;
678 DWORD dwSize;
680 hr = load_resource_into_memory(hSrcModule, hResInfo, &pBuffer, &dwSize);
681 if(FAILED(hr)) return D3DXERR_INVALIDDATA;
682 return D3DXLoadSurfaceFromFileInMemory(pDestSurface, pDestPalette, pDestRect, pBuffer, dwSize, pSrcRect, dwFilter, Colorkey, pSrcInfo);
685 hResInfo = FindResourceW(hSrcModule, pResource, (LPCWSTR)RT_BITMAP);
686 if(hResInfo) {
687 FIXME("Implement loading bitmaps from resource type RT_BITMAP\n");
688 return E_NOTIMPL;
690 return D3DXERR_INVALIDDATA;
694 /************************************************************
695 * helper functions for D3DXLoadSurfaceFromMemory
697 struct argb_conversion_info
699 CONST PixelFormatDesc *srcformat;
700 CONST PixelFormatDesc *destformat;
701 DWORD srcshift[4], destshift[4];
702 DWORD srcmask[4], destmask[4];
703 BOOL process_channel[4];
704 DWORD channelmask;
707 static void init_argb_conversion_info(CONST PixelFormatDesc *srcformat, CONST PixelFormatDesc *destformat, struct argb_conversion_info *info)
709 UINT i;
710 ZeroMemory(info->process_channel, 4 * sizeof(BOOL));
711 info->channelmask = 0;
713 info->srcformat = srcformat;
714 info->destformat = destformat;
716 for(i = 0;i < 4;i++) {
717 /* srcshift is used to extract the _relevant_ components */
718 info->srcshift[i] = srcformat->shift[i] + max( srcformat->bits[i] - destformat->bits[i], 0);
720 /* destshift is used to move the components to the correct position */
721 info->destshift[i] = destformat->shift[i] + max(destformat->bits[i] - srcformat->bits[i], 0);
723 info->srcmask[i] = ((1 << srcformat->bits[i]) - 1) << srcformat->shift[i];
724 info->destmask[i] = ((1 << destformat->bits[i]) - 1) << destformat->shift[i];
726 /* channelmask specifies bits which aren't used in the source format but in the destination one */
727 if(destformat->bits[i]) {
728 if(srcformat->bits[i]) info->process_channel[i] = TRUE;
729 else info->channelmask |= info->destmask[i];
734 static DWORD dword_from_bytes(CONST BYTE *src, UINT bytes_per_pixel)
736 DWORD ret = 0;
737 static BOOL fixme_once;
739 if(bytes_per_pixel > sizeof(DWORD)) {
740 if(!fixme_once++) FIXME("Unsupported image: %u bytes per pixel\n", bytes_per_pixel);
741 bytes_per_pixel = sizeof(DWORD);
744 memcpy(&ret, src, bytes_per_pixel);
745 return ret;
748 static void dword_to_bytes(BYTE *dst, DWORD dword, UINT bytes_per_pixel)
750 static BOOL fixme_once;
752 if(bytes_per_pixel > sizeof(DWORD)) {
753 if(!fixme_once++) FIXME("Unsupported image: %u bytes per pixel\n", bytes_per_pixel);
754 ZeroMemory(dst, bytes_per_pixel);
755 bytes_per_pixel = sizeof(DWORD);
758 memcpy(dst, &dword, bytes_per_pixel);
761 /************************************************************
762 * get_relevant_argb_components
764 * Extracts the relevant components from the source color and
765 * drops the less significant bits if they aren't used by the destination format.
767 static void get_relevant_argb_components(CONST struct argb_conversion_info *info, CONST DWORD col, DWORD *out)
769 UINT i = 0;
770 for(;i < 4;i++)
771 if(info->process_channel[i])
772 out[i] = (col & info->srcmask[i]) >> info->srcshift[i];
775 /************************************************************
776 * make_argb_color
778 * Recombines the output of get_relevant_argb_components and converts
779 * it to the destination format.
781 static DWORD make_argb_color(CONST struct argb_conversion_info *info, CONST DWORD *in)
783 UINT i;
784 DWORD val = 0;
786 for(i = 0;i < 4;i++) {
787 if(info->process_channel[i]) {
788 /* necessary to make sure that e.g. an X4R4G4B4 white maps to an R8G8B8 white instead of 0xf0f0f0 */
789 signed int shift;
790 for(shift = info->destshift[i]; shift > info->destformat->shift[i]; shift -= info->srcformat->bits[i]) val |= in[i] << shift;
791 val |= (in[i] >> (info->destformat->shift[i] - shift)) << info->destformat->shift[i];
794 val |= info->channelmask; /* new channels are set to their maximal value */
795 return val;
798 static void format_to_vec4(const PixelFormatDesc *format, const DWORD *src, struct vec4 *dst)
800 DWORD mask;
802 if (format->bits[1])
804 mask = (1 << format->bits[1]) - 1;
805 dst->x = (float)((*src >> format->shift[1]) & mask) / mask;
807 else
808 dst->x = 1.0f;
810 if (format->bits[2])
812 mask = (1 << format->bits[2]) - 1;
813 dst->y = (float)((*src >> format->shift[2]) & mask) / mask;
815 else
816 dst->y = 1.0f;
818 if (format->bits[3])
820 mask = (1 << format->bits[3]) - 1;
821 dst->z = (float)((*src >> format->shift[3]) & mask) / mask;
823 else
824 dst->z = 1.0f;
826 if (format->bits[0])
828 mask = (1 << format->bits[0]) - 1;
829 dst->w = (float)((*src >> format->shift[0]) & mask) / mask;
831 else
832 dst->w = 1.0f;
835 static void format_from_vec4(const PixelFormatDesc *format, const struct vec4 *src, DWORD *dst)
837 *dst = 0;
839 if (format->bits[1])
840 *dst |= (DWORD)(src->x * ((1 << format->bits[1]) - 1) + 0.5f) << format->shift[1];
841 if (format->bits[2])
842 *dst |= (DWORD)(src->y * ((1 << format->bits[2]) - 1) + 0.5f) << format->shift[2];
843 if (format->bits[3])
844 *dst |= (DWORD)(src->z * ((1 << format->bits[3]) - 1) + 0.5f) << format->shift[3];
845 if (format->bits[0])
846 *dst |= (DWORD)(src->w * ((1 << format->bits[0]) - 1) + 0.5f) << format->shift[0];
849 /************************************************************
850 * copy_simple_data
852 * Copies the source buffer to the destination buffer, performing
853 * any necessary format conversion and color keying.
854 * Pixels outsize the source rect are blacked out.
855 * Works only for ARGB formats with 1 - 4 bytes per pixel.
857 static void copy_simple_data(const BYTE *src, UINT srcpitch, SIZE src_size, const PixelFormatDesc *srcformat,
858 BYTE *dest, UINT destpitch, SIZE dst_size, const PixelFormatDesc *destformat, D3DCOLOR colorkey)
860 struct argb_conversion_info conv_info, ck_conv_info;
861 const PixelFormatDesc *ck_format = NULL;
862 DWORD channels[4], pixel;
863 UINT minwidth, minheight;
864 UINT x, y;
866 ZeroMemory(channels, sizeof(channels));
867 init_argb_conversion_info(srcformat, destformat, &conv_info);
869 minwidth = (src_size.cx < dst_size.cx) ? src_size.cx : dst_size.cx;
870 minheight = (src_size.cy < dst_size.cy) ? src_size.cy : dst_size.cy;
872 if (colorkey)
874 /* Color keys are always represented in D3DFMT_A8R8G8B8 format. */
875 ck_format = get_format_info(D3DFMT_A8R8G8B8);
876 init_argb_conversion_info(srcformat, ck_format, &ck_conv_info);
879 for(y = 0;y < minheight;y++) {
880 const BYTE *srcptr = src + y * srcpitch;
881 BYTE *destptr = dest + y * destpitch;
882 DWORD val;
884 for(x = 0;x < minwidth;x++) {
885 /* extract source color components */
886 pixel = dword_from_bytes(srcptr, srcformat->bytes_per_pixel);
888 if (!srcformat->to_rgba && !destformat->from_rgba)
890 get_relevant_argb_components(&conv_info, pixel, channels);
891 val = make_argb_color(&conv_info, channels);
893 if (colorkey)
895 get_relevant_argb_components(&ck_conv_info, pixel, channels);
896 pixel = make_argb_color(&ck_conv_info, channels);
897 if (pixel == colorkey)
898 val &= ~conv_info.destmask[0];
901 else
903 struct vec4 color, tmp;
905 format_to_vec4(srcformat, &pixel, &color);
906 if (srcformat->to_rgba)
907 srcformat->to_rgba(&color, &tmp);
908 else
909 tmp = color;
911 if (ck_format)
913 format_from_vec4(ck_format, &tmp, &pixel);
914 if (pixel == colorkey)
915 tmp.w = 0.0f;
918 if (destformat->from_rgba)
919 destformat->from_rgba(&tmp, &color);
920 else
921 color = tmp;
923 format_from_vec4(destformat, &color, &val);
926 dword_to_bytes(destptr, val, destformat->bytes_per_pixel);
927 srcptr += srcformat->bytes_per_pixel;
928 destptr += destformat->bytes_per_pixel;
931 if (src_size.cx < dst_size.cx) /* black out remaining pixels */
932 memset(destptr, 0, destformat->bytes_per_pixel * (dst_size.cx - src_size.cx));
934 if (src_size.cy < dst_size.cy) /* black out remaining pixels */
935 memset(dest + src_size.cy * destpitch, 0, destpitch * (dst_size.cy - src_size.cy));
938 /************************************************************
939 * point_filter_simple_data
941 * Copies the source buffer to the destination buffer, performing
942 * any necessary format conversion, color keying and stretching
943 * using a point filter.
944 * Works only for ARGB formats with 1 - 4 bytes per pixel.
946 static void point_filter_simple_data(const BYTE *src, UINT srcpitch, SIZE src_size, const PixelFormatDesc *srcformat,
947 BYTE *dest, UINT destpitch, SIZE dst_size, const PixelFormatDesc *destformat, D3DCOLOR colorkey)
949 struct argb_conversion_info conv_info, ck_conv_info;
950 const PixelFormatDesc *ck_format = NULL;
951 DWORD channels[4], pixel;
953 UINT x, y;
955 ZeroMemory(channels, sizeof(channels));
956 init_argb_conversion_info(srcformat, destformat, &conv_info);
958 if (colorkey)
960 /* Color keys are always represented in D3DFMT_A8R8G8B8 format. */
961 ck_format = get_format_info(D3DFMT_A8R8G8B8);
962 init_argb_conversion_info(srcformat, ck_format, &ck_conv_info);
965 for (y = 0; y < dst_size.cy; ++y)
967 BYTE *destptr = dest + y * destpitch;
968 const BYTE *bufptr = src + srcpitch * (y * src_size.cy / dst_size.cy);
970 for (x = 0; x < dst_size.cx; ++x)
972 const BYTE *srcptr = bufptr + (x * src_size.cx / dst_size.cx) * srcformat->bytes_per_pixel;
973 DWORD val;
975 /* extract source color components */
976 pixel = dword_from_bytes(srcptr, srcformat->bytes_per_pixel);
978 if (!srcformat->to_rgba && !destformat->from_rgba)
980 get_relevant_argb_components(&conv_info, pixel, channels);
981 val = make_argb_color(&conv_info, channels);
983 if (colorkey)
985 get_relevant_argb_components(&ck_conv_info, pixel, channels);
986 pixel = make_argb_color(&ck_conv_info, channels);
987 if (pixel == colorkey)
988 val &= ~conv_info.destmask[0];
991 else
993 struct vec4 color, tmp;
995 format_to_vec4(srcformat, &pixel, &color);
996 if (srcformat->to_rgba)
997 srcformat->to_rgba(&color, &tmp);
998 else
999 tmp = color;
1001 if (ck_format)
1003 format_from_vec4(ck_format, &tmp, &pixel);
1004 if (pixel == colorkey)
1005 tmp.w = 0.0f;
1008 if (destformat->from_rgba)
1009 destformat->from_rgba(&tmp, &color);
1010 else
1011 color = tmp;
1013 format_from_vec4(destformat, &color, &val);
1016 dword_to_bytes(destptr, val, destformat->bytes_per_pixel);
1017 destptr += destformat->bytes_per_pixel;
1022 /************************************************************
1023 * D3DXLoadSurfaceFromMemory
1025 * Loads data from a given memory chunk into a surface,
1026 * applying any of the specified filters.
1028 * PARAMS
1029 * pDestSurface [I] pointer to the surface
1030 * pDestPalette [I] palette to use
1031 * pDestRect [I] to be filled area of the surface
1032 * pSrcMemory [I] pointer to the source data
1033 * SrcFormat [I] format of the source pixel data
1034 * SrcPitch [I] number of bytes in a row
1035 * pSrcPalette [I] palette used in the source image
1036 * pSrcRect [I] area of the source data to load
1037 * dwFilter [I] filter to apply on stretching
1038 * Colorkey [I] colorkey
1040 * RETURNS
1041 * Success: D3D_OK, if we successfully load the pixel data into our surface or
1042 * if pSrcMemory is NULL but the other parameters are valid
1043 * Failure: D3DERR_INVALIDCALL, if pDestSurface, SrcPitch or pSrcRect are NULL or
1044 * if SrcFormat is an invalid format (other than D3DFMT_UNKNOWN) or
1045 * if DestRect is invalid
1046 * D3DXERR_INVALIDDATA, if we fail to lock pDestSurface
1047 * E_FAIL, if SrcFormat is D3DFMT_UNKNOWN or the dimensions of pSrcRect are invalid
1049 * NOTES
1050 * pSrcRect specifies the dimensions of the source data;
1051 * negative values for pSrcRect are allowed as we're only looking at the width and height anyway.
1054 HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface,
1055 const PALETTEENTRY *dst_palette, const RECT *dst_rect, const void *src_memory,
1056 D3DFORMAT src_format, UINT src_pitch, const PALETTEENTRY *src_palette, const RECT *src_rect,
1057 DWORD filter, D3DCOLOR color_key)
1059 CONST PixelFormatDesc *srcformatdesc, *destformatdesc;
1060 D3DSURFACE_DESC surfdesc;
1061 D3DLOCKED_RECT lockrect;
1062 SIZE src_size, dst_size;
1063 HRESULT hr;
1065 TRACE("(%p, %p, %s, %p, %#x, %u, %p, %s %#x, 0x%08x)\n",
1066 dst_surface, dst_palette, wine_dbgstr_rect(dst_rect), src_memory, src_format,
1067 src_pitch, src_palette, wine_dbgstr_rect(src_rect), filter, color_key);
1069 if (!dst_surface || !src_memory || !src_rect)
1070 return D3DERR_INVALIDCALL;
1071 if (src_format == D3DFMT_UNKNOWN
1072 || src_rect->left >= src_rect->right
1073 || src_rect->top >= src_rect->bottom)
1074 return E_FAIL;
1076 if (filter == D3DX_DEFAULT)
1077 filter = D3DX_FILTER_TRIANGLE | D3DX_FILTER_DITHER;
1079 IDirect3DSurface9_GetDesc(dst_surface, &surfdesc);
1081 src_size.cx = src_rect->right - src_rect->left;
1082 src_size.cy = src_rect->bottom - src_rect->top;
1083 if (!dst_rect)
1085 dst_size.cx = surfdesc.Width;
1086 dst_size.cy = surfdesc.Height;
1088 else
1090 if (dst_rect->left > dst_rect->right || dst_rect->right > surfdesc.Width)
1091 return D3DERR_INVALIDCALL;
1092 if (dst_rect->top > dst_rect->bottom || dst_rect->bottom > surfdesc.Height)
1093 return D3DERR_INVALIDCALL;
1094 if (dst_rect->left < 0 || dst_rect->top < 0)
1095 return D3DERR_INVALIDCALL;
1096 dst_size.cx = dst_rect->right - dst_rect->left;
1097 dst_size.cy = dst_rect->bottom - dst_rect->top;
1098 if (!dst_size.cx || !dst_size.cy)
1099 return D3D_OK;
1102 srcformatdesc = get_format_info(src_format);
1103 if (srcformatdesc->type == FORMAT_UNKNOWN)
1104 return E_NOTIMPL;
1106 destformatdesc = get_format_info(surfdesc.Format);
1107 if (destformatdesc->type == FORMAT_UNKNOWN)
1108 return E_NOTIMPL;
1110 if (src_format == surfdesc.Format
1111 && dst_size.cx == src_size.cx
1112 && dst_size.cy == src_size.cy) /* Simple copy. */
1114 UINT row_block_count = ((src_size.cx + srcformatdesc->block_width - 1) / srcformatdesc->block_width);
1115 UINT row_count = (src_size.cy + srcformatdesc->block_height - 1) / srcformatdesc->block_height;
1116 const BYTE *src_addr;
1117 BYTE *dst_addr;
1118 UINT row;
1120 if (src_rect->left & (srcformatdesc->block_width - 1)
1121 || src_rect->top & (srcformatdesc->block_height - 1)
1122 || (src_rect->right & (srcformatdesc->block_width - 1)
1123 && src_size.cx != surfdesc.Width)
1124 || (src_rect->bottom & (srcformatdesc->block_height - 1)
1125 && src_size.cy != surfdesc.Height))
1127 WARN("Source rect %s is misaligned.\n", wine_dbgstr_rect(src_rect));
1128 return D3DXERR_INVALIDDATA;
1131 if (FAILED(hr = IDirect3DSurface9_LockRect(dst_surface, &lockrect, dst_rect, 0)))
1132 return D3DXERR_INVALIDDATA;
1134 src_addr = src_memory;
1135 src_addr += (src_rect->top / srcformatdesc->block_height) * src_pitch;
1136 src_addr += (src_rect->left / srcformatdesc->block_width) * srcformatdesc->block_byte_count;
1137 dst_addr = lockrect.pBits;
1139 for (row = 0; row < row_count; ++row)
1141 memcpy(dst_addr, src_addr, row_block_count * srcformatdesc->block_byte_count);
1142 src_addr += src_pitch;
1143 dst_addr += lockrect.Pitch;
1146 IDirect3DSurface9_UnlockRect(dst_surface);
1148 else /* Stretching or format conversion. */
1150 if (srcformatdesc->bytes_per_pixel > 4)
1151 return E_NOTIMPL;
1152 if (destformatdesc->bytes_per_pixel > 4)
1153 return E_NOTIMPL;
1154 if (srcformatdesc->block_height != 1 || srcformatdesc->block_width != 1)
1155 return E_NOTIMPL;
1156 if (destformatdesc->block_height != 1 || destformatdesc->block_width != 1)
1157 return E_NOTIMPL;
1159 if (FAILED(hr = IDirect3DSurface9_LockRect(dst_surface, &lockrect, dst_rect, 0)))
1160 return D3DXERR_INVALIDDATA;
1162 if ((filter & 0xf) == D3DX_FILTER_NONE)
1164 copy_simple_data(src_memory, src_pitch, src_size, srcformatdesc,
1165 lockrect.pBits, lockrect.Pitch, dst_size, destformatdesc, color_key);
1167 else /* if ((filter & 0xf) == D3DX_FILTER_POINT) */
1169 if ((filter & 0xf) != D3DX_FILTER_POINT)
1170 FIXME("Unhandled filter %#x.\n", filter);
1172 /* Always apply a point filter until D3DX_FILTER_LINEAR,
1173 * D3DX_FILTER_TRIANGLE and D3DX_FILTER_BOX are implemented. */
1174 point_filter_simple_data(src_memory, src_pitch, src_size, srcformatdesc,
1175 lockrect.pBits, lockrect.Pitch, dst_size, destformatdesc, color_key);
1178 IDirect3DSurface9_UnlockRect(dst_surface);
1181 return D3D_OK;
1184 /************************************************************
1185 * D3DXLoadSurfaceFromSurface
1187 * Copies the contents from one surface to another, performing any required
1188 * format conversion, resizing or filtering.
1190 * PARAMS
1191 * pDestSurface [I] pointer to the destination surface
1192 * pDestPalette [I] palette to use
1193 * pDestRect [I] to be filled area of the surface
1194 * pSrcSurface [I] pointer to the source surface
1195 * pSrcPalette [I] palette used for the source surface
1196 * pSrcRect [I] area of the source data to load
1197 * dwFilter [I] filter to apply on resizing
1198 * Colorkey [I] any ARGB value or 0 to disable color-keying
1200 * RETURNS
1201 * Success: D3D_OK
1202 * Failure: D3DERR_INVALIDCALL, if pDestSurface or pSrcSurface are NULL
1203 * D3DXERR_INVALIDDATA, if one of the surfaces is not lockable
1206 HRESULT WINAPI D3DXLoadSurfaceFromSurface(LPDIRECT3DSURFACE9 pDestSurface,
1207 CONST PALETTEENTRY *pDestPalette,
1208 CONST RECT *pDestRect,
1209 LPDIRECT3DSURFACE9 pSrcSurface,
1210 CONST PALETTEENTRY *pSrcPalette,
1211 CONST RECT *pSrcRect,
1212 DWORD dwFilter,
1213 D3DCOLOR Colorkey)
1215 RECT rect;
1216 D3DLOCKED_RECT lock;
1217 D3DSURFACE_DESC SrcDesc;
1218 HRESULT hr;
1220 TRACE("(%p, %p, %p, %p, %p, %p, %u, %#x): relay\n", pDestSurface, pDestPalette, pDestRect,
1221 pSrcSurface, pSrcPalette, pSrcRect, dwFilter, Colorkey);
1223 if( !pDestSurface || !pSrcSurface ) return D3DERR_INVALIDCALL;
1225 IDirect3DSurface9_GetDesc(pSrcSurface, &SrcDesc);
1227 if( !pSrcRect ) SetRect(&rect, 0, 0, SrcDesc.Width, SrcDesc.Height);
1228 else rect = *pSrcRect;
1230 hr = IDirect3DSurface9_LockRect(pSrcSurface, &lock, NULL, D3DLOCK_READONLY);
1231 if(FAILED(hr)) return D3DXERR_INVALIDDATA;
1233 hr = D3DXLoadSurfaceFromMemory(pDestSurface, pDestPalette, pDestRect,
1234 lock.pBits, SrcDesc.Format, lock.Pitch,
1235 pSrcPalette, &rect, dwFilter, Colorkey);
1237 IDirect3DSurface9_UnlockRect(pSrcSurface);
1238 return hr;
1242 HRESULT WINAPI D3DXSaveSurfaceToFileA(LPCSTR pDestFile, D3DXIMAGE_FILEFORMAT DestFormat,
1243 LPDIRECT3DSURFACE9 pSrcSurface, const PALETTEENTRY* pSrcPalette, const RECT* pSrcRect)
1245 FIXME("(%p, %d, %p, %p, %p): stub\n", pDestFile, DestFormat, pSrcSurface, pSrcPalette, pSrcRect);
1246 return D3DERR_INVALIDCALL;
1249 HRESULT WINAPI D3DXSaveSurfaceToFileW(LPCWSTR pDestFile, D3DXIMAGE_FILEFORMAT DestFormat,
1250 LPDIRECT3DSURFACE9 pSrcSurface, const PALETTEENTRY* pSrcPalette, const RECT* pSrcRect)
1252 FIXME("(%p, %d, %p, %p, %p): stub\n", pDestFile, DestFormat, pSrcSurface, pSrcPalette, pSrcRect);
1253 return D3DERR_INVALIDCALL;