ReactOS 0.4.15-dev-8093-g3285f69
d3dx9tex.h File Reference
#include <d3dx9.h>
Include dependency graph for d3dx9tex.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _D3DXIMAGE_INFO
 

Macros

#define D3DX_FILTER_NONE   0x00000001
 
#define D3DX_FILTER_POINT   0x00000002
 
#define D3DX_FILTER_LINEAR   0x00000003
 
#define D3DX_FILTER_TRIANGLE   0x00000004
 
#define D3DX_FILTER_BOX   0x00000005
 
#define D3DX_FILTER_MIRROR_U   0x00010000
 
#define D3DX_FILTER_MIRROR_V   0x00020000
 
#define D3DX_FILTER_MIRROR_W   0x00040000
 
#define D3DX_FILTER_MIRROR   0x00070000
 
#define D3DX_FILTER_DITHER   0x00080000
 
#define D3DX_FILTER_DITHER_DIFFUSION   0x00100000
 
#define D3DX_FILTER_SRGB_IN   0x00200000
 
#define D3DX_FILTER_SRGB_OUT   0x00400000
 
#define D3DX_FILTER_SRGB   0x00600000
 
#define D3DX_SKIP_DDS_MIP_LEVELS_MASK   0x1f
 
#define D3DX_SKIP_DDS_MIP_LEVELS_SHIFT   26
 
#define D3DX_SKIP_DDS_MIP_LEVELS(l, f)
 
#define D3DX_NORMALMAP_MIRROR_U   0x00010000
 
#define D3DX_NORMALMAP_MIRROR_V   0x00020000
 
#define D3DX_NORMALMAP_MIRROR   0x00030000
 
#define D3DX_NORMALMAP_INVERTSIGN   0x00080000
 
#define D3DX_NORMALMAP_COMPUTE_OCCLUSION   0x00100000
 
#define D3DX_CHANNEL_RED   0x00000001
 
#define D3DX_CHANNEL_BLUE   0x00000002
 
#define D3DX_CHANNEL_GREEN   0x00000004
 
#define D3DX_CHANNEL_ALPHA   0x00000008
 
#define D3DX_CHANNEL_LUMINANCE   0x00000010
 
#define D3DXGetImageInfoFromFile   WINELIB_NAME_AW(D3DXGetImageInfoFromFile)
 
#define D3DXGetImageInfoFromResource   WINELIB_NAME_AW(D3DXGetImageInfoFromResource)
 
#define D3DXLoadSurfaceFromFile   WINELIB_NAME_AW(D3DXLoadSurfaceFromFile)
 
#define D3DXLoadSurfaceFromResource   WINELIB_NAME_AW(D3DXLoadSurfaceFromResource)
 
#define D3DXSaveSurfaceToFile   WINELIB_NAME_AW(D3DXSaveSurfaceToFile)
 
#define D3DXLoadVolumeFromFile   WINELIB_NAME_AW(D3DXLoadVolumeFromFile)
 
#define D3DXLoadVolumeFromResource   WINELIB_NAME_AW(D3DXLoadVolumeFromResource)
 
#define D3DXSaveVolumeToFile   WINELIB_NAME_AW(D3DXSaveVolumeToFile)
 
#define D3DXCreateTextureFromFile   WINELIB_NAME_AW(D3DXCreateTextureFromFile)
 
#define D3DXCreateCubeTextureFromFile   WINELIB_NAME_AW(D3DXCreateCubeTextureFromFile)
 
#define D3DXCreateVolumeTextureFromFile   WINELIB_NAME_AW(D3DXCreateVolumeTextureFromFile)
 
#define D3DXCreateTextureFromResource   WINELIB_NAME_AW(D3DXCreateTextureFromResource)
 
#define D3DXCreateCubeTextureFromResource   WINELIB_NAME_AW(D3DXCreateCubeTextureFromResource)
 
#define D3DXCreateVolumeTextureFromResource   WINELIB_NAME_AW(D3DXCreateVolumeTextureFromResource)
 
#define D3DXCreateTextureFromFileEx   WINELIB_NAME_AW(D3DXCreateTextureFromFileEx)
 
#define D3DXCreateCubeTextureFromFileEx   WINELIB_NAME_AW(D3DXCreateCubeTextureFromFileEx)
 
#define D3DXCreateVolumeTextureFromFileEx   WINELIB_NAME_AW(D3DXCreateVolumeTextureFromFileEx)
 
#define D3DXCreateTextureFromResourceEx   WINELIB_NAME_AW(D3DXCreateTextureFromResourceEx)
 
#define D3DXCreateCubeTextureFromResourceEx   WINELIB_NAME_AW(D3DXCreateCubeTextureFromResourceEx)
 
#define D3DXCreateVolumeTextureFromResourceEx   WINELIB_NAME_AW(D3DXCreateVolumeTextureFromResourceEx)
 
#define D3DXSaveTextureToFile   WINELIB_NAME_AW(D3DXSaveTextureToFile)
 
#define D3DXFilterCubeTexture   D3DXFilterTexture
 
#define D3DXFilterVolumeTexture   D3DXFilterTexture
 

Typedefs

typedef enum _D3DXIMAGE_FILEFORMAT D3DXIMAGE_FILEFORMAT
 
typedef struct _D3DXIMAGE_INFO D3DXIMAGE_INFO
 
typedef void(WINAPILPD3DXFILL2D) (D3DXVECTOR4 *out, const D3DXVECTOR2 *texcoord, const D3DXVECTOR2 *texelsize, void *data)
 
typedef void(WINAPILPD3DXFILL3D) (D3DXVECTOR4 *out, const D3DXVECTOR3 *texcoord, const D3DXVECTOR3 *texelsize, void *data)
 

Enumerations

enum  _D3DXIMAGE_FILEFORMAT {
  D3DXIFF_BMP , D3DXIFF_JPG , D3DXIFF_TGA , D3DXIFF_PNG ,
  D3DXIFF_DDS , D3DXIFF_PPM , D3DXIFF_DIB , D3DXIFF_HDR ,
  D3DXIFF_PFM , D3DXIFF_FORCE_DWORD = 0x7fffffff
}
 

Functions

HRESULT WINAPI D3DXGetImageInfoFromFileA (const char *file, D3DXIMAGE_INFO *info)
 
HRESULT WINAPI D3DXGetImageInfoFromFileW (const WCHAR *file, D3DXIMAGE_INFO *info)
 
HRESULT WINAPI D3DXGetImageInfoFromResourceA (HMODULE module, const char *resource, D3DXIMAGE_INFO *info)
 
HRESULT WINAPI D3DXGetImageInfoFromResourceW (HMODULE module, const WCHAR *resource, D3DXIMAGE_INFO *info)
 
HRESULT WINAPI D3DXGetImageInfoFromFileInMemory (const void *data, UINT data_size, D3DXIMAGE_INFO *info)
 
HRESULT WINAPI D3DXLoadSurfaceFromFileA (struct IDirect3DSurface9 *destsurface, const PALETTEENTRY *destpalette, const RECT *destrect, const char *srcfile, const RECT *srcrect, DWORD filter, D3DCOLOR colorkey, D3DXIMAGE_INFO *srcinfo)
 
HRESULT WINAPI D3DXLoadSurfaceFromFileW (struct IDirect3DSurface9 *destsurface, const PALETTEENTRY *destpalette, const RECT *destrect, const WCHAR *srcfile, const RECT *srcrect, DWORD filter, D3DCOLOR colorkey, D3DXIMAGE_INFO *srcinfo)
 
HRESULT WINAPI D3DXLoadSurfaceFromResourceA (struct IDirect3DSurface9 *destsurface, const PALETTEENTRY *destpalette, const RECT *destrect, HMODULE srcmodule, const char *resource, const RECT *srcrect, DWORD filter, D3DCOLOR colorkey, D3DXIMAGE_INFO *srcinfo)
 
HRESULT WINAPI D3DXLoadSurfaceFromResourceW (struct IDirect3DSurface9 *destsurface, const PALETTEENTRY *destpalette, const RECT *destrect, HMODULE srcmodule, const WCHAR *resource, const RECT *srcrect, DWORD filter, D3DCOLOR colorkey, D3DXIMAGE_INFO *srcinfo)
 
HRESULT WINAPI D3DXLoadSurfaceFromFileInMemory (struct IDirect3DSurface9 *destsurface, const PALETTEENTRY *destpalette, const RECT *destrect, const void *srcdata, UINT srcdatasize, const RECT *srcrect, DWORD filter, D3DCOLOR colorkey, D3DXIMAGE_INFO *srcinfo)
 
HRESULT WINAPI D3DXLoadSurfaceFromSurface (struct IDirect3DSurface9 *destsurface, const PALETTEENTRY *destpalette, const RECT *destrect, struct IDirect3DSurface9 *srcsurface, const PALETTEENTRY *srcpalette, const RECT *srcrect, DWORD filter, D3DCOLOR colorkey)
 
HRESULT WINAPI D3DXLoadSurfaceFromMemory (IDirect3DSurface9 *dst_surface, const PALETTEENTRY *dst_palette, const RECT *dst_rect, const void *src_memory, D3DFORMAT src_format, UINT src_pitch, const PALETTEENTRY *src_palette, const RECT *src_rect, DWORD filter, D3DCOLOR color_key)
 
HRESULT WINAPI D3DXSaveSurfaceToFileInMemory (struct ID3DXBuffer **destbuffer, D3DXIMAGE_FILEFORMAT destformat, struct IDirect3DSurface9 *srcsurface, const PALETTEENTRY *srcpalette, const RECT *srcrect)
 
HRESULT WINAPI D3DXSaveSurfaceToFileA (const char *destfile, D3DXIMAGE_FILEFORMAT destformat, struct IDirect3DSurface9 *srcsurface, const PALETTEENTRY *srcpalette, const RECT *srcrect)
 
HRESULT WINAPI D3DXSaveSurfaceToFileW (const WCHAR *destfile, D3DXIMAGE_FILEFORMAT destformat, struct IDirect3DSurface9 *srcsurface, const PALETTEENTRY *srcpalette, const RECT *srcrect)
 
HRESULT WINAPI D3DXLoadVolumeFromFileA (struct IDirect3DVolume9 *destvolume, const PALETTEENTRY *destpalette, const D3DBOX *destbox, const char *srcfile, const D3DBOX *srcbox, DWORD filter, D3DCOLOR colorkey, D3DXIMAGE_INFO *srcinfo)
 
HRESULT WINAPI D3DXLoadVolumeFromFileW (struct IDirect3DVolume9 *destvolume, const PALETTEENTRY *destpalette, const D3DBOX *destbox, const WCHAR *srcfile, const D3DBOX *srcbox, DWORD filter, D3DCOLOR colorkey, D3DXIMAGE_INFO *srcinfo)
 
HRESULT WINAPI D3DXLoadVolumeFromResourceA (struct IDirect3DVolume9 *destvolume, const PALETTEENTRY *destpalette, const D3DBOX *destbox, HMODULE srcmodule, const char *resource, const D3DBOX *srcbox, DWORD filter, D3DCOLOR colorkey, D3DXIMAGE_INFO *srcinfo)
 
HRESULT WINAPI D3DXLoadVolumeFromResourceW (struct IDirect3DVolume9 *destvolume, const PALETTEENTRY *destpalette, const D3DBOX *destbox, HMODULE srcmodule, const WCHAR *resource, const D3DBOX *srcbox, DWORD filter, D3DCOLOR colorkey, D3DXIMAGE_INFO *srcinfo)
 
HRESULT WINAPI D3DXLoadVolumeFromFileInMemory (struct IDirect3DVolume9 *destvolume, const PALETTEENTRY *destpalette, const D3DBOX *destbox, const void *srcdata, UINT srcdatasize, const D3DBOX *srcbox, DWORD filter, D3DCOLOR colorkey, D3DXIMAGE_INFO *srcinfo)
 
HRESULT WINAPI D3DXLoadVolumeFromVolume (struct IDirect3DVolume9 *destvolume, const PALETTEENTRY *destpalette, const D3DBOX *destbox, struct IDirect3DVolume9 *srcvolume, const PALETTEENTRY *srcpalette, const D3DBOX *srcbox, DWORD filter, D3DCOLOR colorkey)
 
HRESULT WINAPI D3DXLoadVolumeFromMemory (struct IDirect3DVolume9 *destvolume, const PALETTEENTRY *destpalette, const D3DBOX *destbox, const void *srcmemory, D3DFORMAT srcformat, UINT srcrowpitch, UINT srcslicepitch, const PALETTEENTRY *srcpalette, const D3DBOX *srcbox, DWORD filter, D3DCOLOR colorkey)
 
HRESULT WINAPI D3DXSaveVolumeToFileA (const char *destfile, D3DXIMAGE_FILEFORMAT destformat, struct IDirect3DVolume9 *srcvolume, const PALETTEENTRY *srcpalette, const D3DBOX *srcbox)
 
HRESULT WINAPI D3DXSaveVolumeToFileW (const WCHAR *destfile, D3DXIMAGE_FILEFORMAT destformat, struct IDirect3DVolume9 *srcvolume, const PALETTEENTRY *srcpalette, const D3DBOX *srcbox)
 
HRESULT WINAPI D3DXCheckTextureRequirements (struct IDirect3DDevice9 *device, UINT *width, UINT *height, UINT *miplevels, DWORD usage, D3DFORMAT *format, D3DPOOL pool)
 
HRESULT WINAPI D3DXCheckCubeTextureRequirements (struct IDirect3DDevice9 *device, UINT *size, UINT *miplevels, DWORD usage, D3DFORMAT *format, D3DPOOL pool)
 
HRESULT WINAPI D3DXCheckVolumeTextureRequirements (struct IDirect3DDevice9 *device, UINT *width, UINT *height, UINT *depth, UINT *miplevels, DWORD usage, D3DFORMAT *format, D3DPOOL pool)
 
HRESULT WINAPI D3DXCreateTexture (struct IDirect3DDevice9 *device, UINT width, UINT height, UINT miplevels, DWORD usage, D3DFORMAT format, D3DPOOL pool, struct IDirect3DTexture9 **texture)
 
HRESULT WINAPI D3DXCreateCubeTexture (struct IDirect3DDevice9 *device, UINT size, UINT miplevels, DWORD usage, D3DFORMAT format, D3DPOOL pool, struct IDirect3DCubeTexture9 **cube)
 
HRESULT WINAPI D3DXCreateVolumeTexture (struct IDirect3DDevice9 *device, UINT width, UINT height, UINT depth, UINT miplevels, DWORD usage, D3DFORMAT format, D3DPOOL pool, struct IDirect3DVolumeTexture9 **volume)
 
HRESULT WINAPI D3DXCreateTextureFromFileA (struct IDirect3DDevice9 *device, const char *srcfile, struct IDirect3DTexture9 **texture)
 
HRESULT WINAPI D3DXCreateTextureFromFileW (struct IDirect3DDevice9 *device, const WCHAR *srcfile, struct IDirect3DTexture9 **texture)
 
HRESULT WINAPI D3DXCreateCubeTextureFromFileA (struct IDirect3DDevice9 *device, const char *srcfile, struct IDirect3DCubeTexture9 **cube)
 
HRESULT WINAPI D3DXCreateCubeTextureFromFileW (struct IDirect3DDevice9 *device, const WCHAR *srcfile, struct IDirect3DCubeTexture9 **cube)
 
HRESULT WINAPI D3DXCreateVolumeTextureFromFileA (struct IDirect3DDevice9 *device, const char *srcfile, struct IDirect3DVolumeTexture9 **volume)
 
HRESULT WINAPI D3DXCreateVolumeTextureFromFileW (struct IDirect3DDevice9 *device, const WCHAR *srcfile, struct IDirect3DVolumeTexture9 **volume)
 
HRESULT WINAPI D3DXCreateTextureFromResourceA (struct IDirect3DDevice9 *device, HMODULE srcmodule, const char *resource, struct IDirect3DTexture9 **texture)
 
HRESULT WINAPI D3DXCreateTextureFromResourceW (struct IDirect3DDevice9 *device, HMODULE srcmodule, const WCHAR *resource, struct IDirect3DTexture9 **texture)
 
HRESULT WINAPI D3DXCreateCubeTextureFromResourceA (struct IDirect3DDevice9 *device, HMODULE srcmodule, const char *resource, struct IDirect3DCubeTexture9 **cube)
 
HRESULT WINAPI D3DXCreateCubeTextureFromResourceW (struct IDirect3DDevice9 *device, HMODULE srcmodule, const WCHAR *resource, struct IDirect3DCubeTexture9 **cube)
 
HRESULT WINAPI D3DXCreateVolumeTextureFromResourceA (struct IDirect3DDevice9 *device, HMODULE srcmodule, const char *resource, struct IDirect3DVolumeTexture9 **volume)
 
HRESULT WINAPI D3DXCreateVolumeTextureFromResourceW (struct IDirect3DDevice9 *device, HMODULE srcmodule, const WCHAR *resource, struct IDirect3DVolumeTexture9 **volume)
 
HRESULT WINAPI D3DXCreateTextureFromFileExA (struct IDirect3DDevice9 *device, const char *srcfile, UINT width, UINT height, UINT miplevels, DWORD usage, D3DFORMAT format, D3DPOOL pool, DWORD filter, DWORD mipfilter, D3DCOLOR colorkey, D3DXIMAGE_INFO *srcinfo, PALETTEENTRY *palette, struct IDirect3DTexture9 **texture)
 
HRESULT WINAPI D3DXCreateTextureFromFileExW (struct IDirect3DDevice9 *device, const WCHAR *srcfile, UINT width, UINT height, UINT miplevels, DWORD usage, D3DFORMAT format, D3DPOOL pool, DWORD filter, DWORD mipfilter, D3DCOLOR colorkey, D3DXIMAGE_INFO *srcinfo, PALETTEENTRY *palette, struct IDirect3DTexture9 **texture)
 
HRESULT WINAPI D3DXCreateCubeTextureFromFileExA (struct IDirect3DDevice9 *device, const char *srcfile, UINT size, UINT miplevels, DWORD usage, D3DFORMAT format, D3DPOOL pool, DWORD filter, DWORD mipfilter, D3DCOLOR colorkey, D3DXIMAGE_INFO *srcinfo, PALETTEENTRY *palette, struct IDirect3DCubeTexture9 **cube)
 
HRESULT WINAPI D3DXCreateCubeTextureFromFileExW (struct IDirect3DDevice9 *device, const WCHAR *srcfile, UINT size, UINT miplevels, DWORD usage, D3DFORMAT format, D3DPOOL pool, DWORD filter, DWORD mipfilter, D3DCOLOR colorkey, D3DXIMAGE_INFO *srcinfo, PALETTEENTRY *palette, struct IDirect3DCubeTexture9 **cube)
 
HRESULT WINAPI D3DXCreateVolumeTextureFromFileExA (struct IDirect3DDevice9 *device, const char *srcfile, UINT width, UINT height, UINT depth, UINT miplevels, DWORD usage, D3DFORMAT format, D3DPOOL pool, DWORD filter, DWORD mipfilter, D3DCOLOR colorkey, D3DXIMAGE_INFO *srcinfo, PALETTEENTRY *palette, struct IDirect3DVolumeTexture9 **volume)
 
HRESULT WINAPI D3DXCreateVolumeTextureFromFileExW (struct IDirect3DDevice9 *device, const WCHAR *srcfile, UINT width, UINT height, UINT depth, UINT miplevels, DWORD usage, D3DFORMAT format, D3DPOOL pool, DWORD filter, DWORD mipfilter, D3DCOLOR colorkey, D3DXIMAGE_INFO *srcinfo, PALETTEENTRY *palette, struct IDirect3DVolumeTexture9 **volume)
 
HRESULT WINAPI D3DXCreateTextureFromResourceExA (struct IDirect3DDevice9 *device, HMODULE srcmodule, const char *resource, UINT width, UINT height, UINT miplevels, DWORD usage, D3DFORMAT format, D3DPOOL pool, DWORD filter, DWORD mipfilter, D3DCOLOR colorkey, D3DXIMAGE_INFO *srcinfo, PALETTEENTRY *palette, struct IDirect3DTexture9 **texture)
 
HRESULT WINAPI D3DXCreateTextureFromResourceExW (struct IDirect3DDevice9 *device, HMODULE srcmodule, const WCHAR *resource, UINT width, UINT height, UINT miplevels, DWORD usage, D3DFORMAT format, D3DPOOL pool, DWORD filter, DWORD mipfilter, D3DCOLOR colorkey, D3DXIMAGE_INFO *srcinfo, PALETTEENTRY *palette, struct IDirect3DTexture9 **texture)
 
HRESULT WINAPI D3DXCreateCubeTextureFromResourceExA (struct IDirect3DDevice9 *device, HMODULE srcmodule, const char *resource, UINT size, UINT miplevels, DWORD usage, D3DFORMAT format, D3DPOOL pool, DWORD filter, DWORD mipfilter, D3DCOLOR colorkey, D3DXIMAGE_INFO *srcinfo, PALETTEENTRY *palette, struct IDirect3DCubeTexture9 **cube)
 
HRESULT WINAPI D3DXCreateCubeTextureFromResourceExW (struct IDirect3DDevice9 *device, HMODULE srcmodule, const WCHAR *resource, UINT size, UINT miplevels, DWORD usage, D3DFORMAT format, D3DPOOL pool, DWORD filter, DWORD mipfilter, D3DCOLOR colorkey, D3DXIMAGE_INFO *srcinfo, PALETTEENTRY *palette, struct IDirect3DCubeTexture9 **cube)
 
HRESULT WINAPI D3DXCreateVolumeTextureFromResourceExA (struct IDirect3DDevice9 *device, HMODULE srcmodule, const char *resource, UINT width, UINT height, UINT depth, UINT miplevels, DWORD usage, D3DFORMAT format, D3DPOOL pool, DWORD filter, DWORD mipfilter, D3DCOLOR colorkey, D3DXIMAGE_INFO *srcinfo, PALETTEENTRY *palette, struct IDirect3DVolumeTexture9 **volume)
 
HRESULT WINAPI D3DXCreateVolumeTextureFromResourceExW (struct IDirect3DDevice9 *device, HMODULE srcmodule, const WCHAR *resource, UINT width, UINT height, UINT depth, UINT miplevels, DWORD usage, D3DFORMAT format, D3DPOOL pool, DWORD filter, DWORD mipfilter, D3DCOLOR colorkey, D3DXIMAGE_INFO *srcinfo, PALETTEENTRY *palette, struct IDirect3DVolumeTexture9 **volume)
 
HRESULT WINAPI D3DXCreateTextureFromFileInMemory (struct IDirect3DDevice9 *device, const void *srcdata, UINT srcdatasize, struct IDirect3DTexture9 **texture)
 
HRESULT WINAPI D3DXCreateCubeTextureFromFileInMemory (struct IDirect3DDevice9 *device, const void *srcdata, UINT srcdatasize, struct IDirect3DCubeTexture9 **cube)
 
HRESULT WINAPI D3DXCreateVolumeTextureFromFileInMemory (struct IDirect3DDevice9 *device, const void *srcdata, UINT srcdatasize, struct IDirect3DVolumeTexture9 **volume)
 
HRESULT WINAPI D3DXCreateTextureFromFileInMemoryEx (struct IDirect3DDevice9 *device, const void *srcdata, UINT srcdatasize, UINT width, UINT height, UINT miplevels, DWORD usage, D3DFORMAT format, D3DPOOL pool, DWORD filter, DWORD mipfilter, D3DCOLOR colorkey, D3DXIMAGE_INFO *srcinfo, PALETTEENTRY *palette, struct IDirect3DTexture9 **texture)
 
HRESULT WINAPI D3DXCreateCubeTextureFromFileInMemoryEx (struct IDirect3DDevice9 *device, const void *srcdata, UINT srcdatasize, UINT size, UINT miplevels, DWORD usage, D3DFORMAT format, D3DPOOL pool, DWORD filter, DWORD mipfilter, D3DCOLOR colorkey, D3DXIMAGE_INFO *srcinfo, PALETTEENTRY *palette, struct IDirect3DCubeTexture9 **cube)
 
HRESULT WINAPI D3DXCreateVolumeTextureFromFileInMemoryEx (struct IDirect3DDevice9 *device, const void *srcdata, UINT srcdatasize, UINT width, UINT height, UINT depth, UINT miplevels, DWORD usage, D3DFORMAT format, D3DPOOL pool, DWORD filter, DWORD mipfilter, D3DCOLOR colorkey, D3DXIMAGE_INFO *srcinfo, PALETTEENTRY *palette, struct IDirect3DVolumeTexture9 **volume)
 
HRESULT WINAPI D3DXSaveTextureToFileInMemory (struct ID3DXBuffer **destbuffer, D3DXIMAGE_FILEFORMAT destformat, struct IDirect3DBaseTexture9 *srctexture, const PALETTEENTRY *srcpalette)
 
HRESULT WINAPI D3DXSaveTextureToFileA (const char *destfile, D3DXIMAGE_FILEFORMAT destformat, struct IDirect3DBaseTexture9 *srctexture, const PALETTEENTRY *srcpalette)
 
HRESULT WINAPI D3DXSaveTextureToFileW (const WCHAR *destfile, D3DXIMAGE_FILEFORMAT destformat, struct IDirect3DBaseTexture9 *srctexture, const PALETTEENTRY *srcpalette)
 
HRESULT WINAPI D3DXFilterTexture (struct IDirect3DBaseTexture9 *texture, const PALETTEENTRY *palette, UINT srclevel, DWORD filter)
 
HRESULT WINAPI D3DXFillTexture (struct IDirect3DTexture9 *texture, LPD3DXFILL2D function, void *data)
 
HRESULT WINAPI D3DXFillCubeTexture (struct IDirect3DCubeTexture9 *cube, LPD3DXFILL3D function, void *data)
 
HRESULT WINAPI D3DXFillVolumeTexture (struct IDirect3DVolumeTexture9 *volume, LPD3DXFILL3D function, void *data)
 
HRESULT WINAPI D3DXFillTextureTX (struct IDirect3DTexture9 *texture, ID3DXTextureShader *texture_shader)
 
HRESULT WINAPI D3DXFillCubeTextureTX (struct IDirect3DCubeTexture9 *cube, ID3DXTextureShader *texture_shader)
 
HRESULT WINAPI D3DXFillVolumeTextureTX (struct IDirect3DVolumeTexture9 *volume, ID3DXTextureShader *texture_shader)
 
HRESULT WINAPI D3DXComputeNormalMap (IDirect3DTexture9 *texture, IDirect3DTexture9 *srctexture, const PALETTEENTRY *srcpalette, DWORD flags, DWORD channel, float amplitude)
 

Macro Definition Documentation

◆ D3DX_CHANNEL_ALPHA

#define D3DX_CHANNEL_ALPHA   0x00000008

Definition at line 56 of file d3dx9tex.h.

◆ D3DX_CHANNEL_BLUE

#define D3DX_CHANNEL_BLUE   0x00000002

Definition at line 54 of file d3dx9tex.h.

◆ D3DX_CHANNEL_GREEN

#define D3DX_CHANNEL_GREEN   0x00000004

Definition at line 55 of file d3dx9tex.h.

◆ D3DX_CHANNEL_LUMINANCE

#define D3DX_CHANNEL_LUMINANCE   0x00000010

Definition at line 57 of file d3dx9tex.h.

◆ D3DX_CHANNEL_RED

#define D3DX_CHANNEL_RED   0x00000001

Definition at line 53 of file d3dx9tex.h.

◆ D3DX_FILTER_BOX

#define D3DX_FILTER_BOX   0x00000005

Definition at line 31 of file d3dx9tex.h.

◆ D3DX_FILTER_DITHER

#define D3DX_FILTER_DITHER   0x00080000

Definition at line 36 of file d3dx9tex.h.

◆ D3DX_FILTER_DITHER_DIFFUSION

#define D3DX_FILTER_DITHER_DIFFUSION   0x00100000

Definition at line 37 of file d3dx9tex.h.

◆ D3DX_FILTER_LINEAR

#define D3DX_FILTER_LINEAR   0x00000003

Definition at line 29 of file d3dx9tex.h.

◆ D3DX_FILTER_MIRROR

#define D3DX_FILTER_MIRROR   0x00070000

Definition at line 35 of file d3dx9tex.h.

◆ D3DX_FILTER_MIRROR_U

#define D3DX_FILTER_MIRROR_U   0x00010000

Definition at line 32 of file d3dx9tex.h.

◆ D3DX_FILTER_MIRROR_V

#define D3DX_FILTER_MIRROR_V   0x00020000

Definition at line 33 of file d3dx9tex.h.

◆ D3DX_FILTER_MIRROR_W

#define D3DX_FILTER_MIRROR_W   0x00040000

Definition at line 34 of file d3dx9tex.h.

◆ D3DX_FILTER_NONE

#define D3DX_FILTER_NONE   0x00000001

Definition at line 27 of file d3dx9tex.h.

◆ D3DX_FILTER_POINT

#define D3DX_FILTER_POINT   0x00000002

Definition at line 28 of file d3dx9tex.h.

◆ D3DX_FILTER_SRGB

#define D3DX_FILTER_SRGB   0x00600000

Definition at line 40 of file d3dx9tex.h.

◆ D3DX_FILTER_SRGB_IN

#define D3DX_FILTER_SRGB_IN   0x00200000

Definition at line 38 of file d3dx9tex.h.

◆ D3DX_FILTER_SRGB_OUT

#define D3DX_FILTER_SRGB_OUT   0x00400000

Definition at line 39 of file d3dx9tex.h.

◆ D3DX_FILTER_TRIANGLE

#define D3DX_FILTER_TRIANGLE   0x00000004

Definition at line 30 of file d3dx9tex.h.

◆ D3DX_NORMALMAP_COMPUTE_OCCLUSION

#define D3DX_NORMALMAP_COMPUTE_OCCLUSION   0x00100000

Definition at line 51 of file d3dx9tex.h.

◆ D3DX_NORMALMAP_INVERTSIGN

#define D3DX_NORMALMAP_INVERTSIGN   0x00080000

Definition at line 50 of file d3dx9tex.h.

◆ D3DX_NORMALMAP_MIRROR

#define D3DX_NORMALMAP_MIRROR   0x00030000

Definition at line 49 of file d3dx9tex.h.

◆ D3DX_NORMALMAP_MIRROR_U

#define D3DX_NORMALMAP_MIRROR_U   0x00010000

Definition at line 47 of file d3dx9tex.h.

◆ D3DX_NORMALMAP_MIRROR_V

#define D3DX_NORMALMAP_MIRROR_V   0x00020000

Definition at line 48 of file d3dx9tex.h.

◆ D3DX_SKIP_DDS_MIP_LEVELS

#define D3DX_SKIP_DDS_MIP_LEVELS (   l,
  f 
)
Value:
r l[0]
Definition: byte_order.h:168
#define D3DX_DEFAULT
Definition: d3dx9.h:24
#define D3DX_FILTER_BOX
Definition: d3dx9tex.h:31
#define D3DX_SKIP_DDS_MIP_LEVELS_MASK
Definition: d3dx9tex.h:42
#define D3DX_SKIP_DDS_MIP_LEVELS_SHIFT
Definition: d3dx9tex.h:43
GLfloat f
Definition: glext.h:7540
#define f
Definition: ke_i.h:83

Definition at line 44 of file d3dx9tex.h.

◆ D3DX_SKIP_DDS_MIP_LEVELS_MASK

#define D3DX_SKIP_DDS_MIP_LEVELS_MASK   0x1f

Definition at line 42 of file d3dx9tex.h.

◆ D3DX_SKIP_DDS_MIP_LEVELS_SHIFT

#define D3DX_SKIP_DDS_MIP_LEVELS_SHIFT   26

Definition at line 43 of file d3dx9tex.h.

◆ D3DXCreateCubeTextureFromFile

#define D3DXCreateCubeTextureFromFile   WINELIB_NAME_AW(D3DXCreateCubeTextureFromFile)

Definition at line 216 of file d3dx9tex.h.

◆ D3DXCreateCubeTextureFromFileEx

#define D3DXCreateCubeTextureFromFileEx   WINELIB_NAME_AW(D3DXCreateCubeTextureFromFileEx)

Definition at line 260 of file d3dx9tex.h.

◆ D3DXCreateCubeTextureFromResource

#define D3DXCreateCubeTextureFromResource   WINELIB_NAME_AW(D3DXCreateCubeTextureFromResource)

Definition at line 234 of file d3dx9tex.h.

◆ D3DXCreateCubeTextureFromResourceEx

#define D3DXCreateCubeTextureFromResourceEx   WINELIB_NAME_AW(D3DXCreateCubeTextureFromResourceEx)

Definition at line 290 of file d3dx9tex.h.

◆ D3DXCreateTextureFromFile

#define D3DXCreateTextureFromFile   WINELIB_NAME_AW(D3DXCreateTextureFromFile)

Definition at line 210 of file d3dx9tex.h.

◆ D3DXCreateTextureFromFileEx

#define D3DXCreateTextureFromFileEx   WINELIB_NAME_AW(D3DXCreateTextureFromFileEx)

Definition at line 250 of file d3dx9tex.h.

◆ D3DXCreateTextureFromResource

#define D3DXCreateTextureFromResource   WINELIB_NAME_AW(D3DXCreateTextureFromResource)

Definition at line 228 of file d3dx9tex.h.

◆ D3DXCreateTextureFromResourceEx

#define D3DXCreateTextureFromResourceEx   WINELIB_NAME_AW(D3DXCreateTextureFromResourceEx)

Definition at line 280 of file d3dx9tex.h.

◆ D3DXCreateVolumeTextureFromFile

#define D3DXCreateVolumeTextureFromFile   WINELIB_NAME_AW(D3DXCreateVolumeTextureFromFile)

Definition at line 222 of file d3dx9tex.h.

◆ D3DXCreateVolumeTextureFromFileEx

#define D3DXCreateVolumeTextureFromFileEx   WINELIB_NAME_AW(D3DXCreateVolumeTextureFromFileEx)

Definition at line 270 of file d3dx9tex.h.

◆ D3DXCreateVolumeTextureFromResource

#define D3DXCreateVolumeTextureFromResource   WINELIB_NAME_AW(D3DXCreateVolumeTextureFromResource)

Definition at line 240 of file d3dx9tex.h.

◆ D3DXCreateVolumeTextureFromResourceEx

#define D3DXCreateVolumeTextureFromResourceEx   WINELIB_NAME_AW(D3DXCreateVolumeTextureFromResourceEx)

Definition at line 300 of file d3dx9tex.h.

◆ D3DXFilterCubeTexture

#define D3DXFilterCubeTexture   D3DXFilterTexture

Definition at line 333 of file d3dx9tex.h.

◆ D3DXFilterVolumeTexture

#define D3DXFilterVolumeTexture   D3DXFilterTexture

Definition at line 334 of file d3dx9tex.h.

◆ D3DXGetImageInfoFromFile

#define D3DXGetImageInfoFromFile   WINELIB_NAME_AW(D3DXGetImageInfoFromFile)

Definition at line 104 of file d3dx9tex.h.

◆ D3DXGetImageInfoFromResource

#define D3DXGetImageInfoFromResource   WINELIB_NAME_AW(D3DXGetImageInfoFromResource)

Definition at line 108 of file d3dx9tex.h.

◆ D3DXLoadSurfaceFromFile

#define D3DXLoadSurfaceFromFile   WINELIB_NAME_AW(D3DXLoadSurfaceFromFile)

Definition at line 120 of file d3dx9tex.h.

◆ D3DXLoadSurfaceFromResource

#define D3DXLoadSurfaceFromResource   WINELIB_NAME_AW(D3DXLoadSurfaceFromResource)

Definition at line 128 of file d3dx9tex.h.

◆ D3DXLoadVolumeFromFile

#define D3DXLoadVolumeFromFile   WINELIB_NAME_AW(D3DXLoadVolumeFromFile)

Definition at line 161 of file d3dx9tex.h.

◆ D3DXLoadVolumeFromResource

#define D3DXLoadVolumeFromResource   WINELIB_NAME_AW(D3DXLoadVolumeFromResource)

Definition at line 169 of file d3dx9tex.h.

◆ D3DXSaveSurfaceToFile

#define D3DXSaveSurfaceToFile   WINELIB_NAME_AW(D3DXSaveSurfaceToFile)

Definition at line 151 of file d3dx9tex.h.

◆ D3DXSaveTextureToFile

#define D3DXSaveTextureToFile   WINELIB_NAME_AW(D3DXSaveTextureToFile)

Definition at line 328 of file d3dx9tex.h.

◆ D3DXSaveVolumeToFile

#define D3DXSaveVolumeToFile   WINELIB_NAME_AW(D3DXSaveVolumeToFile)

Definition at line 188 of file d3dx9tex.h.

Typedef Documentation

◆ D3DXIMAGE_FILEFORMAT

◆ D3DXIMAGE_INFO

◆ LPD3DXFILL2D

typedef void(WINAPI * LPD3DXFILL2D) (D3DXVECTOR4 *out, const D3DXVECTOR2 *texcoord, const D3DXVECTOR2 *texelsize, void *data)

Definition at line 91 of file d3dx9tex.h.

◆ LPD3DXFILL3D

typedef void(WINAPI * LPD3DXFILL3D) (D3DXVECTOR4 *out, const D3DXVECTOR3 *texcoord, const D3DXVECTOR3 *texelsize, void *data)

Definition at line 93 of file d3dx9tex.h.

Enumeration Type Documentation

◆ _D3DXIMAGE_FILEFORMAT

Enumerator
D3DXIFF_BMP 
D3DXIFF_JPG 
D3DXIFF_TGA 
D3DXIFF_PNG 
D3DXIFF_DDS 
D3DXIFF_PPM 
D3DXIFF_DIB 
D3DXIFF_HDR 
D3DXIFF_PFM 
D3DXIFF_FORCE_DWORD 

Definition at line 62 of file d3dx9tex.h.

63{
73 D3DXIFF_FORCE_DWORD = 0x7fffffff
enum _D3DXIMAGE_FILEFORMAT D3DXIMAGE_FILEFORMAT
@ D3DXIFF_JPG
Definition: d3dx9tex.h:65
@ D3DXIFF_DDS
Definition: d3dx9tex.h:68
@ D3DXIFF_BMP
Definition: d3dx9tex.h:64
@ D3DXIFF_HDR
Definition: d3dx9tex.h:71
@ D3DXIFF_TGA
Definition: d3dx9tex.h:66
@ D3DXIFF_DIB
Definition: d3dx9tex.h:70
@ D3DXIFF_PFM
Definition: d3dx9tex.h:72
@ D3DXIFF_FORCE_DWORD
Definition: d3dx9tex.h:73
@ D3DXIFF_PPM
Definition: d3dx9tex.h:69
@ D3DXIFF_PNG
Definition: d3dx9tex.h:67

Function Documentation

◆ D3DXCheckCubeTextureRequirements()

HRESULT WINAPI D3DXCheckCubeTextureRequirements ( struct IDirect3DDevice9 *  device,
UINT size,
UINT miplevels,
DWORD  usage,
D3DFORMAT format,
D3DPOOL  pool 
)

Definition at line 421 of file texture.c.

423{
424 D3DCAPS9 caps;
425 UINT s = (size && *size) ? *size : 256;
426 HRESULT hr;
427
428 TRACE("(%p, %p, %p, %u, %p, %u)\n", device, size, miplevels, usage, format, pool);
429
430 if (s == D3DX_DEFAULT)
431 s = 256;
432
434 return D3DERR_INVALIDCALL;
435
437 return D3DERR_NOTAVAILABLE;
438
440 s = make_pow2(s);
441
443
445 {
446 if(miplevels)
447 *miplevels = 1;
448 }
449
450 if (size)
451 *size = s;
452
453 return hr;
454}
#define D3DPTEXTURECAPS_CUBEMAP_POW2
Definition: d3d8caps.h:126
#define D3DPTEXTURECAPS_CUBEMAP
Definition: d3d8caps.h:121
#define D3DPTEXTURECAPS_MIPCUBEMAP
Definition: d3d8caps.h:125
@ D3DRTYPE_CUBETEXTURE
Definition: d3d8types.h:814
#define IDirect3DDevice9_GetDeviceCaps(p, a)
Definition: d3d9.h:1514
#define D3DERR_INVALIDCALL
static uint32_t make_pow2(uint32_t num)
static HRESULT check_texture_requirements(struct IDirect3DDevice9 *device, UINT *width, UINT *height, UINT *miplevels, DWORD usage, D3DFORMAT *format, D3DPOOL pool, D3DRESOURCETYPE resource_type)
Definition: texture.c:202
static BOOL is_pow2(UINT num)
Definition: texture.c:32
GLdouble s
Definition: gl.h:2039
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
GLsizeiptr size
Definition: glext.h:5919
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
#define FAILED(hr)
Definition: intsafe.h:51
unsigned int UINT
Definition: ndis.h:50
#define D3DERR_NOTAVAILABLE
Definition: d3d8.h:84
HRESULT hr
Definition: shlfolder.c:183
#define TRACE(s)
Definition: solgame.cpp:4
DWORD TextureCaps
Definition: d3d9caps.h:279
Definition: devices.h:37

Referenced by D3DXCreateCubeTexture(), D3DXCreateCubeTextureFromFileInMemoryEx(), and test_D3DXCheckCubeTextureRequirements().

◆ D3DXCheckTextureRequirements()

HRESULT WINAPI D3DXCheckTextureRequirements ( struct IDirect3DDevice9 *  device,
UINT width,
UINT height,
UINT miplevels,
DWORD  usage,
D3DFORMAT format,
D3DPOOL  pool 
)

Definition at line 412 of file texture.c.

414{
415 TRACE("device %p, width %p, height %p, miplevels %p, usage %u, format %p, pool %u.\n",
416 device, width, height, miplevels, usage, format, pool);
417
419}
@ D3DRTYPE_TEXTURE
Definition: d3d8types.h:812
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLint GLint GLsizei width
Definition: gl.h:1546

Referenced by D3DXCreateRenderToEnvMap(), D3DXCreateTexture(), D3DXCreateTextureFromFileInMemoryEx(), and test_D3DXCheckTextureRequirements().

◆ D3DXCheckVolumeTextureRequirements()

HRESULT WINAPI D3DXCheckVolumeTextureRequirements ( struct IDirect3DDevice9 *  device,
UINT width,
UINT height,
UINT depth,
UINT miplevels,
DWORD  usage,
D3DFORMAT format,
D3DPOOL  pool 
)

Definition at line 456 of file texture.c.

458{
459 D3DCAPS9 caps;
462 UINT d = (depth && *depth) ? *depth : 1;
463 HRESULT hr;
464
465 TRACE("(%p, %p, %p, %p, %p, %u, %p, %u)\n", device, width, height, depth, miplevels,
466 usage, format, pool);
467
469 return D3DERR_INVALIDCALL;
470
472 return D3DERR_NOTAVAILABLE;
473
475 if (d == D3DX_DEFAULT)
476 d = 1;
477
479 (!is_pow2(w) || !is_pow2(h) || !is_pow2(d)))
480 {
481 w = make_pow2(w);
482 h = make_pow2(h);
483 d = make_pow2(d);
484 }
485
486 if (w > caps.MaxVolumeExtent)
487 w = caps.MaxVolumeExtent;
488 if (h > caps.MaxVolumeExtent)
489 h = caps.MaxVolumeExtent;
490 if (d > caps.MaxVolumeExtent)
491 d = caps.MaxVolumeExtent;
492
493 if (miplevels)
494 {
496 *miplevels = 1;
497 else if ((usage & D3DUSAGE_AUTOGENMIPMAP))
498 {
499 if (*miplevels > 1)
500 *miplevels = 0;
501 }
502 else
503 {
504 UINT max_mipmaps = 1;
505 UINT max_dimen = max(max(w, h), d);
506
507 while (max_dimen > 1)
508 {
509 max_dimen >>= 1;
510 max_mipmaps++;
511 }
512
513 if (*miplevels == 0 || *miplevels > max_mipmaps)
514 *miplevels = max_mipmaps;
515 }
516 }
517
518 if (width)
519 *width = w;
520 if (height)
521 *height = h;
522 if (depth)
523 *depth = d;
524
525 return hr;
526}
#define D3DPTEXTURECAPS_VOLUMEMAP
Definition: d3d8caps.h:122
#define D3DPTEXTURECAPS_VOLUMEMAP_POW2
Definition: d3d8caps.h:127
#define D3DPTEXTURECAPS_MIPVOLUMEMAP
Definition: d3d8caps.h:124
@ D3DRTYPE_VOLUMETEXTURE
Definition: d3d8types.h:813
#define D3DUSAGE_AUTOGENMIPMAP
Definition: d3d9types.h:113
#define NULL
Definition: types.h:112
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
#define d
Definition: ke_i.h:81
DWORD MaxVolumeExtent
Definition: d3d9caps.h:288
#define max(a, b)
Definition: svc.c:63

Referenced by D3DXCreateVolumeTexture(), D3DXCreateVolumeTextureFromFileInMemoryEx(), and test_D3DXCheckVolumeTextureRequirements().

◆ D3DXComputeNormalMap()

HRESULT WINAPI D3DXComputeNormalMap ( IDirect3DTexture9 *  texture,
IDirect3DTexture9 *  srctexture,
const PALETTEENTRY srcpalette,
DWORD  flags,
DWORD  channel,
float  amplitude 
)

Definition at line 1927 of file texture.c.

1929{
1930 FIXME("texture %p, src_texture %p, src_palette %p, flags %#x, channel %u, amplitude %.8e stub.\n",
1931 texture, src_texture, src_palette, flags, channel, amplitude);
1932
1933 return D3D_OK;
1934}
#define FIXME(fmt,...)
Definition: debug.h:114
#define D3D_OK
Definition: d3d.h:106
GLenum GLuint texture
Definition: glext.h:6295
GLbitfield flags
Definition: glext.h:7161

◆ D3DXCreateCubeTexture()

HRESULT WINAPI D3DXCreateCubeTexture ( struct IDirect3DDevice9 *  device,
UINT  size,
UINT  miplevels,
DWORD  usage,
D3DFORMAT  format,
D3DPOOL  pool,
struct IDirect3DCubeTexture9 **  cube 
)

Definition at line 913 of file texture.c.

915{
916 HRESULT hr;
917
918 TRACE("(%p, %u, %u, %#x, %#x, %#x, %p)\n", device, size, miplevels, usage, format,
919 pool, texture);
920
921 if (!device || !texture)
922 return D3DERR_INVALIDCALL;
923
925
926 if (FAILED(hr))
927 {
928 TRACE("D3DXCheckCubeTextureRequirements failed\n");
929 return hr;
930 }
931
933}
#define IDirect3DDevice9_CreateCubeTexture(p, a, b, c, d, e, f, g)
Definition: d3d9.h:1532
HRESULT WINAPI D3DXCheckCubeTextureRequirements(struct IDirect3DDevice9 *device, UINT *size, UINT *miplevels, DWORD usage, D3DFORMAT *format, D3DPOOL pool)
Definition: texture.c:421

Referenced by D3DXCreateCubeTextureFromFileInMemoryEx().

◆ D3DXCreateCubeTextureFromFileA()

HRESULT WINAPI D3DXCreateCubeTextureFromFileA ( struct IDirect3DDevice9 *  device,
const char srcfile,
struct IDirect3DCubeTexture9 **  cube 
)

Definition at line 1531 of file texture.c.

1534{
1535 int len;
1536 HRESULT hr;
1537 WCHAR *filename;
1538 void *data;
1539 DWORD data_size;
1540
1541 TRACE("(%p, %s, %p): relay\n", device, wine_dbgstr_a(src_filename), cube_texture);
1542
1543 if (!src_filename) return D3DERR_INVALIDCALL;
1544
1545 len = MultiByteToWideChar(CP_ACP, 0, src_filename, -1, NULL, 0);
1546 filename = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
1547 if (!filename) return E_OUTOFMEMORY;
1548 MultiByteToWideChar(CP_ACP, 0, src_filename, -1, filename, len);
1549
1550 hr = map_view_of_file(filename, &data, &data_size);
1551 if (FAILED(hr))
1552 {
1554 return D3DXERR_INVALIDDATA;
1555 }
1556
1559
1562 return hr;
1563}
#define D3DXERR_INVALIDDATA
Definition: compiler.c:30
@ D3DFMT_UNKNOWN
Definition: d3d8types.h:601
@ D3DPOOL_MANAGED
Definition: d3d8types.h:710
HRESULT map_view_of_file(const WCHAR *filename, void **buffer, DWORD *length) DECLSPEC_HIDDEN
Definition: util.c:120
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
HRESULT WINAPI D3DXCreateCubeTextureFromFileInMemoryEx(IDirect3DDevice9 *device, const void *src_data, UINT src_data_size, UINT size, UINT mip_levels, DWORD usage, D3DFORMAT format, D3DPOOL pool, DWORD filter, DWORD mip_filter, D3DCOLOR color_key, D3DXIMAGE_INFO *src_info, PALETTEENTRY *palette, IDirect3DCubeTexture9 **cube_texture)
Definition: texture.c:1400
#define GetProcessHeap()
Definition: compat.h:736
#define UnmapViewOfFile
Definition: compat.h:746
#define CP_ACP
Definition: compat.h:109
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define MultiByteToWideChar
Definition: compat.h:110
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLenum GLsizei len
Definition: glext.h:6722
const char * filename
Definition: ioapi.h:137
const char int int int static __inline const char * wine_dbgstr_a(const char *s)
Definition: debug.h:187
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ D3DXCreateCubeTextureFromFileExA()

HRESULT WINAPI D3DXCreateCubeTextureFromFileExA ( struct IDirect3DDevice9 *  device,
const char srcfile,
UINT  size,
UINT  miplevels,
DWORD  usage,
D3DFORMAT  format,
D3DPOOL  pool,
DWORD  filter,
DWORD  mipfilter,
D3DCOLOR  colorkey,
D3DXIMAGE_INFO srcinfo,
PALETTEENTRY palette,
struct IDirect3DCubeTexture9 **  cube 
)

Definition at line 1585 of file texture.c.

1598{
1599 int len;
1600 HRESULT hr;
1601 WCHAR *filename;
1602 void *data;
1603 DWORD data_size;
1604
1605 TRACE("(%p, %s, %u, %u, %#x, %#x, %#x, %#x, %#x, %#x, %p, %p, %p): relay\n",
1606 device, wine_dbgstr_a(src_filename), size, mip_levels, usage, format,
1607 pool, filter, mip_filter, color_key, image_info, palette, cube_texture);
1608
1609 if (!src_filename) return D3DERR_INVALIDCALL;
1610
1611 len = MultiByteToWideChar(CP_ACP, 0, src_filename, -1, NULL, 0);
1612 filename = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
1613 if (!filename) return E_OUTOFMEMORY;
1614 MultiByteToWideChar(CP_ACP, 0, src_filename, -1, filename, len);
1615
1616 hr = map_view_of_file(filename, &data, &data_size);
1617 if (FAILED(hr))
1618 {
1620 return D3DXERR_INVALIDDATA;
1621 }
1622
1623 hr = D3DXCreateCubeTextureFromFileInMemoryEx(device, data, data_size, size, mip_levels,
1624 usage, format, pool, filter, mip_filter, color_key, image_info, palette, cube_texture);
1625
1628 return hr;
1629}
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7005
static HPALETTE palette
Definition: clipboard.c:1345

◆ D3DXCreateCubeTextureFromFileExW()

HRESULT WINAPI D3DXCreateCubeTextureFromFileExW ( struct IDirect3DDevice9 *  device,
const WCHAR srcfile,
UINT  size,
UINT  miplevels,
DWORD  usage,
D3DFORMAT  format,
D3DPOOL  pool,
DWORD  filter,
DWORD  mipfilter,
D3DCOLOR  colorkey,
D3DXIMAGE_INFO srcinfo,
PALETTEENTRY palette,
struct IDirect3DCubeTexture9 **  cube 
)

Definition at line 1631 of file texture.c.

1644{
1645 HRESULT hr;
1646 void *data;
1647 DWORD data_size;
1648
1649 TRACE("(%p, %s, %u, %u, %#x, %#x, %#x, %#x, %#x, %#x, %p, %p, %p): relay\n",
1650 device, wine_dbgstr_w(src_filename), size, mip_levels, usage, format,
1651 pool, filter, mip_filter, color_key, image_info, palette, cube_texture);
1652
1653 hr = map_view_of_file(src_filename, &data, &data_size);
1654 if (FAILED(hr)) return D3DXERR_INVALIDDATA;
1655
1656 hr = D3DXCreateCubeTextureFromFileInMemoryEx(device, data, data_size, size, mip_levels,
1657 usage, format, pool, filter, mip_filter, color_key, image_info, palette, cube_texture);
1658
1660 return hr;
1661}
#define wine_dbgstr_w
Definition: kernel32.h:34

◆ D3DXCreateCubeTextureFromFileInMemory()

HRESULT WINAPI D3DXCreateCubeTextureFromFileInMemory ( struct IDirect3DDevice9 *  device,
const void srcdata,
UINT  srcdatasize,
struct IDirect3DCubeTexture9 **  cube 
)

Definition at line 935 of file texture.c.

937{
938 TRACE("(%p, %p, %u, %p)\n", device, data, datasize, texture);
939
942}
static SIZE_T datasize
Definition: asm.c:30

Referenced by test_D3DXCreateCubeTextureFromFileInMemory().

◆ D3DXCreateCubeTextureFromFileInMemoryEx()

HRESULT WINAPI D3DXCreateCubeTextureFromFileInMemoryEx ( struct IDirect3DDevice9 *  device,
const void srcdata,
UINT  srcdatasize,
UINT  size,
UINT  miplevels,
DWORD  usage,
D3DFORMAT  format,
D3DPOOL  pool,
DWORD  filter,
DWORD  mipfilter,
D3DCOLOR  colorkey,
D3DXIMAGE_INFO srcinfo,
PALETTEENTRY palette,
struct IDirect3DCubeTexture9 **  cube 
)

Definition at line 1400 of file texture.c.

1414{
1415 HRESULT hr;
1416 D3DCAPS9 caps;
1417 UINT loaded_miplevels;
1418 D3DXIMAGE_INFO img_info;
1419 BOOL dynamic_texture;
1421 BOOL file_format = FALSE;
1422 BOOL file_mip_levels = FALSE;
1423 IDirect3DCubeTexture9 *tex, *buftex;
1424
1425 TRACE("(%p, %p, %u, %u, %u, %#x, %#x, %#x, %#x, %#x, %#x, %p, %p, %p)\n", device,
1426 src_data, src_data_size, size, mip_levels, usage, format, pool, filter, mip_filter,
1427 color_key, src_info, palette, cube_texture);
1428
1429 if (!device || !cube_texture || !src_data || !src_data_size)
1430 return D3DERR_INVALIDCALL;
1431
1432 hr = D3DXGetImageInfoFromFileInMemory(src_data, src_data_size, &img_info);
1433 if (FAILED(hr))
1434 return hr;
1435
1436 if (img_info.ImageFileFormat != D3DXIFF_DDS)
1437 return D3DXERR_INVALIDDATA;
1438
1439 if (img_info.Width != img_info.Height)
1440 return D3DXERR_INVALIDDATA;
1441
1442 if (size == 0 || size == D3DX_DEFAULT_NONPOW2)
1443 size = img_info.Width;
1444 if (size == D3DX_DEFAULT)
1445 size = make_pow2(img_info.Width);
1446
1448 format = img_info.Format;
1449
1450 if (size == D3DX_FROM_FILE)
1451 {
1452 file_size = TRUE;
1453 size = img_info.Width;
1454 }
1455
1456 if (format == D3DFMT_FROM_FILE)
1457 {
1458 file_format = TRUE;
1459 format = img_info.Format;
1460 }
1461
1462 if (mip_levels == D3DX_FROM_FILE)
1463 {
1464 file_mip_levels = TRUE;
1465 mip_levels = img_info.MipLevels;
1466 }
1467
1469 if (FAILED(hr))
1470 return hr;
1471
1472 if ((file_size && size != img_info.Width)
1473 || (file_format && format != img_info.Format)
1474 || (file_mip_levels && mip_levels != img_info.MipLevels))
1475 return D3DERR_NOTAVAILABLE;
1476
1478 if (FAILED(hr))
1479 return D3DERR_INVALIDCALL;
1480
1481 dynamic_texture = (caps.Caps2 & D3DCAPS2_DYNAMICTEXTURES) && (usage & D3DUSAGE_DYNAMIC);
1482 if (pool == D3DPOOL_DEFAULT && !dynamic_texture)
1483 {
1484 hr = D3DXCreateCubeTexture(device, size, mip_levels, 0, format, D3DPOOL_SYSTEMMEM, &buftex);
1485 tex = buftex;
1486 }
1487 else
1488 {
1489 hr = D3DXCreateCubeTexture(device, size, mip_levels, usage, format, pool, &tex);
1490 buftex = NULL;
1491 }
1492 if (FAILED(hr))
1493 return hr;
1494
1495 hr = load_cube_texture_from_dds(tex, src_data, palette, filter, color_key, &img_info);
1496 if (FAILED(hr))
1497 {
1499 return hr;
1500 }
1501
1502 loaded_miplevels = min(IDirect3DCubeTexture9_GetLevelCount(tex), img_info.MipLevels);
1503 hr = D3DXFilterTexture((IDirect3DBaseTexture9*) tex, palette, loaded_miplevels - 1, mip_filter);
1504 if (FAILED(hr))
1505 {
1507 return hr;
1508 }
1509
1510 if (buftex)
1511 {
1512 hr = D3DXCreateCubeTexture(device, size, mip_levels, usage, format, pool, &tex);
1513 if (FAILED(hr))
1514 {
1516 return hr;
1517 }
1518
1519 IDirect3DDevice9_UpdateTexture(device, (IDirect3DBaseTexture9 *)buftex, (IDirect3DBaseTexture9 *)tex);
1521 }
1522
1523 if (src_info)
1524 *src_info = img_info;
1525
1526 *cube_texture = tex;
1527 return D3D_OK;
1528}
#define D3DCAPS2_DYNAMICTEXTURES
Definition: d3d8caps.h:25
#define D3DUSAGE_DYNAMIC
Definition: d3d8types.h:99
@ D3DPOOL_DEFAULT
Definition: d3d8types.h:709
@ D3DPOOL_SYSTEMMEM
Definition: d3d8types.h:711
#define IDirect3DCubeTexture9_Release(p)
Definition: d3d9.h:919
#define IDirect3DCubeTexture9_GetLevelCount(p)
Definition: d3d9.h:932
#define IDirect3DDevice9_UpdateTexture(p, a, b)
Definition: d3d9.h:1538
#define D3DX_DEFAULT_NONPOW2
Definition: d3dx9.h:25
#define D3DX_FROM_FILE
Definition: d3dx9.h:27
#define D3DFMT_FROM_FILE
Definition: d3dx9.h:28
HRESULT load_cube_texture_from_dds(IDirect3DCubeTexture9 *cube_texture, const void *src_data, const PALETTEENTRY *palette, DWORD filter, D3DCOLOR color_key, const D3DXIMAGE_INFO *src_info) DECLSPEC_HIDDEN
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
HRESULT WINAPI D3DXGetImageInfoFromFileInMemory(const void *data, UINT datasize, D3DXIMAGE_INFO *info)
Definition: surface.c:985
HRESULT WINAPI D3DXCreateCubeTexture(struct IDirect3DDevice9 *device, UINT size, UINT miplevels, DWORD usage, D3DFORMAT format, D3DPOOL pool, struct IDirect3DCubeTexture9 **texture)
Definition: texture.c:913
HRESULT WINAPI D3DXFilterTexture(IDirect3DBaseTexture9 *texture, const PALETTEENTRY *palette, UINT srclevel, DWORD filter)
Definition: texture.c:52
unsigned int BOOL
Definition: ntddk_ex.h:94
#define min(a, b)
Definition: monoChain.cc:55
static unsigned int file_size
Definition: regtests2xml.c:47
DWORD Caps2
Definition: d3d9caps.h:267
UINT MipLevels
Definition: d3dx9tex.h:81
D3DXIMAGE_FILEFORMAT ImageFileFormat
Definition: d3dx9tex.h:84
D3DFORMAT Format
Definition: d3dx9tex.h:82

Referenced by D3DXCreateCubeTextureFromFileA(), D3DXCreateCubeTextureFromFileExA(), D3DXCreateCubeTextureFromFileExW(), D3DXCreateCubeTextureFromFileInMemory(), D3DXCreateCubeTextureFromFileW(), and test_D3DXCreateCubeTextureFromFileInMemoryEx().

◆ D3DXCreateCubeTextureFromFileW()

HRESULT WINAPI D3DXCreateCubeTextureFromFileW ( struct IDirect3DDevice9 *  device,
const WCHAR srcfile,
struct IDirect3DCubeTexture9 **  cube 
)

Definition at line 1565 of file texture.c.

1568{
1569 HRESULT hr;
1570 void *data;
1571 DWORD data_size;
1572
1573 TRACE("(%p, %s, %p): relay\n", device, wine_dbgstr_w(src_filename), cube_texture);
1574
1575 hr = map_view_of_file(src_filename, &data, &data_size);
1576 if (FAILED(hr)) return D3DXERR_INVALIDDATA;
1577
1580
1582 return hr;
1583}

◆ D3DXCreateCubeTextureFromResourceA()

HRESULT WINAPI D3DXCreateCubeTextureFromResourceA ( struct IDirect3DDevice9 *  device,
HMODULE  srcmodule,
const char resource,
struct IDirect3DCubeTexture9 **  cube 
)

◆ D3DXCreateCubeTextureFromResourceExA()

HRESULT WINAPI D3DXCreateCubeTextureFromResourceExA ( struct IDirect3DDevice9 *  device,
HMODULE  srcmodule,
const char resource,
UINT  size,
UINT  miplevels,
DWORD  usage,
D3DFORMAT  format,
D3DPOOL  pool,
DWORD  filter,
DWORD  mipfilter,
D3DCOLOR  colorkey,
D3DXIMAGE_INFO srcinfo,
PALETTEENTRY palette,
struct IDirect3DCubeTexture9 **  cube 
)

◆ D3DXCreateCubeTextureFromResourceExW()

HRESULT WINAPI D3DXCreateCubeTextureFromResourceExW ( struct IDirect3DDevice9 *  device,
HMODULE  srcmodule,
const WCHAR resource,
UINT  size,
UINT  miplevels,
DWORD  usage,
D3DFORMAT  format,
D3DPOOL  pool,
DWORD  filter,
DWORD  mipfilter,
D3DCOLOR  colorkey,
D3DXIMAGE_INFO srcinfo,
PALETTEENTRY palette,
struct IDirect3DCubeTexture9 **  cube 
)

◆ D3DXCreateCubeTextureFromResourceW()

HRESULT WINAPI D3DXCreateCubeTextureFromResourceW ( struct IDirect3DDevice9 *  device,
HMODULE  srcmodule,
const WCHAR resource,
struct IDirect3DCubeTexture9 **  cube 
)

◆ D3DXCreateTexture()

HRESULT WINAPI D3DXCreateTexture ( struct IDirect3DDevice9 *  device,
UINT  width,
UINT  height,
UINT  miplevels,
DWORD  usage,
D3DFORMAT  format,
D3DPOOL  pool,
struct IDirect3DTexture9 **  texture 
)

Definition at line 528 of file texture.c.

530{
531 HRESULT hr;
532
533 TRACE("device %p, width %u, height %u, miplevels %u, usage %#x, format %#x, pool %#x, texture %p.\n",
534 device, width, height, miplevels, usage, format, pool, texture);
535
536 if (!device || !texture)
537 return D3DERR_INVALIDCALL;
538
540 return hr;
541
543}
#define IDirect3DDevice9_CreateTexture(p, a, b, c, d, e, f, g, h)
Definition: d3d9.h:1530
HRESULT WINAPI D3DXCheckTextureRequirements(struct IDirect3DDevice9 *device, UINT *width, UINT *height, UINT *miplevels, DWORD usage, D3DFORMAT *format, D3DPOOL pool)
Definition: texture.c:412

Referenced by D3DXCreateTextureFromFileInMemoryEx(), test_D3DXCreateTexture(), test_effect_parameter_block(), and test_effect_setvalue_object().

◆ D3DXCreateTextureFromFileA()

HRESULT WINAPI D3DXCreateTextureFromFileA ( struct IDirect3DDevice9 *  device,
const char srcfile,
struct IDirect3DTexture9 **  texture 
)

Definition at line 818 of file texture.c.

820{
821 TRACE("(%p, %s, %p)\n", device, debugstr_a(srcfile), texture);
822
825}
HRESULT WINAPI D3DXCreateTextureFromFileExA(struct IDirect3DDevice9 *device, const char *srcfile, UINT width, UINT height, UINT miplevels, DWORD usage, D3DFORMAT format, D3DPOOL pool, DWORD filter, DWORD mipfilter, D3DCOLOR colorkey, D3DXIMAGE_INFO *srcinfo, PALETTEENTRY *palette, struct IDirect3DTexture9 **texture)
Definition: texture.c:789
#define debugstr_a
Definition: kernel32.h:31

◆ D3DXCreateTextureFromFileExA()

HRESULT WINAPI D3DXCreateTextureFromFileExA ( struct IDirect3DDevice9 *  device,
const char srcfile,
UINT  width,
UINT  height,
UINT  miplevels,
DWORD  usage,
D3DFORMAT  format,
D3DPOOL  pool,
DWORD  filter,
DWORD  mipfilter,
D3DCOLOR  colorkey,
D3DXIMAGE_INFO srcinfo,
PALETTEENTRY palette,
struct IDirect3DTexture9 **  texture 
)

Definition at line 789 of file texture.c.

793{
794 WCHAR *widename;
795 HRESULT hr;
796 DWORD len;
797
798 TRACE("device %p, srcfile %s, width %u, height %u, miplevels %u, usage %#x, format %#x, "
799 "pool %#x, filter %#x, mipfilter %#x, colorkey 0x%08x, srcinfo %p, palette %p, texture %p.\n",
800 device, debugstr_a(srcfile), width, height, miplevels, usage, format,
801 pool, filter, mipfilter, colorkey, srcinfo, palette, texture);
802
803 if (!device || !srcfile || !texture)
804 return D3DERR_INVALIDCALL;
805
806 len = MultiByteToWideChar(CP_ACP, 0, srcfile, -1, NULL, 0);
807 widename = HeapAlloc(GetProcessHeap(), 0, len * sizeof(*widename));
808 MultiByteToWideChar(CP_ACP, 0, srcfile, -1, widename, len);
809
810 hr = D3DXCreateTextureFromFileExW(device, widename, width, height, miplevels,
811 usage, format, pool, filter, mipfilter,
812 colorkey, srcinfo, palette, texture);
813
814 HeapFree(GetProcessHeap(), 0, widename);
815 return hr;
816}
HRESULT WINAPI D3DXCreateTextureFromFileExW(struct IDirect3DDevice9 *device, const WCHAR *srcfile, UINT width, UINT height, UINT miplevels, DWORD usage, D3DFORMAT format, D3DPOOL pool, DWORD filter, DWORD mipfilter, D3DCOLOR colorkey, D3DXIMAGE_INFO *srcinfo, PALETTEENTRY *palette, struct IDirect3DTexture9 **texture)
Definition: texture.c:757

Referenced by D3DXCreateTextureFromFileA().

◆ D3DXCreateTextureFromFileExW()

HRESULT WINAPI D3DXCreateTextureFromFileExW ( struct IDirect3DDevice9 *  device,
const WCHAR srcfile,
UINT  width,
UINT  height,
UINT  miplevels,
DWORD  usage,
D3DFORMAT  format,
D3DPOOL  pool,
DWORD  filter,
DWORD  mipfilter,
D3DCOLOR  colorkey,
D3DXIMAGE_INFO srcinfo,
PALETTEENTRY palette,
struct IDirect3DTexture9 **  texture 
)

Definition at line 757 of file texture.c.

761{
762 void *buffer;
763 HRESULT hr;
764 DWORD size;
765
766 TRACE("device %p, srcfile %s, width %u, height %u, miplevels %u, usage %#x, format %#x, "
767 "pool %#x, filter %#x, mipfilter %#x, colorkey 0x%08x, srcinfo %p, palette %p, texture %p.\n",
768 device, debugstr_w(srcfile), width, height, miplevels, usage, format,
769 pool, filter, mipfilter, colorkey, srcinfo, palette, texture);
770
771 if (!srcfile)
772 return D3DERR_INVALIDCALL;
773
774 hr = map_view_of_file(srcfile, &buffer, &size);
775 if (FAILED(hr))
776 {
777 WARN("Failed to open file.\n");
778 return D3DXERR_INVALIDDATA;
779 }
780
782 filter, mipfilter, colorkey, srcinfo, palette, texture);
783
785
786 return hr;
787}
#define WARN(fmt,...)
Definition: debug.h:115
HRESULT WINAPI D3DXCreateTextureFromFileInMemoryEx(struct IDirect3DDevice9 *device, const void *srcdata, UINT srcdatasize, UINT width, UINT height, UINT miplevels, DWORD usage, D3DFORMAT format, D3DPOOL pool, DWORD filter, DWORD mipfilter, D3DCOLOR colorkey, D3DXIMAGE_INFO *srcinfo, PALETTEENTRY *palette, struct IDirect3DTexture9 **texture)
Definition: texture.c:568
GLuint buffer
Definition: glext.h:5915
#define debugstr_w
Definition: kernel32.h:32

Referenced by D3DXCreateTextureFromFileExA(), and D3DXCreateTextureFromFileW().

◆ D3DXCreateTextureFromFileInMemory()

HRESULT WINAPI D3DXCreateTextureFromFileInMemory ( struct IDirect3DDevice9 *  device,
const void srcdata,
UINT  srcdatasize,
struct IDirect3DTexture9 **  texture 
)

Definition at line 748 of file texture.c.

750{
751 TRACE("(%p, %p, %d, %p)\n", device, srcdata, srcdatasize, texture);
752
755}

Referenced by test_D3DXCreateTextureFromFileInMemory().

◆ D3DXCreateTextureFromFileInMemoryEx()

HRESULT WINAPI D3DXCreateTextureFromFileInMemoryEx ( struct IDirect3DDevice9 *  device,
const void srcdata,
UINT  srcdatasize,
UINT  width,
UINT  height,
UINT  miplevels,
DWORD  usage,
D3DFORMAT  format,
D3DPOOL  pool,
DWORD  filter,
DWORD  mipfilter,
D3DCOLOR  colorkey,
D3DXIMAGE_INFO srcinfo,
PALETTEENTRY palette,
struct IDirect3DTexture9 **  texture 
)

Definition at line 568 of file texture.c.

572{
573 BOOL dynamic_texture, format_specified = FALSE;
574 unsigned int loaded_miplevels, skip_levels;
575 IDirect3DSurface9 *surface;
576 IDirect3DTexture9 **texptr;
577 IDirect3DTexture9 *buftex;
578 D3DXIMAGE_INFO imginfo;
579 D3DCAPS9 caps;
580 HRESULT hr;
581
582 TRACE("device %p, srcdata %p, srcdatasize %u, width %u, height %u, miplevels %u,"
583 " usage %#x, format %#x, pool %#x, filter %#x, mipfilter %#x, colorkey %#x,"
584 " srcinfo %p, palette %p, texture %p.\n",
585 device, srcdata, srcdatasize, width, height, miplevels, usage, format, pool,
586 filter, mipfilter, colorkey, srcinfo, palette, texture);
587
588 /* check for invalid parameters */
589 if (!device || !texture || !srcdata || !srcdatasize)
590 return D3DERR_INVALIDCALL;
591
592 hr = D3DXGetImageInfoFromFileInMemory(srcdata, srcdatasize, &imginfo);
593 if (FAILED(hr))
594 {
595 FIXME("Unrecognized file format, returning failure.\n");
596 *texture = NULL;
597 return hr;
598 }
599
600 /* handle default values */
601 if (width == 0 || width == D3DX_DEFAULT_NONPOW2)
602 width = imginfo.Width;
603
604 if (height == 0 || height == D3DX_DEFAULT_NONPOW2)
605 height = imginfo.Height;
606
607 if (width == D3DX_DEFAULT)
608 width = make_pow2(imginfo.Width);
609
610 if (height == D3DX_DEFAULT)
611 height = make_pow2(imginfo.Height);
612
614 format = imginfo.Format;
615 else
616 format_specified = TRUE;
617
618 if (width == D3DX_FROM_FILE)
619 {
620 width = imginfo.Width;
621 }
622
623 if (height == D3DX_FROM_FILE)
624 {
625 height = imginfo.Height;
626 }
627
629 {
630 format = imginfo.Format;
631 }
632
633 if (miplevels == D3DX_FROM_FILE)
634 {
635 miplevels = imginfo.MipLevels;
636 }
637
638 skip_levels = mipfilter != D3DX_DEFAULT ? mipfilter >> D3DX_SKIP_DDS_MIP_LEVELS_SHIFT : 0;
639 if (skip_levels && imginfo.MipLevels > skip_levels)
640 {
641 TRACE("Skipping the first %u (of %u) levels of a DDS mipmapped texture.\n",
642 skip_levels, imginfo.MipLevels);
643 TRACE("Texture level 0 dimensions are %ux%u.\n", imginfo.Width, imginfo.Height);
644 width >>= skip_levels;
645 height >>= skip_levels;
646 miplevels -= skip_levels;
647 }
648 else
649 {
650 skip_levels = 0;
651 }
652
653 /* Fix up texture creation parameters. */
655 if (FAILED(hr))
656 {
657 FIXME("Couldn't find suitable texture parameters.\n");
658 *texture = NULL;
659 return hr;
660 }
661
662 if (colorkey && !format_specified)
664
666 && D3DFMT_DXT1 <= imginfo.Format && imginfo.Format <= D3DFMT_DXT5 && miplevels > 1)
667 {
668 FIXME("Generation of mipmaps for compressed volume textures is not implemented yet.\n");
669 miplevels = 1;
670 }
671
673 return D3DERR_INVALIDCALL;
674
675 /* Create the to-be-filled texture */
676 dynamic_texture = (caps.Caps2 & D3DCAPS2_DYNAMICTEXTURES) && (usage & D3DUSAGE_DYNAMIC);
677 if (pool == D3DPOOL_DEFAULT && !dynamic_texture)
678 {
679 hr = D3DXCreateTexture(device, width, height, miplevels, 0, format, D3DPOOL_SYSTEMMEM, &buftex);
680 texptr = &buftex;
681 }
682 else
683 {
685 texptr = texture;
686 }
687
688 if (FAILED(hr))
689 {
690 FIXME("Texture creation failed.\n");
691 *texture = NULL;
692 return hr;
693 }
694
695 TRACE("Texture created correctly. Now loading the texture data into it.\n");
696 if (imginfo.ImageFileFormat != D3DXIFF_DDS)
697 {
698 IDirect3DTexture9_GetSurfaceLevel(*texptr, 0, &surface);
699 hr = D3DXLoadSurfaceFromFileInMemory(surface, palette, NULL, srcdata, srcdatasize, NULL, filter, colorkey, NULL);
701 loaded_miplevels = min(IDirect3DTexture9_GetLevelCount(*texptr), imginfo.MipLevels);
702 }
703 else
704 {
705 hr = load_texture_from_dds(*texptr, srcdata, palette, filter, colorkey, &imginfo, skip_levels,
706 &loaded_miplevels);
707 }
708
709 if (FAILED(hr))
710 {
711 FIXME("Texture loading failed.\n");
713 *texture = NULL;
714 return hr;
715 }
716
717 hr = D3DXFilterTexture((IDirect3DBaseTexture9*) *texptr, palette, loaded_miplevels - 1, mipfilter);
718 if (FAILED(hr))
719 {
720 FIXME("Texture filtering failed.\n");
722 *texture = NULL;
723 return hr;
724 }
725
726 /* Move the data to the actual texture if necessary */
727 if (texptr == &buftex)
728 {
730
731 if (FAILED(hr))
732 {
734 *texture = NULL;
735 return hr;
736 }
737
738 IDirect3DDevice9_UpdateTexture(device, (IDirect3DBaseTexture9*)buftex, (IDirect3DBaseTexture9*)(*texture));
740 }
741
742 if (srcinfo)
743 *srcinfo = imginfo;
744
745 return D3D_OK;
746}
@ D3DFMT_DXT5
Definition: d3d8types.h:638
@ D3DFMT_DXT1
Definition: d3d8types.h:634
#define IDirect3DTexture9_GetSurfaceLevel(p, a, b)
Definition: d3d9.h:1033
#define IDirect3DTexture9_GetLevelCount(p)
Definition: d3d9.h:1027
#define IDirect3DSurface9_Release(p)
Definition: d3d9.h:622
#define IDirect3DTexture9_Release(p)
Definition: d3d9.h:1014
HRESULT load_texture_from_dds(IDirect3DTexture9 *texture, const void *src_data, const PALETTEENTRY *palette, DWORD filter, D3DCOLOR color_key, const D3DXIMAGE_INFO *src_info, unsigned int skip_levels, unsigned int *loaded_miplevels) DECLSPEC_HIDDEN
Definition: surface.c:737
HRESULT WINAPI D3DXLoadSurfaceFromFileInMemory(IDirect3DSurface9 *pDestSurface, const PALETTEENTRY *pDestPalette, const RECT *pDestRect, const void *pSrcData, UINT SrcDataSize, const RECT *pSrcRect, DWORD dwFilter, D3DCOLOR Colorkey, D3DXIMAGE_INFO *pSrcInfo)
Definition: surface.c:1245
static D3DFORMAT get_alpha_replacement_format(D3DFORMAT format)
Definition: texture.c:545
HRESULT WINAPI D3DXCreateTexture(struct IDirect3DDevice9 *device, UINT width, UINT height, UINT miplevels, DWORD usage, D3DFORMAT format, D3DPOOL pool, struct IDirect3DTexture9 **texture)
Definition: texture.c:528
D3DRESOURCETYPE ResourceType
Definition: d3dx9tex.h:83

Referenced by D3DXCreateTextureFromFileExW(), D3DXCreateTextureFromFileInMemory(), D3DXCreateTextureFromResourceExA(), D3DXCreateTextureFromResourceExW(), and test_D3DXCreateTextureFromFileInMemoryEx().

◆ D3DXCreateTextureFromFileW()

HRESULT WINAPI D3DXCreateTextureFromFileW ( struct IDirect3DDevice9 *  device,
const WCHAR srcfile,
struct IDirect3DTexture9 **  texture 
)

Definition at line 827 of file texture.c.

◆ D3DXCreateTextureFromResourceA()

HRESULT WINAPI D3DXCreateTextureFromResourceA ( struct IDirect3DDevice9 *  device,
HMODULE  srcmodule,
const char resource,
struct IDirect3DTexture9 **  texture 
)

Definition at line 837 of file texture.c.

839{
840 TRACE("(%p, %s): relay\n", srcmodule, debugstr_a(resource));
841
844}
HRESULT WINAPI D3DXCreateTextureFromResourceExA(struct IDirect3DDevice9 *device, HMODULE srcmodule, const char *resource, UINT width, UINT height, UINT miplevels, DWORD usage, D3DFORMAT format, D3DPOOL pool, DWORD filter, DWORD mipfilter, D3DCOLOR colorkey, D3DXIMAGE_INFO *srcinfo, PALETTEENTRY *palette, struct IDirect3DTexture9 **texture)
Definition: texture.c:855

Referenced by test_D3DXCreateTexture().

◆ D3DXCreateTextureFromResourceExA()

HRESULT WINAPI D3DXCreateTextureFromResourceExA ( struct IDirect3DDevice9 *  device,
HMODULE  srcmodule,
const char resource,
UINT  width,
UINT  height,
UINT  miplevels,
DWORD  usage,
D3DFORMAT  format,
D3DPOOL  pool,
DWORD  filter,
DWORD  mipfilter,
D3DCOLOR  colorkey,
D3DXIMAGE_INFO srcinfo,
PALETTEENTRY palette,
struct IDirect3DTexture9 **  texture 
)

Definition at line 855 of file texture.c.

859{
860 HRSRC resinfo;
861 void *buffer;
862 DWORD size;
863
864 TRACE("device %p, srcmodule %p, resource %s, width %u, height %u, miplevels %u, usage %#x, format %#x, "
865 "pool %#x, filter %#x, mipfilter %#x, colorkey 0x%08x, srcinfo %p, palette %p, texture %p.\n",
866 device, srcmodule, debugstr_a(resource), width, height, miplevels, usage, format,
867 pool, filter, mipfilter, colorkey, srcinfo, palette, texture);
868
869 if (!device || !texture)
870 return D3DERR_INVALIDCALL;
871
872 if (!(resinfo = FindResourceA(srcmodule, resource, (const char *)RT_RCDATA))
873 /* Try loading the resource as bitmap data (which is in DIB format D3DXIFF_DIB) */
874 && !(resinfo = FindResourceA(srcmodule, resource, (const char *)RT_BITMAP)))
875 return D3DXERR_INVALIDDATA;
876
877 if (FAILED(load_resource_into_memory(srcmodule, resinfo, &buffer, &size)))
878 return D3DXERR_INVALIDDATA;
879
881 usage, format, pool, filter, mipfilter, colorkey, srcinfo, palette, texture);
882}
HRESULT load_resource_into_memory(HMODULE module, HRSRC resinfo, void **buffer, DWORD *length) DECLSPEC_HIDDEN
Definition: util.c:170
HRSRC WINAPI FindResourceA(HMODULE hModule, LPCSTR name, LPCSTR type)
Definition: res.c:155
#define RT_BITMAP
Definition: pedump.c:364
#define RT_RCDATA
Definition: pedump.c:372

Referenced by D3DXCreateTextureFromResourceA(), and test_D3DXCreateTexture().

◆ D3DXCreateTextureFromResourceExW()

HRESULT WINAPI D3DXCreateTextureFromResourceExW ( struct IDirect3DDevice9 *  device,
HMODULE  srcmodule,
const WCHAR resource,
UINT  width,
UINT  height,
UINT  miplevels,
DWORD  usage,
D3DFORMAT  format,
D3DPOOL  pool,
DWORD  filter,
DWORD  mipfilter,
D3DCOLOR  colorkey,
D3DXIMAGE_INFO srcinfo,
PALETTEENTRY palette,
struct IDirect3DTexture9 **  texture 
)

Definition at line 884 of file texture.c.

888{
889 HRSRC resinfo;
890 void *buffer;
891 DWORD size;
892
893 TRACE("device %p, srcmodule %p, resource %s, width %u, height %u, miplevels %u, usage %#x, format %#x, "
894 "pool %#x, filter %#x, mipfilter %#x, colorkey 0x%08x, srcinfo %p, palette %p, texture %p.\n",
895 device, srcmodule, debugstr_w(resource), width, height, miplevels, usage, format,
896 pool, filter, mipfilter, colorkey, srcinfo, palette, texture);
897
898 if (!device || !texture)
899 return D3DERR_INVALIDCALL;
900
901 if (!(resinfo = FindResourceW(srcmodule, resource, (const WCHAR *)RT_RCDATA))
902 /* Try loading the resource as bitmap data (which is in DIB format D3DXIFF_DIB) */
903 && !(resinfo = FindResourceW(srcmodule, resource, (const WCHAR *)RT_BITMAP)))
904 return D3DXERR_INVALIDDATA;
905
906 if (FAILED(load_resource_into_memory(srcmodule, resinfo, &buffer, &size)))
907 return D3DXERR_INVALIDDATA;
908
910 usage, format, pool, filter, mipfilter, colorkey, srcinfo, palette, texture);
911}
HRSRC WINAPI FindResourceW(HINSTANCE hModule, LPCWSTR name, LPCWSTR type)
Definition: res.c:176

Referenced by D3DXCreateTextureFromResourceW().

◆ D3DXCreateTextureFromResourceW()

HRESULT WINAPI D3DXCreateTextureFromResourceW ( struct IDirect3DDevice9 *  device,
HMODULE  srcmodule,
const WCHAR resource,
struct IDirect3DTexture9 **  texture 
)

Definition at line 846 of file texture.c.

848{
849 TRACE("(%p, %s): relay\n", srcmodule, debugstr_w(resource));
850
853}
HRESULT WINAPI D3DXCreateTextureFromResourceExW(struct IDirect3DDevice9 *device, HMODULE srcmodule, const WCHAR *resource, UINT width, UINT height, UINT miplevels, DWORD usage, D3DFORMAT format, D3DPOOL pool, DWORD filter, DWORD mipfilter, D3DCOLOR colorkey, D3DXIMAGE_INFO *srcinfo, PALETTEENTRY *palette, struct IDirect3DTexture9 **texture)
Definition: texture.c:884

◆ D3DXCreateVolumeTexture()

HRESULT WINAPI D3DXCreateVolumeTexture ( struct IDirect3DDevice9 *  device,
UINT  width,
UINT  height,
UINT  depth,
UINT  miplevels,
DWORD  usage,
D3DFORMAT  format,
D3DPOOL  pool,
struct IDirect3DVolumeTexture9 **  volume 
)

Definition at line 944 of file texture.c.

946{
947 HRESULT hr;
948
949 TRACE("(%p, %u, %u, %u, %u, %#x, %#x, %#x, %p)\n", device, width, height, depth,
950 miplevels, usage, format, pool, texture);
951
952 if (!device || !texture)
953 return D3DERR_INVALIDCALL;
954
956 &miplevels, usage, &format, pool);
957
958 if (FAILED(hr))
959 {
960 TRACE("D3DXCheckVolumeTextureRequirements failed\n");
961 return hr;
962 }
963
966}
#define IDirect3DDevice9_CreateVolumeTexture(p, a, b, c, d, e, f, g, h, i)
Definition: d3d9.h:1531
HRESULT WINAPI D3DXCheckVolumeTextureRequirements(struct IDirect3DDevice9 *device, UINT *width, UINT *height, UINT *depth, UINT *miplevels, DWORD usage, D3DFORMAT *format, D3DPOOL pool)
Definition: texture.c:456

Referenced by D3DXCreateVolumeTextureFromFileInMemoryEx().

◆ D3DXCreateVolumeTextureFromFileA()

HRESULT WINAPI D3DXCreateVolumeTextureFromFileA ( struct IDirect3DDevice9 *  device,
const char srcfile,
struct IDirect3DVolumeTexture9 **  volume 
)

Definition at line 968 of file texture.c.

971{
972 int len;
973 HRESULT hr;
974 void *data;
975 DWORD data_size;
977
978 TRACE("(%p, %s, %p): relay\n",
979 device, debugstr_a(filename), volume_texture);
980
981 if (!filename) return D3DERR_INVALIDCALL;
982
984 filenameW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
985 if (!filenameW) return E_OUTOFMEMORY;
987
988 hr = map_view_of_file(filenameW, &data, &data_size);
990 if (FAILED(hr)) return D3DXERR_INVALIDDATA;
991
994
996 return hr;
997}
HRESULT WINAPI D3DXCreateVolumeTextureFromFileInMemoryEx(IDirect3DDevice9 *device, const void *data, UINT data_size, UINT width, UINT height, UINT depth, UINT mip_levels, DWORD usage, D3DFORMAT format, D3DPOOL pool, DWORD filter, DWORD mip_filter, D3DCOLOR color_key, D3DXIMAGE_INFO *info, PALETTEENTRY *palette, IDirect3DVolumeTexture9 **volume_texture)
Definition: texture.c:1118
static const WCHAR filenameW[]
Definition: amstream.c:41

◆ D3DXCreateVolumeTextureFromFileExA()

HRESULT WINAPI D3DXCreateVolumeTextureFromFileExA ( struct IDirect3DDevice9 *  device,
const char srcfile,
UINT  width,
UINT  height,
UINT  depth,
UINT  miplevels,
DWORD  usage,
D3DFORMAT  format,
D3DPOOL  pool,
DWORD  filter,
DWORD  mipfilter,
D3DCOLOR  colorkey,
D3DXIMAGE_INFO srcinfo,
PALETTEENTRY palette,
struct IDirect3DVolumeTexture9 **  volume 
)

Definition at line 1022 of file texture.c.

1037{
1038 int len;
1039 HRESULT hr;
1041 void *data;
1042 DWORD data_size;
1043
1044 TRACE("(%p, %s, %u, %u, %u, %u, %#x, %#x, %#x, %#x, %#x, %#x, %p, %p, %p): relay\n",
1045 device, debugstr_a(filename), width, height, depth, mip_levels,
1046 usage, format, pool, filter, mip_filter, color_key, src_info,
1047 palette, volume_texture);
1048
1049 if (!filename) return D3DERR_INVALIDCALL;
1050
1052 filenameW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
1053 if (!filenameW) return E_OUTOFMEMORY;
1055
1056 hr = map_view_of_file(filenameW, &data, &data_size);
1058 if (FAILED(hr)) return D3DXERR_INVALIDDATA;
1059
1061 mip_levels, usage, format, pool, filter, mip_filter, color_key, src_info, palette,
1062 volume_texture);
1063
1065 return hr;
1066}

◆ D3DXCreateVolumeTextureFromFileExW()

HRESULT WINAPI D3DXCreateVolumeTextureFromFileExW ( struct IDirect3DDevice9 *  device,
const WCHAR srcfile,
UINT  width,
UINT  height,
UINT  depth,
UINT  miplevels,
DWORD  usage,
D3DFORMAT  format,
D3DPOOL  pool,
DWORD  filter,
DWORD  mipfilter,
D3DCOLOR  colorkey,
D3DXIMAGE_INFO srcinfo,
PALETTEENTRY palette,
struct IDirect3DVolumeTexture9 **  volume 
)

Definition at line 1068 of file texture.c.

1083{
1084 HRESULT hr;
1085 void *data;
1086 DWORD data_size;
1087
1088 TRACE("(%p, %s, %u, %u, %u, %u, %#x, %#x, %#x, %#x, %#x, %#x, %p, %p, %p): relay\n",
1089 device, debugstr_w(filename), width, height, depth, mip_levels,
1090 usage, format, pool, filter, mip_filter, color_key, src_info,
1091 palette, volume_texture);
1092
1093 if (!filename) return D3DERR_INVALIDCALL;
1094
1095 hr = map_view_of_file(filename, &data, &data_size);
1096 if (FAILED(hr)) return D3DXERR_INVALIDDATA;
1097
1099 mip_levels, usage, format, pool, filter, mip_filter, color_key, src_info, palette,
1100 volume_texture);
1101
1103 return hr;
1104}

◆ D3DXCreateVolumeTextureFromFileInMemory()

HRESULT WINAPI D3DXCreateVolumeTextureFromFileInMemory ( struct IDirect3DDevice9 *  device,
const void srcdata,
UINT  srcdatasize,
struct IDirect3DVolumeTexture9 **  volume 
)

Definition at line 1106 of file texture.c.

1110{
1111 TRACE("(%p, %p, %u, %p): relay\n", device, data, data_size, volume_texture);
1112
1115 0, NULL, NULL, volume_texture);
1116}

Referenced by test_D3DXCreateVolumeTextureFromFileInMemory().

◆ D3DXCreateVolumeTextureFromFileInMemoryEx()

HRESULT WINAPI D3DXCreateVolumeTextureFromFileInMemoryEx ( struct IDirect3DDevice9 *  device,
const void srcdata,
UINT  srcdatasize,
UINT  width,
UINT  height,
UINT  depth,
UINT  miplevels,
DWORD  usage,
D3DFORMAT  format,
D3DPOOL  pool,
DWORD  filter,
DWORD  mipfilter,
D3DCOLOR  colorkey,
D3DXIMAGE_INFO srcinfo,
PALETTEENTRY palette,
struct IDirect3DVolumeTexture9 **  volume 
)

Definition at line 1118 of file texture.c.

1134{
1135 HRESULT hr;
1136 D3DCAPS9 caps;
1137 D3DXIMAGE_INFO image_info;
1138 BOOL dynamic_texture;
1139 BOOL file_width = FALSE;
1140 BOOL file_height = FALSE;
1141 BOOL file_depth = FALSE;
1142 BOOL file_format = FALSE;
1143 BOOL file_mip_levels = FALSE;
1144 IDirect3DVolumeTexture9 *tex, *buftex;
1145
1146 TRACE("(%p, %p, %u, %u, %u, %u, %u, %#x, %#x, %#x, %#x, %#x, %#x, %p, %p, %p)\n",
1147 device, data, data_size, width, height, depth, mip_levels, usage, format, pool,
1148 filter, mip_filter, color_key, info, palette, volume_texture);
1149
1150 if (!device || !data || !data_size || !volume_texture)
1151 return D3DERR_INVALIDCALL;
1152
1153 hr = D3DXGetImageInfoFromFileInMemory(data, data_size, &image_info);
1154 if (FAILED(hr)) return hr;
1155
1156 if (image_info.ImageFileFormat != D3DXIFF_DDS)
1157 return D3DXERR_INVALIDDATA;
1158
1159 if (width == 0 || width == D3DX_DEFAULT_NONPOW2)
1160 width = image_info.Width;
1161 if (width == D3DX_DEFAULT)
1162 width = make_pow2(image_info.Width);
1163
1164 if (height == 0 || height == D3DX_DEFAULT_NONPOW2)
1165 height = image_info.Height;
1166 if (height == D3DX_DEFAULT)
1167 height = make_pow2(image_info.Height);
1168
1169 if (depth == 0 || depth == D3DX_DEFAULT_NONPOW2)
1170 depth = image_info.Depth;
1171 if (depth == D3DX_DEFAULT)
1172 depth = make_pow2(image_info.Depth);
1173
1175 format = image_info.Format;
1176
1177 if (width == D3DX_FROM_FILE)
1178 {
1179 file_width = TRUE;
1180 width = image_info.Width;
1181 }
1182
1183 if (height == D3DX_FROM_FILE)
1184 {
1185 file_height = TRUE;
1186 height = image_info.Height;
1187 }
1188
1189 if (depth == D3DX_FROM_FILE)
1190 {
1191 file_depth = TRUE;
1192 depth = image_info.Depth;
1193 }
1194
1195 if (format == D3DFMT_FROM_FILE)
1196 {
1197 file_format = TRUE;
1198 format = image_info.Format;
1199 }
1200
1201 if (mip_levels == D3DX_FROM_FILE)
1202 {
1203 file_mip_levels = TRUE;
1204 mip_levels = image_info.MipLevels;
1205 }
1206
1208 if (FAILED(hr)) return hr;
1209
1210 if ((file_width && width != image_info.Width)
1211 || (file_height && height != image_info.Height)
1212 || (file_depth && depth != image_info.Depth)
1213 || (file_format && format != image_info.Format)
1214 || (file_mip_levels && mip_levels != image_info.MipLevels))
1215 return D3DERR_NOTAVAILABLE;
1216
1218 if (FAILED(hr))
1219 return D3DERR_INVALIDCALL;
1220
1221 if (mip_levels > image_info.MipLevels)
1222 {
1223 FIXME("Generation of mipmaps for volume textures is not implemented yet.\n");
1224 mip_levels = image_info.MipLevels;
1225 }
1226
1227 dynamic_texture = (caps.Caps2 & D3DCAPS2_DYNAMICTEXTURES) && (usage & D3DUSAGE_DYNAMIC);
1228 if (pool == D3DPOOL_DEFAULT && !dynamic_texture)
1229 {
1231 tex = buftex;
1232 }
1233 else
1234 {
1235 hr = D3DXCreateVolumeTexture(device, width, height, depth, mip_levels, usage, format, pool, &tex);
1236 buftex = NULL;
1237 }
1238 if (FAILED(hr)) return hr;
1239
1241 if (FAILED(hr))
1242 {
1244 return hr;
1245 }
1246
1247 if (buftex)
1248 {
1249 hr = D3DXCreateVolumeTexture(device, width, height, depth, mip_levels, usage, format, pool, &tex);
1250 if (FAILED(hr))
1251 {
1253 return hr;
1254 }
1255
1256 IDirect3DDevice9_UpdateTexture(device, (IDirect3DBaseTexture9 *)buftex, (IDirect3DBaseTexture9 *)tex);
1258 }
1259
1260 if (info)
1261 *info = image_info;
1262
1263 *volume_texture = tex;
1264 return D3D_OK;
1265}
#define IDirect3DVolumeTexture9_Release(p)
Definition: d3d9.h:1109
HRESULT load_volume_texture_from_dds(IDirect3DVolumeTexture9 *volume_texture, const void *src_data, const PALETTEENTRY *palette, DWORD filter, DWORD color_key, const D3DXIMAGE_INFO *src_info) DECLSPEC_HIDDEN
Definition: surface.c:847
HRESULT WINAPI D3DXCreateVolumeTexture(struct IDirect3DDevice9 *device, UINT width, UINT height, UINT depth, UINT miplevels, DWORD usage, D3DFORMAT format, D3DPOOL pool, struct IDirect3DVolumeTexture9 **texture)
Definition: texture.c:944

Referenced by D3DXCreateVolumeTextureFromFileA(), D3DXCreateVolumeTextureFromFileExA(), D3DXCreateVolumeTextureFromFileExW(), D3DXCreateVolumeTextureFromFileInMemory(), D3DXCreateVolumeTextureFromFileW(), and test_D3DXCreateVolumeTextureFromFileInMemoryEx().

◆ D3DXCreateVolumeTextureFromFileW()

HRESULT WINAPI D3DXCreateVolumeTextureFromFileW ( struct IDirect3DDevice9 *  device,
const WCHAR srcfile,
struct IDirect3DVolumeTexture9 **  volume 
)

Definition at line 999 of file texture.c.

1002{
1003 HRESULT hr;
1004 void *data;
1005 DWORD data_size;
1006
1007 TRACE("(%p, %s, %p): relay\n",
1008 device, debugstr_w(filename), volume_texture);
1009
1010 if (!filename) return D3DERR_INVALIDCALL;
1011
1012 hr = map_view_of_file(filename, &data, &data_size);
1013 if (FAILED(hr)) return D3DXERR_INVALIDDATA;
1014
1017
1019 return hr;
1020}

◆ D3DXCreateVolumeTextureFromResourceA()

HRESULT WINAPI D3DXCreateVolumeTextureFromResourceA ( struct IDirect3DDevice9 *  device,
HMODULE  srcmodule,
const char resource,
struct IDirect3DVolumeTexture9 **  volume 
)

◆ D3DXCreateVolumeTextureFromResourceExA()

HRESULT WINAPI D3DXCreateVolumeTextureFromResourceExA ( struct IDirect3DDevice9 *  device,
HMODULE  srcmodule,
const char resource,
UINT  width,
UINT  height,
UINT  depth,
UINT  miplevels,
DWORD  usage,
D3DFORMAT  format,
D3DPOOL  pool,
DWORD  filter,
DWORD  mipfilter,
D3DCOLOR  colorkey,
D3DXIMAGE_INFO srcinfo,
PALETTEENTRY palette,
struct IDirect3DVolumeTexture9 **  volume 
)

◆ D3DXCreateVolumeTextureFromResourceExW()

HRESULT WINAPI D3DXCreateVolumeTextureFromResourceExW ( struct IDirect3DDevice9 *  device,
HMODULE  srcmodule,
const WCHAR resource,
UINT  width,
UINT  height,
UINT  depth,
UINT  miplevels,
DWORD  usage,
D3DFORMAT  format,
D3DPOOL  pool,
DWORD  filter,
DWORD  mipfilter,
D3DCOLOR  colorkey,
D3DXIMAGE_INFO srcinfo,
PALETTEENTRY palette,
struct IDirect3DVolumeTexture9 **  volume 
)

◆ D3DXCreateVolumeTextureFromResourceW()

HRESULT WINAPI D3DXCreateVolumeTextureFromResourceW ( struct IDirect3DDevice9 *  device,
HMODULE  srcmodule,
const WCHAR resource,
struct IDirect3DVolumeTexture9 **  volume 
)

◆ D3DXFillCubeTexture()

HRESULT WINAPI D3DXFillCubeTexture ( struct IDirect3DCubeTexture9 *  cube,
LPD3DXFILL3D  function,
void data 
)

Definition at line 1695 of file texture.c.

1696{
1697 DWORD miplevels;
1698 DWORD m, x, y, f;
1700 D3DLOCKED_RECT lock_rect;
1703 const struct pixel_format_desc *format;
1704 BYTE *data;
1705 static const enum cube_coord coordmap[6][3] =
1706 {
1708 {ZERO, YCOORDINV, XCOORD},
1709 {XCOORD, ONE, YCOORD},
1710 {XCOORD, ZERO, YCOORDINV},
1711 {XCOORD, YCOORDINV, ONE},
1713 };
1714
1715 if (texture == NULL || function == NULL)
1716 return D3DERR_INVALIDCALL;
1717
1719
1720 for (m = 0; m < miplevels; m++)
1721 {
1723 return D3DERR_INVALIDCALL;
1724
1725 format = get_format_info(desc.Format);
1726 if (format->type != FORMAT_ARGB && format->type != FORMAT_ARGBF16 && format->type != FORMAT_ARGBF)
1727 {
1728 FIXME("Unsupported texture format %#x\n", desc.Format);
1729 return D3DERR_INVALIDCALL;
1730 }
1731
1732 for (f = 0; f < 6; f++)
1733 {
1735 return D3DERR_INVALIDCALL;
1736
1737 size.x = (f == 0) || (f == 1) ? 0.0f : 2.0f / desc.Width;
1738 size.y = (f == 2) || (f == 3) ? 0.0f : 2.0f / desc.Width;
1739 size.z = (f == 4) || (f == 5) ? 0.0f : 2.0f / desc.Width;
1740
1741 data = lock_rect.pBits;
1742
1743 for (y = 0; y < desc.Height; y++)
1744 {
1745 for (x = 0; x < desc.Width; x++)
1746 {
1747 coord.x = get_cube_coord(coordmap[f][0], x, y, desc.Width) / desc.Width * 2.0f - 1.0f;
1748 coord.y = get_cube_coord(coordmap[f][1], x, y, desc.Width) / desc.Width * 2.0f - 1.0f;
1749 coord.z = get_cube_coord(coordmap[f][2], x, y, desc.Width) / desc.Width * 2.0f - 1.0f;
1750
1751 function(&value, &coord, &size, funcdata);
1752
1753 fill_texture(format, data + y * lock_rect.Pitch + x * format->bytes_per_pixel, &value);
1754 }
1755 }
1757 }
1758 }
1759
1760 return D3D_OK;
1761}
#define D3DLOCK_DISCARD
Definition: d3d8types.h:72
#define IDirect3DCubeTexture9_UnlockRect(p, a, b)
Definition: d3d9.h:940
#define IDirect3DCubeTexture9_LockRect(p, a, b, c, d, e)
Definition: d3d9.h:939
#define IDirect3DBaseTexture9_GetLevelCount(p)
Definition: d3d9.h:848
#define IDirect3DCubeTexture9_GetLevelDesc(p, a, b)
Definition: d3d9.h:937
const struct pixel_format_desc * get_format_info(D3DFORMAT format) DECLSPEC_HIDDEN
Definition: util.c:217
@ FORMAT_ARGBF16
Definition: d3dx9_private.h:51
@ FORMAT_ARGB
Definition: d3dx9_private.h:50
@ FORMAT_ARGBF
Definition: d3dx9_private.h:52
static float get_cube_coord(enum cube_coord coord, unsigned int x, unsigned int y, unsigned int size)
Definition: texture.c:1673
static void fill_texture(const struct pixel_format_desc *format, BYTE *pos, const D3DXVECTOR4 *value)
Definition: texture.c:1267
cube_coord
Definition: texture.c:1664
@ XCOORDINV
Definition: texture.c:1666
@ ONE
Definition: texture.c:1670
@ YCOORDINV
Definition: texture.c:1668
@ XCOORD
Definition: texture.c:1665
@ ZERO
Definition: texture.c:1669
@ YCOORD
Definition: texture.c:1667
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLuint coord
Definition: glext.h:9511
const GLfloat * m
Definition: glext.h:10848
static const WCHAR desc[]
Definition: protectdata.c:36
Definition: pdh_main.c:94
unsigned char BYTE
Definition: xxhash.c:193

Referenced by test_D3DXFillCubeTexture(), and test_D3DXSaveTextureToFileInMemory().

◆ D3DXFillCubeTextureTX()

HRESULT WINAPI D3DXFillCubeTextureTX ( struct IDirect3DCubeTexture9 *  cube,
ID3DXTextureShader *  texture_shader 
)

Definition at line 1763 of file texture.c.

1764{
1765 FIXME("texture %p, texture_shader %p stub.\n", texture, texture_shader);
1766 return E_NOTIMPL;
1767}
#define E_NOTIMPL
Definition: ddrawi.h:99

Referenced by test_texture_shader().

◆ D3DXFillTexture()

HRESULT WINAPI D3DXFillTexture ( struct IDirect3DTexture9 *  texture,
LPD3DXFILL2D  function,
void data 
)

Definition at line 1323 of file texture.c.

1324{
1325 IDirect3DSurface9 *surface, *temp_surface;
1326 DWORD miplevels;
1327 DWORD m, x, y;
1329 D3DLOCKED_RECT lock_rect;
1332 const struct pixel_format_desc *format;
1333 BYTE *data;
1334 HRESULT hr;
1335
1336 TRACE("texture %p, function %p, funcdata %p.\n", texture, function, funcdata);
1337
1338 if (!texture || !function)
1339 return D3DERR_INVALIDCALL;
1340
1342
1343 for (m = 0; m < miplevels; m++)
1344 {
1346 return hr;
1347
1348 format = get_format_info(desc.Format);
1349 if (format->type != FORMAT_ARGB && format->type != FORMAT_ARGBF16 && format->type != FORMAT_ARGBF)
1350 {
1351 FIXME("Unsupported texture format %#x.\n", desc.Format);
1352 return D3DERR_INVALIDCALL;
1353 }
1354
1356 return hr;
1357 if (FAILED(hr = lock_surface(surface, NULL, &lock_rect, &temp_surface, TRUE)))
1358 {
1360 return hr;
1361 }
1362
1363 size.x = 1.0f / desc.Width;
1364 size.y = 1.0f / desc.Height;
1365
1366 data = lock_rect.pBits;
1367
1368 for (y = 0; y < desc.Height; y++)
1369 {
1370 /* The callback function expects the coordinates of the center
1371 of the texel */
1372 coord.y = (y + 0.5f) / desc.Height;
1373
1374 for (x = 0; x < desc.Width; x++)
1375 {
1376 coord.x = (x + 0.5f) / desc.Width;
1377
1378 function(&value, &coord, &size, funcdata);
1379
1380 fill_texture(format, data + y * lock_rect.Pitch + x * format->bytes_per_pixel, &value);
1381 }
1382 }
1383 if (FAILED(hr = unlock_surface(surface, NULL, temp_surface, TRUE)))
1384 {
1386 return hr;
1387 }
1389 }
1390
1391 return D3D_OK;
1392}
#define IDirect3DTexture9_GetLevelDesc(p, a, b)
Definition: d3d9.h:1032
HRESULT lock_surface(IDirect3DSurface9 *surface, const RECT *surface_rect, D3DLOCKED_RECT *lock, IDirect3DSurface9 **temp_surface, BOOL write) DECLSPEC_HIDDEN
Definition: surface.c:209
HRESULT unlock_surface(IDirect3DSurface9 *surface, const RECT *surface_rect, IDirect3DSurface9 *temp_surface, BOOL update) DECLSPEC_HIDDEN
Definition: surface.c:267
#define for
Definition: utility.h:88

Referenced by test_D3DXFillTexture().

◆ D3DXFillTextureTX()

HRESULT WINAPI D3DXFillTextureTX ( struct IDirect3DTexture9 *  texture,
ID3DXTextureShader *  texture_shader 
)

Definition at line 1394 of file texture.c.

1395{
1396 FIXME("texture %p, texture_shader %p stub.\n", texture, texture_shader);
1397 return E_NOTIMPL;
1398}

Referenced by test_texture_shader().

◆ D3DXFillVolumeTexture()

HRESULT WINAPI D3DXFillVolumeTexture ( struct IDirect3DVolumeTexture9 *  volume,
LPD3DXFILL3D  function,
void data 
)

Definition at line 1769 of file texture.c.

1770{
1771 DWORD miplevels;
1772 DWORD m, x, y, z;
1774 D3DLOCKED_BOX lock_box;
1777 const struct pixel_format_desc *format;
1778 BYTE *data;
1779
1780 if (texture == NULL || function == NULL)
1781 return D3DERR_INVALIDCALL;
1782
1784
1785 for (m = 0; m < miplevels; m++)
1786 {
1788 return D3DERR_INVALIDCALL;
1789
1790 format = get_format_info(desc.Format);
1791 if (format->type != FORMAT_ARGB && format->type != FORMAT_ARGBF16 && format->type != FORMAT_ARGBF)
1792 {
1793 FIXME("Unsupported texture format %#x\n", desc.Format);
1794 return D3DERR_INVALIDCALL;
1795 }
1796
1798 return D3DERR_INVALIDCALL;
1799
1800 size.x = 1.0f / desc.Width;
1801 size.y = 1.0f / desc.Height;
1802 size.z = 1.0f / desc.Depth;
1803
1804 data = lock_box.pBits;
1805
1806 for (z = 0; z < desc.Depth; z++)
1807 {
1808 /* The callback function expects the coordinates of the center
1809 of the texel */
1810 coord.z = (z + 0.5f) / desc.Depth;
1811
1812 for (y = 0; y < desc.Height; y++)
1813 {
1814 coord.y = (y + 0.5f) / desc.Height;
1815
1816 for (x = 0; x < desc.Width; x++)
1817 {
1818 coord.x = (x + 0.5f) / desc.Width;
1819
1820 function(&value, &coord, &size, funcdata);
1821
1822 fill_texture(format, data + z * lock_box.SlicePitch + y * lock_box.RowPitch
1823 + x * format->bytes_per_pixel, &value);
1824 }
1825 }
1826 }
1828 }
1829
1830 return D3D_OK;
1831}
#define IDirect3DVolumeTexture9_GetLevelDesc(p, a, b)
Definition: d3d9.h:1127
#define IDirect3DVolumeTexture9_LockBox(p, a, b, c, d)
Definition: d3d9.h:1129
#define IDirect3DVolumeTexture9_UnlockBox(p, a)
Definition: d3d9.h:1130
GLdouble GLdouble z
Definition: glext.h:5874

Referenced by test_D3DXFillVolumeTexture().

◆ D3DXFillVolumeTextureTX()

HRESULT WINAPI D3DXFillVolumeTextureTX ( struct IDirect3DVolumeTexture9 *  volume,
ID3DXTextureShader *  texture_shader 
)

Definition at line 1833 of file texture.c.

1834{
1835 FIXME("texture %p, texture_shader %p stub.\n", texture, texture_shader);
1836 return E_NOTIMPL;
1837}

Referenced by test_texture_shader().

◆ D3DXFilterTexture()

HRESULT WINAPI D3DXFilterTexture ( struct IDirect3DBaseTexture9 *  texture,
const PALETTEENTRY palette,
UINT  srclevel,
DWORD  filter 
)

Definition at line 52 of file texture.c.

56{
57 UINT level;
58 HRESULT hr;
60
61 TRACE("(%p, %p, %u, %#x)\n", texture, palette, srclevel, filter);
62
63 if (!texture)
64 return D3DERR_INVALIDCALL;
65
66 if ((filter & 0xFFFF) > D3DX_FILTER_BOX && filter != D3DX_DEFAULT)
67 return D3DERR_INVALIDCALL;
68
69 if (srclevel == D3DX_DEFAULT)
70 srclevel = 0;
71 else if (srclevel >= IDirect3DBaseTexture9_GetLevelCount(texture))
72 return D3DERR_INVALIDCALL;
73
75 {
78 {
79 IDirect3DSurface9 *topsurf, *mipsurf;
81 int i, numfaces;
82
84 {
85 numfaces = 1;
86 IDirect3DTexture9_GetLevelDesc((IDirect3DTexture9*) texture, srclevel, &desc);
87 }
88 else
89 {
90 numfaces = 6;
91 IDirect3DCubeTexture9_GetLevelDesc((IDirect3DTexture9*) texture, srclevel, &desc);
92 }
93
94 if (filter == D3DX_DEFAULT)
95 {
96 if (is_pow2(desc.Width) && is_pow2(desc.Height))
98 else
100 }
101
102 for (i = 0; i < numfaces; i++)
103 {
104 level = srclevel + 1;
105 hr = get_surface(type, texture, i, srclevel, &topsurf);
106
107 if (FAILED(hr))
108 return D3DERR_INVALIDCALL;
109
110 while (get_surface(type, texture, i, level, &mipsurf) == D3D_OK)
111 {
112 hr = D3DXLoadSurfaceFromSurface(mipsurf, palette, NULL, topsurf, palette, NULL, filter, 0);
114 topsurf = mipsurf;
115
116 if (FAILED(hr))
117 break;
118
119 level++;
120 }
121
123 if (FAILED(hr))
124 return hr;
125 }
126
127 return D3D_OK;
128 }
129
131 {
133 int level, level_count;
134 IDirect3DVolume9 *top_volume, *mip_volume;
135 IDirect3DVolumeTexture9 *volume_texture = (IDirect3DVolumeTexture9*) texture;
136
137 IDirect3DVolumeTexture9_GetLevelDesc(volume_texture, srclevel, &desc);
138
139 if (filter == D3DX_DEFAULT)
140 {
141 if (is_pow2(desc.Width) && is_pow2(desc.Height) && is_pow2(desc.Depth))
143 else
145 }
146
147 hr = IDirect3DVolumeTexture9_GetVolumeLevel(volume_texture, srclevel, &top_volume);
148 if (FAILED(hr))
149 return hr;
150
151 level_count = IDirect3DVolumeTexture9_GetLevelCount(volume_texture);
152 for (level = srclevel + 1; level < level_count; level++)
153 {
154 IDirect3DVolumeTexture9_GetVolumeLevel(volume_texture, level, &mip_volume);
155 hr = D3DXLoadVolumeFromVolume(mip_volume, palette, NULL, top_volume, palette, NULL, filter, 0);
156 IDirect3DVolume9_Release(top_volume);
157 top_volume = mip_volume;
158
159 if (FAILED(hr))
160 break;
161 }
162
163 IDirect3DVolume9_Release(top_volume);
164 if (FAILED(hr))
165 return hr;
166
167 return D3D_OK;
168 }
169
170 default:
171 return D3DERR_INVALIDCALL;
172 }
173}
enum _D3DRESOURCETYPE D3DRESOURCETYPE
#define IDirect3DVolumeTexture9_GetLevelCount(p)
Definition: d3d9.h:1122
#define IDirect3DVolume9_Release(p)
Definition: d3d9.h:383
#define IDirect3DVolumeTexture9_GetVolumeLevel(p, a, b)
Definition: d3d9.h:1128
#define IDirect3DBaseTexture9_GetType(p)
Definition: d3d9.h:844
#define D3DX_FILTER_DITHER
Definition: d3dx9tex.h:36
HRESULT WINAPI D3DXLoadSurfaceFromSurface(IDirect3DSurface9 *dst_surface, const PALETTEENTRY *dst_palette, const RECT *dst_rect, IDirect3DSurface9 *src_surface, const PALETTEENTRY *src_palette, const RECT *src_rect, DWORD filter, D3DCOLOR color_key)
Definition: surface.c:2233
static HRESULT get_surface(D3DRESOURCETYPE type, struct IDirect3DBaseTexture9 *tex, int face, UINT level, struct IDirect3DSurface9 **surf)
Definition: texture.c:37
HRESULT WINAPI D3DXLoadVolumeFromVolume(IDirect3DVolume9 *dst_volume, const PALETTEENTRY *dst_palette, const D3DBOX *dst_box, IDirect3DVolume9 *src_volume, const PALETTEENTRY *src_palette, const D3DBOX *src_box, DWORD filter, D3DCOLOR color_key)
Definition: volume.c:291
GLint level
Definition: gl.h:1546
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248

Referenced by D3DXCreateCubeTextureFromFileInMemoryEx(), D3DXCreateTextureFromFileInMemoryEx(), D3DXRenderToEnvMap_End(), and test_D3DXFilterTexture().

◆ D3DXGetImageInfoFromFileA()

HRESULT WINAPI D3DXGetImageInfoFromFileA ( const char file,
D3DXIMAGE_INFO info 
)

Definition at line 1135 of file surface.c.

1136{
1137 WCHAR *widename;
1138 HRESULT hr;
1139 int strlength;
1140
1141 TRACE("file %s, info %p.\n", debugstr_a(file), info);
1142
1143 if( !file ) return D3DERR_INVALIDCALL;
1144
1145 strlength = MultiByteToWideChar(CP_ACP, 0, file, -1, NULL, 0);
1146 widename = HeapAlloc(GetProcessHeap(), 0, strlength * sizeof(*widename));
1147 MultiByteToWideChar(CP_ACP, 0, file, -1, widename, strlength);
1148
1149 hr = D3DXGetImageInfoFromFileW(widename, info);
1150 HeapFree(GetProcessHeap(), 0, widename);
1151
1152 return hr;
1153}
HRESULT WINAPI D3DXGetImageInfoFromFileW(const WCHAR *file, D3DXIMAGE_INFO *info)
Definition: surface.c:1155
Definition: fci.c:127

Referenced by test_D3DXGetImageInfo().

◆ D3DXGetImageInfoFromFileInMemory()

HRESULT WINAPI D3DXGetImageInfoFromFileInMemory ( const void data,
UINT  data_size,
D3DXIMAGE_INFO info 
)

Definition at line 985 of file surface.c.

986{
988 IWICBitmapDecoder *decoder = NULL;
990 HRESULT hr;
991 BOOL dib;
992
993 TRACE("(%p, %d, %p)\n", data, datasize, info);
994
995 if (!data || !datasize)
996 return D3DERR_INVALIDCALL;
997
998 if (!info)
999 return D3D_OK;
1000
1001 if ((datasize >= 4) && !strncmp(data, "DDS ", 4)) {
1002 TRACE("File type is DDS\n");
1004 }
1005
1006 /* In case of DIB file, convert it to BMP */
1008
1009 hr = WICCreateImagingFactory_Proxy(WINCODEC_SDK_VERSION, &factory);
1010
1011 if (SUCCEEDED(hr)) {
1012 IWICImagingFactory_CreateStream(factory, &stream);
1013 IWICStream_InitializeFromMemory(stream, (BYTE*)data, datasize);
1014 hr = IWICImagingFactory_CreateDecoderFromStream(factory, (IStream*)stream, NULL, 0, &decoder);
1015 IWICStream_Release(stream);
1016 IWICImagingFactory_Release(factory);
1017 }
1018
1019 if (FAILED(hr)) {
1020 if ((datasize >= 2) && (!strncmp(data, "P3", 2) || !strncmp(data, "P6", 2)))
1021 FIXME("File type PPM is not supported yet\n");
1022 else if ((datasize >= 10) && !strncmp(data, "#?RADIANCE", 10))
1023 FIXME("File type HDR is not supported yet\n");
1024 else if ((datasize >= 2) && (!strncmp(data, "PF", 2) || !strncmp(data, "Pf", 2)))
1025 FIXME("File type PFM is not supported yet\n");
1026 }
1027
1028 if (SUCCEEDED(hr)) {
1029 GUID container_format;
1030 UINT frame_count;
1031
1032 hr = IWICBitmapDecoder_GetContainerFormat(decoder, &container_format);
1033 if (SUCCEEDED(hr)) {
1034 if (IsEqualGUID(&container_format, &GUID_ContainerFormatBmp)) {
1035 if (dib) {
1036 TRACE("File type is DIB\n");
1037 info->ImageFileFormat = D3DXIFF_DIB;
1038 } else {
1039 TRACE("File type is BMP\n");
1040 info->ImageFileFormat = D3DXIFF_BMP;
1041 }
1042 } else if (IsEqualGUID(&container_format, &GUID_ContainerFormatPng)) {
1043 TRACE("File type is PNG\n");
1044 info->ImageFileFormat = D3DXIFF_PNG;
1045 } else if(IsEqualGUID(&container_format, &GUID_ContainerFormatJpeg)) {
1046 TRACE("File type is JPG\n");
1047 info->ImageFileFormat = D3DXIFF_JPG;
1048 } else if(IsEqualGUID(&container_format, &GUID_WineContainerFormatTga)) {
1049 TRACE("File type is TGA\n");
1050 info->ImageFileFormat = D3DXIFF_TGA;
1051 } else {
1052 WARN("Unsupported image file format %s\n", debugstr_guid(&container_format));
1054 }
1055 }
1056
1057 if (SUCCEEDED(hr))
1058 hr = IWICBitmapDecoder_GetFrameCount(decoder, &frame_count);
1059 if (SUCCEEDED(hr) && !frame_count)
1061
1062 if (SUCCEEDED(hr)) {
1063 IWICBitmapFrameDecode *frame = NULL;
1064
1065 hr = IWICBitmapDecoder_GetFrame(decoder, 0, &frame);
1066
1067 if (SUCCEEDED(hr))
1068 hr = IWICBitmapFrameDecode_GetSize(frame, &info->Width, &info->Height);
1069
1070 if (SUCCEEDED(hr)) {
1072
1073 hr = IWICBitmapFrameDecode_GetPixelFormat(frame, &pixel_format);
1074 if (SUCCEEDED(hr)) {
1076 if (info->Format == D3DFMT_UNKNOWN) {
1077 WARN("Unsupported pixel format %s\n", debugstr_guid(&pixel_format));
1079 }
1080 }
1081 }
1082
1083 /* For 32 bpp BMP, windowscodecs.dll never returns a format with alpha while
1084 * d3dx9_xx.dll returns one if at least 1 pixel has a non zero alpha component */
1085 if (SUCCEEDED(hr) && (info->Format == D3DFMT_X8R8G8B8) && (info->ImageFileFormat == D3DXIFF_BMP)) {
1086 DWORD size = sizeof(DWORD) * info->Width * info->Height;
1088 hr = IWICBitmapFrameDecode_CopyPixels(frame, NULL, sizeof(DWORD) * info->Width, size, buffer);
1089 if (SUCCEEDED(hr)) {
1090 DWORD i;
1091 for (i = 0; i < info->Width * info->Height; i++) {
1092 if (buffer[i*4+3]) {
1093 info->Format = D3DFMT_A8R8G8B8;
1094 break;
1095 }
1096 }
1097 }
1099 }
1100
1101 if (frame)
1102 IWICBitmapFrameDecode_Release(frame);
1103
1104 info->Depth = 1;
1105 info->MipLevels = 1;
1106 info->ResourceType = D3DRTYPE_TEXTURE;
1107 }
1108 }
1109
1110 if (decoder)
1111 IWICBitmapDecoder_Release(decoder);
1112
1113 if (dib)
1114 HeapFree(GetProcessHeap(), 0, (void*)data);
1115
1116 if (FAILED(hr)) {
1117 TRACE("Invalid or unsupported image file\n");
1118 return D3DXERR_INVALIDDATA;
1119 }
1120
1121 return D3D_OK;
1122}
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
@ D3DFMT_A8R8G8B8
Definition: d3d8types.h:604
@ D3DFMT_X8R8G8B8
Definition: d3d8types.h:605
static BOOL convert_dib_to_bmp(const void **data, unsigned int *size)
Definition: surface.c:899
static HRESULT get_image_info_from_dds(const void *buffer, UINT length, D3DXIMAGE_INFO *info)
Definition: surface.c:512
HRESULT WINAPI WICCreateImagingFactory_Proxy(UINT, IWICImagingFactory **)
Definition: proxy.c:651
static D3DFORMAT wic_guid_to_d3dformat(const GUID *guid)
Definition: surface.c:57
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define debugstr_guid
Definition: kernel32.h:35
static const BYTE dib[]
Definition: ole2.c:201
#define DWORD
Definition: nt_native.h:44
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
Definition: main.c:439
Definition: parse.h:23

Referenced by check_dds_pixel_format_(), D3DXCreateCubeTextureFromFileInMemoryEx(), D3DXCreateTextureFromFileInMemoryEx(), D3DXCreateVolumeTextureFromFileInMemoryEx(), D3DXGetImageInfoFromFileW(), D3DXGetImageInfoFromResourceA(), D3DXGetImageInfoFromResourceW(), D3DXLoadSurfaceFromFileInMemory(), D3DXLoadVolumeFromFileInMemory(), test_D3DXGetImageInfo(), test_D3DXSaveTextureToFileInMemory(), and test_dds_header_handling().

◆ D3DXGetImageInfoFromFileW()

HRESULT WINAPI D3DXGetImageInfoFromFileW ( const WCHAR file,
D3DXIMAGE_INFO info 
)

Definition at line 1155 of file surface.c.

1156{
1157 void *buffer;
1158 HRESULT hr;
1159 DWORD size;
1160
1161 TRACE("file %s, info %p.\n", debugstr_w(file), info);
1162
1163 if (!file)
1164 return D3DERR_INVALIDCALL;
1165
1167 return D3DXERR_INVALIDDATA;
1168
1171
1172 return hr;
1173}

Referenced by D3DXGetImageInfoFromFileA().

◆ D3DXGetImageInfoFromResourceA()

HRESULT WINAPI D3DXGetImageInfoFromResourceA ( HMODULE  module,
const char resource,
D3DXIMAGE_INFO info 
)

Definition at line 1184 of file surface.c.

1185{
1186 HRSRC resinfo;
1187 void *buffer;
1188 DWORD size;
1189
1190 TRACE("module %p, resource %s, info %p.\n", module, debugstr_a(resource), info);
1191
1192 if (!(resinfo = FindResourceA(module, resource, (const char *)RT_RCDATA))
1193 /* Try loading the resource as bitmap data (which is in DIB format D3DXIFF_DIB) */
1194 && !(resinfo = FindResourceA(module, resource, (const char *)RT_BITMAP)))
1195 return D3DXERR_INVALIDDATA;
1196
1198 return D3DXERR_INVALIDDATA;
1199
1201}

Referenced by test_D3DXGetImageInfo().

◆ D3DXGetImageInfoFromResourceW()

HRESULT WINAPI D3DXGetImageInfoFromResourceW ( HMODULE  module,
const WCHAR resource,
D3DXIMAGE_INFO info 
)

Definition at line 1203 of file surface.c.

1204{
1205 HRSRC resinfo;
1206 void *buffer;
1207 DWORD size;
1208
1209 TRACE("module %p, resource %s, info %p.\n", module, debugstr_w(resource), info);
1210
1211 if (!(resinfo = FindResourceW(module, resource, (const WCHAR *)RT_RCDATA))
1212 /* Try loading the resource as bitmap data (which is in DIB format D3DXIFF_DIB) */
1213 && !(resinfo = FindResourceW(module, resource, (const WCHAR *)RT_BITMAP)))
1214 return D3DXERR_INVALIDDATA;
1215
1217 return D3DXERR_INVALIDDATA;
1218
1220}

◆ D3DXLoadSurfaceFromFileA()

HRESULT WINAPI D3DXLoadSurfaceFromFileA ( struct IDirect3DSurface9 *  destsurface,
const PALETTEENTRY destpalette,
const RECT destrect,
const char srcfile,
const RECT srcrect,
DWORD  filter,
D3DCOLOR  colorkey,
D3DXIMAGE_INFO srcinfo 
)

Definition at line 1416 of file surface.c.

1419{
1420 WCHAR *src_file_w;
1421 HRESULT hr;
1422 int strlength;
1423
1424 TRACE("dst_surface %p, dst_palette %p, dst_rect %s, src_file %s, "
1425 "src_rect %s, filter %#x, color_key 0x%08x, src_info %p.\n",
1426 dst_surface, dst_palette, wine_dbgstr_rect(dst_rect), debugstr_a(src_file),
1427 wine_dbgstr_rect(src_rect), filter, color_key, src_info);
1428
1429 if (!src_file || !dst_surface)
1430 return D3DERR_INVALIDCALL;
1431
1432 strlength = MultiByteToWideChar(CP_ACP, 0, src_file, -1, NULL, 0);
1433 src_file_w = HeapAlloc(GetProcessHeap(), 0, strlength * sizeof(*src_file_w));
1434 MultiByteToWideChar(CP_ACP, 0, src_file, -1, src_file_w, strlength);
1435
1436 hr = D3DXLoadSurfaceFromFileW(dst_surface, dst_palette, dst_rect,
1437 src_file_w, src_rect, filter, color_key, src_info);
1438 HeapFree(GetProcessHeap(), 0, src_file_w);
1439
1440 return hr;
1441}
static const char * wine_dbgstr_rect(const RECT *prc)
Definition: atltest.h:160
HRESULT WINAPI D3DXLoadSurfaceFromFileW(IDirect3DSurface9 *dst_surface, const PALETTEENTRY *dst_palette, const RECT *dst_rect, const WCHAR *src_file, const RECT *src_rect, DWORD filter, D3DCOLOR color_key, D3DXIMAGE_INFO *src_info)
Definition: surface.c:1443

Referenced by test_D3DXLoadSurface(), and test_D3DXSaveSurfaceToFile().

◆ D3DXLoadSurfaceFromFileInMemory()

HRESULT WINAPI D3DXLoadSurfaceFromFileInMemory ( struct IDirect3DSurface9 *  destsurface,
const PALETTEENTRY destpalette,
const RECT destrect,
const void srcdata,
UINT  srcdatasize,
const RECT srcrect,
DWORD  filter,
D3DCOLOR  colorkey,
D3DXIMAGE_INFO srcinfo 
)

Definition at line 1245 of file surface.c.

1248{
1249 D3DXIMAGE_INFO imginfo;
1250 HRESULT hr;
1251
1253 IWICBitmapDecoder *decoder;
1254 IWICBitmapFrameDecode *bitmapframe;
1256
1257 const struct pixel_format_desc *formatdesc;
1258 WICRect wicrect;
1259 RECT rect;
1260
1261 TRACE("dst_surface %p, dst_palette %p, dst_rect %s, src_data %p, src_data_size %u, "
1262 "src_rect %s, filter %#x, color_key 0x%08x, src_info %p.\n",
1263 pDestSurface, pDestPalette, wine_dbgstr_rect(pDestRect), pSrcData, SrcDataSize,
1264 wine_dbgstr_rect(pSrcRect), dwFilter, Colorkey, pSrcInfo);
1265
1266 if (!pDestSurface || !pSrcData || !SrcDataSize)
1267 return D3DERR_INVALIDCALL;
1268
1269 hr = D3DXGetImageInfoFromFileInMemory(pSrcData, SrcDataSize, &imginfo);
1270
1271 if (FAILED(hr))
1272 return hr;
1273
1274 if (pSrcRect)
1275 {
1276 wicrect.X = pSrcRect->left;
1277 wicrect.Y = pSrcRect->top;
1278 wicrect.Width = pSrcRect->right - pSrcRect->left;
1279 wicrect.Height = pSrcRect->bottom - pSrcRect->top;
1280 }
1281 else
1282 {
1283 wicrect.X = 0;
1284 wicrect.Y = 0;
1285 wicrect.Width = imginfo.Width;
1286 wicrect.Height = imginfo.Height;
1287 }
1288
1289 SetRect(&rect, wicrect.X, wicrect.Y, wicrect.X + wicrect.Width, wicrect.Y + wicrect.Height);
1290
1291 if (imginfo.ImageFileFormat == D3DXIFF_DDS)
1292 {
1293 hr = load_surface_from_dds(pDestSurface, pDestPalette, pDestRect, pSrcData, &rect,
1294 dwFilter, Colorkey, &imginfo);
1295 if (SUCCEEDED(hr) && pSrcInfo)
1296 *pSrcInfo = imginfo;
1297 return hr;
1298 }
1299
1300 if (imginfo.ImageFileFormat == D3DXIFF_DIB)
1301 convert_dib_to_bmp(&pSrcData, &SrcDataSize);
1302
1303 if (FAILED(WICCreateImagingFactory_Proxy(WINCODEC_SDK_VERSION, &factory)))
1304 goto cleanup_err;
1305
1306 if (FAILED(IWICImagingFactory_CreateStream(factory, &stream)))
1307 {
1308 IWICImagingFactory_Release(factory);
1309 factory = NULL;
1310 goto cleanup_err;
1311 }
1312
1313 IWICStream_InitializeFromMemory(stream, (BYTE*)pSrcData, SrcDataSize);
1314
1315 hr = IWICImagingFactory_CreateDecoderFromStream(factory, (IStream*)stream, NULL, 0, &decoder);
1316
1317 IWICStream_Release(stream);
1318
1319 if (FAILED(hr))
1320 goto cleanup_err;
1321
1322 hr = IWICBitmapDecoder_GetFrame(decoder, 0, &bitmapframe);
1323
1324 if (FAILED(hr))
1325 goto cleanup_bmp;
1326
1327 formatdesc = get_format_info(imginfo.Format);
1328
1329 if (formatdesc->type == FORMAT_UNKNOWN)
1330 {
1331 FIXME("Unsupported pixel format\n");
1333 }
1334 else
1335 {
1336 BYTE *buffer;
1337 DWORD pitch;
1339 WICColor *colors = NULL;
1340
1341 pitch = formatdesc->bytes_per_pixel * wicrect.Width;
1342 buffer = HeapAlloc(GetProcessHeap(), 0, pitch * wicrect.Height);
1343
1344 hr = IWICBitmapFrameDecode_CopyPixels(bitmapframe, &wicrect, pitch,
1345 pitch * wicrect.Height, buffer);
1346
1347 if (SUCCEEDED(hr) && (formatdesc->type == FORMAT_INDEX))
1348 {
1349 IWICPalette *wic_palette = NULL;
1350 UINT nb_colors;
1351
1352 hr = IWICImagingFactory_CreatePalette(factory, &wic_palette);
1353 if (SUCCEEDED(hr))
1354 hr = IWICBitmapFrameDecode_CopyPalette(bitmapframe, wic_palette);
1355 if (SUCCEEDED(hr))
1356 hr = IWICPalette_GetColorCount(wic_palette, &nb_colors);
1357 if (SUCCEEDED(hr))
1358 {
1359 colors = HeapAlloc(GetProcessHeap(), 0, nb_colors * sizeof(colors[0]));
1360 palette = HeapAlloc(GetProcessHeap(), 0, nb_colors * sizeof(palette[0]));
1361 if (!colors || !palette)
1362 hr = E_OUTOFMEMORY;
1363 }
1364 if (SUCCEEDED(hr))
1365 hr = IWICPalette_GetColors(wic_palette, nb_colors, colors, &nb_colors);
1366 if (SUCCEEDED(hr))
1367 {
1368 UINT i;
1369
1370 /* Convert colors from WICColor (ARGB) to PALETTEENTRY (ABGR) */
1371 for (i = 0; i < nb_colors; i++)
1372 {
1373 palette[i].peRed = (colors[i] >> 16) & 0xff;
1374 palette[i].peGreen = (colors[i] >> 8) & 0xff;
1375 palette[i].peBlue = colors[i] & 0xff;
1376 palette[i].peFlags = (colors[i] >> 24) & 0xff; /* peFlags is the alpha component in DX8 and higher */
1377 }
1378 }
1379 if (wic_palette)
1380 IWICPalette_Release(wic_palette);
1381 }
1382
1383 if (SUCCEEDED(hr))
1384 {
1385 hr = D3DXLoadSurfaceFromMemory(pDestSurface, pDestPalette, pDestRect,
1386 buffer, imginfo.Format, pitch,
1387 palette, &rect, dwFilter, Colorkey);
1388 }
1389
1390 HeapFree(GetProcessHeap(), 0, colors);
1393 }
1394
1395 IWICBitmapFrameDecode_Release(bitmapframe);
1396
1397cleanup_bmp:
1398 IWICBitmapDecoder_Release(decoder);
1399
1400cleanup_err:
1401 if (factory)
1402 IWICImagingFactory_Release(factory);
1403
1404 if (imginfo.ImageFileFormat == D3DXIFF_DIB)
1405 HeapFree(GetProcessHeap(), 0, (void*)pSrcData);
1406
1407 if (FAILED(hr))
1408 return D3DXERR_INVALIDDATA;
1409
1410 if (pSrcInfo)
1411 *pSrcInfo = imginfo;
1412
1413 return D3D_OK;
1414}
@ FORMAT_INDEX
Definition: d3dx9_private.h:54
HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface, const PALETTEENTRY *dst_palette, const RECT *dst_rect, const void *src_memory, D3DFORMAT src_format, UINT src_pitch, const PALETTEENTRY *src_palette, const RECT *src_rect, DWORD filter, D3DCOLOR color_key)
Definition: surface.c:1963
static HRESULT load_surface_from_dds(IDirect3DSurface9 *dst_surface, const PALETTEENTRY *dst_palette, const RECT *dst_rect, const void *src_data, const RECT *src_rect, DWORD filter, D3DCOLOR color_key, const D3DXIMAGE_INFO *src_info)
Definition: surface.c:568
& rect
Definition: startmenu.cpp:1413
INT Height
Definition: wincodec.idl:301
INT Width
Definition: wincodec.idl:300
enum format_type type
Definition: d3dx9_private.h:66
#define FORMAT_UNKNOWN
Definition: trio.c:409
UINT32 WICColor
Definition: wincodec.idl:312
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)

Referenced by D3DXCreateTextureFromFileInMemoryEx(), D3DXLoadSurfaceFromFileW(), D3DXLoadSurfaceFromResourceA(), D3DXLoadSurfaceFromResourceW(), test_D3DXCreateTextureFromFileInMemory(), test_D3DXLoadSurface(), and test_D3DXSaveTextureToFileInMemory().

◆ D3DXLoadSurfaceFromFileW()

HRESULT WINAPI D3DXLoadSurfaceFromFileW ( struct IDirect3DSurface9 *  destsurface,
const PALETTEENTRY destpalette,
const RECT destrect,
const WCHAR srcfile,
const RECT srcrect,
DWORD  filter,
D3DCOLOR  colorkey,
D3DXIMAGE_INFO srcinfo 
)

Definition at line 1443 of file surface.c.

1446{
1447 UINT data_size;
1448 void *data;
1449 HRESULT hr;
1450
1451 TRACE("dst_surface %p, dst_palette %p, dst_rect %s, src_file %s, "
1452 "src_rect %s, filter %#x, color_key 0x%08x, src_info %p.\n",
1453 dst_surface, dst_palette, wine_dbgstr_rect(dst_rect), debugstr_w(src_file),
1454 wine_dbgstr_rect(src_rect), filter, color_key, src_info);
1455
1456 if (!src_file || !dst_surface)
1457 return D3DERR_INVALIDCALL;
1458
1459 if (FAILED(map_view_of_file(src_file, &data, &data_size)))
1460 return D3DXERR_INVALIDDATA;
1461
1462 hr = D3DXLoadSurfaceFromFileInMemory(dst_surface, dst_palette, dst_rect,
1463 data, data_size, src_rect, filter, color_key, src_info);
1465
1466 return hr;
1467}

Referenced by D3DXLoadSurfaceFromFileA().

◆ D3DXLoadSurfaceFromMemory()

HRESULT WINAPI D3DXLoadSurfaceFromMemory ( IDirect3DSurface9 *  dst_surface,
const PALETTEENTRY dst_palette,
const RECT dst_rect,
const void src_memory,
D3DFORMAT  src_format,
UINT  src_pitch,
const PALETTEENTRY src_palette,
const RECT src_rect,
DWORD  filter,
D3DCOLOR  color_key 
)

Definition at line 1963 of file surface.c.

1967{
1968 const struct pixel_format_desc *srcformatdesc, *destformatdesc;
1969 struct volume src_size, dst_size, dst_size_aligned;
1970 RECT dst_rect_temp, dst_rect_aligned;
1971 IDirect3DSurface9 *surface;
1972 D3DSURFACE_DESC surfdesc;
1973 D3DLOCKED_RECT lockrect;
1974 HRESULT hr;
1975
1976 TRACE("(%p, %p, %s, %p, %#x, %u, %p, %s, %#x, 0x%08x)\n",
1977 dst_surface, dst_palette, wine_dbgstr_rect(dst_rect), src_memory, src_format,
1978 src_pitch, src_palette, wine_dbgstr_rect(src_rect), filter, color_key);
1979
1980 if (!dst_surface || !src_memory || !src_rect)
1981 {
1982 WARN("Invalid argument specified.\n");
1983 return D3DERR_INVALIDCALL;
1984 }
1985 if (src_format == D3DFMT_UNKNOWN
1986 || src_rect->left >= src_rect->right
1987 || src_rect->top >= src_rect->bottom)
1988 {
1989 WARN("Invalid src_format or src_rect.\n");
1990 return E_FAIL;
1991 }
1992
1993 srcformatdesc = get_format_info(src_format);
1994 if (srcformatdesc->type == FORMAT_UNKNOWN)
1995 {
1996 FIXME("Unsupported format %#x.\n", src_format);
1997 return E_NOTIMPL;
1998 }
1999
2000 src_size.width = src_rect->right - src_rect->left;
2001 src_size.height = src_rect->bottom - src_rect->top;
2002 src_size.depth = 1;
2003
2004 IDirect3DSurface9_GetDesc(dst_surface, &surfdesc);
2005 destformatdesc = get_format_info(surfdesc.Format);
2006 if (!dst_rect)
2007 {
2008 dst_rect = &dst_rect_temp;
2009 dst_rect_temp.left = 0;
2010 dst_rect_temp.top = 0;
2011 dst_rect_temp.right = surfdesc.Width;
2012 dst_rect_temp.bottom = surfdesc.Height;
2013 }
2014 else
2015 {
2016 if (dst_rect->left > dst_rect->right || dst_rect->right > surfdesc.Width
2017 || dst_rect->top > dst_rect->bottom || dst_rect->bottom > surfdesc.Height
2018 || dst_rect->left < 0 || dst_rect->top < 0)
2019 {
2020 WARN("Invalid dst_rect specified.\n");
2021 return D3DERR_INVALIDCALL;
2022 }
2023 if (dst_rect->left == dst_rect->right || dst_rect->top == dst_rect->bottom)
2024 {
2025 WARN("Empty dst_rect specified.\n");
2026 return D3D_OK;
2027 }
2028 }
2029
2030 dst_rect_aligned = *dst_rect;
2031 if (dst_rect_aligned.left & (destformatdesc->block_width - 1))
2032 dst_rect_aligned.left = dst_rect_aligned.left & ~(destformatdesc->block_width - 1);
2033 if (dst_rect_aligned.top & (destformatdesc->block_height - 1))
2034 dst_rect_aligned.top = dst_rect_aligned.top & ~(destformatdesc->block_height - 1);
2035 if (dst_rect_aligned.right & (destformatdesc->block_width - 1) && dst_rect_aligned.right != surfdesc.Width)
2036 dst_rect_aligned.right = min((dst_rect_aligned.right + destformatdesc->block_width - 1)
2037 & ~(destformatdesc->block_width - 1), surfdesc.Width);
2038 if (dst_rect_aligned.bottom & (destformatdesc->block_height - 1) && dst_rect_aligned.bottom != surfdesc.Height)
2039 dst_rect_aligned.bottom = min((dst_rect_aligned.bottom + destformatdesc->block_height - 1)
2040 & ~(destformatdesc->block_height - 1), surfdesc.Height);
2041
2042 dst_size.width = dst_rect->right - dst_rect->left;
2043 dst_size.height = dst_rect->bottom - dst_rect->top;
2044 dst_size.depth = 1;
2045 dst_size_aligned.width = dst_rect_aligned.right - dst_rect_aligned.left;
2046 dst_size_aligned.height = dst_rect_aligned.bottom - dst_rect_aligned.top;
2047 dst_size_aligned.depth = 1;
2048
2049 if (filter == D3DX_DEFAULT)
2051
2052 if (FAILED(hr = lock_surface(dst_surface, &dst_rect_aligned, &lockrect, &surface, TRUE)))
2053 return hr;
2054
2055 src_memory = (BYTE *)src_memory + src_rect->top / srcformatdesc->block_height * src_pitch
2056 + src_rect->left / srcformatdesc->block_width * srcformatdesc->block_byte_count;
2057
2058 if (src_format == surfdesc.Format
2059 && dst_size.width == src_size.width
2060 && dst_size.height == src_size.height
2061 && color_key == 0
2062 && !(src_rect->left & (srcformatdesc->block_width - 1))
2063 && !(src_rect->top & (srcformatdesc->block_height - 1))
2064 && !(dst_rect->left & (destformatdesc->block_width - 1))
2065 && !(dst_rect->top & (destformatdesc->block_height - 1)))
2066 {
2067 TRACE("Simple copy.\n");
2068 copy_pixels(src_memory, src_pitch, 0, lockrect.pBits, lockrect.Pitch, 0,
2069 &src_size, srcformatdesc);
2070 }
2071 else /* Stretching or format conversion. */
2072 {
2073 const struct pixel_format_desc *dst_format;
2074 DWORD *src_uncompressed = NULL;
2075 BYTE *dst_uncompressed = NULL;
2076 unsigned int dst_pitch;
2077 BYTE *dst_mem;
2078
2079 if (!is_conversion_from_supported(srcformatdesc)
2080 || !is_conversion_to_supported(destformatdesc))
2081 {
2082 FIXME("Unsupported format conversion %#x -> %#x.\n", src_format, surfdesc.Format);
2083 unlock_surface(dst_surface, &dst_rect_aligned, surface, FALSE);
2084 return E_NOTIMPL;
2085 }
2086
2087 if (srcformatdesc->type == FORMAT_DXT)
2088 {
2089 void (*fetch_dxt_texel)(int srcRowStride, const BYTE *pixdata,
2090 int i, int j, void *texel);
2091 unsigned int x, y;
2092
2093 src_pitch = src_pitch * srcformatdesc->block_width / srcformatdesc->block_byte_count;
2094
2095 src_uncompressed = heap_alloc(src_size.width * src_size.height * sizeof(DWORD));
2096 if (!src_uncompressed)
2097 {
2098 unlock_surface(dst_surface, &dst_rect_aligned, surface, FALSE);
2099 return E_OUTOFMEMORY;
2100 }
2101
2102 switch(src_format)
2103 {
2104 case D3DFMT_DXT1:
2105 fetch_dxt_texel = fetch_2d_texel_rgba_dxt1;
2106 break;
2107 case D3DFMT_DXT2:
2108 case D3DFMT_DXT3:
2109 fetch_dxt_texel = fetch_2d_texel_rgba_dxt3;
2110 break;
2111 case D3DFMT_DXT4:
2112 case D3DFMT_DXT5:
2113 fetch_dxt_texel = fetch_2d_texel_rgba_dxt5;
2114 break;
2115 default:
2116 FIXME("Unexpected compressed texture format %u.\n", src_format);
2117 fetch_dxt_texel = NULL;
2118 }
2119
2120 TRACE("Uncompressing DXTn surface.\n");
2121 for (y = 0; y < src_size.height; ++y)
2122 {
2123 DWORD *ptr = &src_uncompressed[y * src_size.width];
2124 for (x = 0; x < src_size.width; ++x)
2125 {
2126 fetch_dxt_texel(src_pitch, src_memory, x + src_rect->left, y + src_rect->top, ptr);
2127 ++ptr;
2128 }
2129 }
2130 src_memory = src_uncompressed;
2131 src_pitch = src_size.width * sizeof(DWORD);
2132 srcformatdesc = get_format_info(D3DFMT_A8B8G8R8);
2133 }
2134
2135 if (destformatdesc->type == FORMAT_DXT)
2136 {
2137 BOOL dst_misaligned = dst_rect->left != dst_rect_aligned.left
2138 || dst_rect->top != dst_rect_aligned.top
2139 || dst_rect->right != dst_rect_aligned.right
2140 || dst_rect->bottom != dst_rect_aligned.bottom;
2141
2142 dst_uncompressed = HeapAlloc(GetProcessHeap(), dst_misaligned ? HEAP_ZERO_MEMORY : 0,
2143 dst_size_aligned.width * dst_size_aligned.height * sizeof(DWORD));
2144 if (!dst_uncompressed)
2145 {
2146 heap_free(src_uncompressed);
2147 unlock_surface(dst_surface, &dst_rect_aligned, surface, FALSE);
2148 return E_OUTOFMEMORY;
2149 }
2150 dst_pitch = dst_size_aligned.width * sizeof(DWORD);
2152 dst_mem = dst_uncompressed + (dst_rect->top - dst_rect_aligned.top) * dst_pitch
2153 + (dst_rect->left - dst_rect_aligned.left) * sizeof(DWORD);
2154 }
2155 else
2156 {
2157 dst_mem = lockrect.pBits;
2158 dst_pitch = lockrect.Pitch;
2159 dst_format = destformatdesc;
2160 }
2161
2162 if ((filter & 0xf) == D3DX_FILTER_NONE)
2163 {
2164 convert_argb_pixels(src_memory, src_pitch, 0, &src_size, srcformatdesc,
2165 dst_mem, dst_pitch, 0, &dst_size, dst_format, color_key, src_palette);
2166 }
2167 else /* if ((filter & 0xf) == D3DX_FILTER_POINT) */
2168 {
2169 if ((filter & 0xf) != D3DX_FILTER_POINT)
2170 FIXME("Unhandled filter %#x.\n", filter);
2171
2172 /* Always apply a point filter until D3DX_FILTER_LINEAR,
2173 * D3DX_FILTER_TRIANGLE and D3DX_FILTER_BOX are implemented. */
2174 point_filter_argb_pixels(src_memory, src_pitch, 0, &src_size, srcformatdesc,
2175 dst_mem, dst_pitch, 0, &dst_size, dst_format, color_key, src_palette);
2176 }
2177
2178 heap_free(src_uncompressed);
2179
2180 if (dst_uncompressed)
2181 {
2182 GLenum gl_format = 0;
2183
2184 TRACE("Compressing DXTn surface.\n");
2185 switch(surfdesc.Format)
2186 {
2187 case D3DFMT_DXT1:
2189 break;
2190 case D3DFMT_DXT2:
2191 case D3DFMT_DXT3:
2193 break;
2194 case D3DFMT_DXT4:
2195 case D3DFMT_DXT5:
2197 break;
2198 default:
2199 ERR("Unexpected destination compressed format %u.\n", surfdesc.Format);
2200 }
2201 tx_compress_dxtn(4, dst_size_aligned.width, dst_size_aligned.height,
2202 dst_uncompressed, gl_format, lockrect.pBits,
2203 lockrect.Pitch * destformatdesc->block_width / destformatdesc->block_byte_count);
2204 heap_free(dst_uncompressed);
2205 }
2206 }
2207
2208 return unlock_surface(dst_surface, &dst_rect_aligned, surface, TRUE);
2209}
void tx_compress_dxtn(GLint srccomps, GLint width, GLint height, const GLubyte *srcPixData, GLenum destFormat, GLubyte *dest, GLint dstRowStride)
void fetch_2d_texel_rgba_dxt3(GLint srcRowStride, const GLubyte *pixdata, GLint i, GLint j, GLvoid *texel)
void fetch_2d_texel_rgba_dxt1(GLint srcRowStride, const GLubyte *pixdata, GLint i, GLint j, GLvoid *texel)
void fetch_2d_texel_rgba_dxt5(GLint srcRowStride, const GLubyte *pixdata, GLint i, GLint j, GLvoid *texel)
static void * heap_alloc(size_t len)
Definition: appwiz.h:66
static BOOL heap_free(void *mem)
Definition: appwiz.h:76
#define ERR(fmt,...)
Definition: debug.h:113
@ D3DFMT_DXT2
Definition: d3d8types.h:635
@ D3DFMT_DXT4
Definition: d3d8types.h:637
@ D3DFMT_DXT3
Definition: d3d8types.h:636
#define IDirect3DSurface9_GetDesc(p, a)
Definition: d3d9.h:634
@ D3DFMT_A8B8G8R8
Definition: d3d9types.h:776
static BOOL is_conversion_to_supported(const struct pixel_format_desc *format)
Definition: d3dx9_private.h:87
@ FORMAT_DXT
Definition: d3dx9_private.h:53
static BOOL is_conversion_from_supported(const struct pixel_format_desc *format)
Definition: d3dx9_private.h:79
#define D3DX_FILTER_TRIANGLE
Definition: d3dx9tex.h:30
#define D3DX_FILTER_POINT
Definition: d3dx9tex.h:28
#define D3DX_FILTER_NONE
Definition: d3dx9tex.h:27
#define E_FAIL
Definition: ddrawi.h:102
HRESULT unlock_surface(IDirect3DSurface9 *surface, const RECT *surface_rect, IDirect3DSurface9 *temp_surface, BOOL update)
Definition: surface.c:267
HRESULT lock_surface(IDirect3DSurface9 *surface, const RECT *surface_rect, D3DLOCKED_RECT *lock, IDirect3DSurface9 **temp_surface, BOOL write)
Definition: surface.c:209
void convert_argb_pixels(const BYTE *src, UINT src_row_pitch, UINT src_slice_pitch, const struct volume *src_size, const struct pixel_format_desc *src_format, BYTE *dst, UINT dst_row_pitch, UINT dst_slice_pitch, const struct volume *dst_size, const struct pixel_format_desc *dst_format, D3DCOLOR color_key, const PALETTEENTRY *palette)
Definition: surface.c:1731
void copy_pixels(const BYTE *src, UINT src_row_pitch, UINT src_slice_pitch, BYTE *dst, UINT dst_row_pitch, UINT dst_slice_pitch, const struct volume *size, const struct pixel_format_desc *format)
Definition: surface.c:1700
void point_filter_argb_pixels(const BYTE *src, UINT src_row_pitch, UINT src_slice_pitch, const struct volume *src_size, const struct pixel_format_desc *src_format, BYTE *dst, UINT dst_row_pitch, UINT dst_slice_pitch, const struct volume *dst_size, const struct pixel_format_desc *dst_format, D3DCOLOR color_key, const PALETTEENTRY *palette)
Definition: surface.c:1839
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
unsigned int GLenum
Definition: gl.h:150
#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT
Definition: glext.h:3492
#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT
Definition: glext.h:3491
#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT
Definition: glext.h:3490
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
if(dx< 0)
Definition: linetemp.h:194
static PVOID ptr
Definition: dispmode.c:27
static const unsigned char pixdata[]
Definition: surface.c:101
static const char * dst_format
Definition: dib.c:1133
D3DFORMAT Format
Definition: d3d8types.h:1170
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306

Referenced by D3DXLoadSurfaceFromFileInMemory(), D3DXLoadSurfaceFromSurface(), load_cube_texture_from_dds(), load_surface_from_dds(), load_texture_from_dds(), test_D3DXCreateTextureFromFileInMemory(), test_D3DXLoadSurface(), and test_D3DXSaveSurfaceToFile().

◆ D3DXLoadSurfaceFromResourceA()

HRESULT WINAPI D3DXLoadSurfaceFromResourceA ( struct IDirect3DSurface9 *  destsurface,
const PALETTEENTRY destpalette,
const RECT destrect,
HMODULE  srcmodule,
const char resource,
const RECT srcrect,
DWORD  filter,
D3DCOLOR  colorkey,
D3DXIMAGE_INFO srcinfo 
)

Definition at line 1469 of file surface.c.

1472{
1473 UINT data_size;
1474 HRSRC resinfo;
1475 void *data;
1476
1477 TRACE("dst_surface %p, dst_palette %p, dst_rect %s, src_module %p, resource %s, "
1478 "src_rect %s, filter %#x, color_key 0x%08x, src_info %p.\n",
1479 dst_surface, dst_palette, wine_dbgstr_rect(dst_rect), src_module, debugstr_a(resource),
1480 wine_dbgstr_rect(src_rect), filter, color_key, src_info);
1481
1482 if (!dst_surface)
1483 return D3DERR_INVALIDCALL;
1484
1485 if (!(resinfo = FindResourceA(src_module, resource, (const char *)RT_RCDATA))
1486 /* Try loading the resource as bitmap data (which is in DIB format D3DXIFF_DIB) */
1487 && !(resinfo = FindResourceA(src_module, resource, (const char *)RT_BITMAP)))
1488 return D3DXERR_INVALIDDATA;
1489
1490 if (FAILED(load_resource_into_memory(src_module, resinfo, &data, &data_size)))
1491 return D3DXERR_INVALIDDATA;
1492
1493 return D3DXLoadSurfaceFromFileInMemory(dst_surface, dst_palette, dst_rect,
1494 data, data_size, src_rect, filter, color_key, src_info);
1495}

Referenced by test_D3DXLoadSurface().

◆ D3DXLoadSurfaceFromResourceW()

HRESULT WINAPI D3DXLoadSurfaceFromResourceW ( struct IDirect3DSurface9 *  destsurface,
const PALETTEENTRY destpalette,
const RECT destrect,
HMODULE  srcmodule,
const WCHAR resource,
const RECT srcrect,
DWORD  filter,
D3DCOLOR  colorkey,
D3DXIMAGE_INFO srcinfo 
)

Definition at line 1497 of file surface.c.

1500{
1501 UINT data_size;
1502 HRSRC resinfo;
1503 void *data;
1504
1505 TRACE("dst_surface %p, dst_palette %p, dst_rect %s, src_module %p, resource %s, "
1506 "src_rect %s, filter %#x, color_key 0x%08x, src_info %p.\n",
1507 dst_surface, dst_palette, wine_dbgstr_rect(dst_rect), src_module, debugstr_w(resource),
1508 wine_dbgstr_rect(src_rect), filter, color_key, src_info);
1509
1510 if (!dst_surface)
1511 return D3DERR_INVALIDCALL;
1512
1513 if (!(resinfo = FindResourceW(src_module, resource, (const WCHAR *)RT_RCDATA))
1514 /* Try loading the resource as bitmap data (which is in DIB format D3DXIFF_DIB) */
1515 && !(resinfo = FindResourceW(src_module, resource, (const WCHAR *)RT_BITMAP)))
1516 return D3DXERR_INVALIDDATA;
1517
1518 if (FAILED(load_resource_into_memory(src_module, resinfo, &data, &data_size)))
1519 return D3DXERR_INVALIDDATA;
1520
1521 return D3DXLoadSurfaceFromFileInMemory(dst_surface, dst_palette, dst_rect,
1522 data, data_size, src_rect, filter, color_key, src_info);
1523}

◆ D3DXLoadSurfaceFromSurface()

HRESULT WINAPI D3DXLoadSurfaceFromSurface ( struct IDirect3DSurface9 *  destsurface,
const PALETTEENTRY destpalette,
const RECT destrect,
struct IDirect3DSurface9 *  srcsurface,
const PALETTEENTRY srcpalette,
const RECT srcrect,
DWORD  filter,
D3DCOLOR  colorkey 
)

Definition at line 2233 of file surface.c.

2236{
2237 const struct pixel_format_desc *src_format_desc, *dst_format_desc;
2238 D3DSURFACE_DESC src_desc, dst_desc;
2239 struct volume src_size, dst_size;
2240 IDirect3DSurface9 *temp_surface;
2241 D3DTEXTUREFILTERTYPE d3d_filter;
2242 IDirect3DDevice9 *device;
2244 RECT dst_rect_temp;
2245 HRESULT hr;
2246 RECT s;
2247
2248 TRACE("dst_surface %p, dst_palette %p, dst_rect %s, src_surface %p, "
2249 "src_palette %p, src_rect %s, filter %#x, color_key 0x%08x.\n",
2250 dst_surface, dst_palette, wine_dbgstr_rect(dst_rect), src_surface,
2251 src_palette, wine_dbgstr_rect(src_rect), filter, color_key);
2252
2253 if (!dst_surface || !src_surface)
2254 return D3DERR_INVALIDCALL;
2255
2256 IDirect3DSurface9_GetDesc(src_surface, &src_desc);
2257 src_format_desc = get_format_info(src_desc.Format);
2258 if (!src_rect)
2259 {
2260 SetRect(&s, 0, 0, src_desc.Width, src_desc.Height);
2261 src_rect = &s;
2262 }
2263 else if (src_rect->left == src_rect->right || src_rect->top == src_rect->bottom)
2264 {
2265 WARN("Empty src_rect specified.\n");
2266 return filter == D3DX_FILTER_NONE ? D3D_OK : E_FAIL;
2267 }
2268 else if (src_rect->left > src_rect->right || src_rect->right > src_desc.Width
2269 || src_rect->left < 0 || src_rect->left > src_desc.Width
2270 || src_rect->top > src_rect->bottom || src_rect->bottom > src_desc.Height
2271 || src_rect->top < 0 || src_rect->top > src_desc.Height)
2272 {
2273 WARN("Invalid src_rect specified.\n");
2274 return D3DERR_INVALIDCALL;
2275 }
2276
2277 src_size.width = src_rect->right - src_rect->left;
2278 src_size.height = src_rect->bottom - src_rect->top;
2279 src_size.depth = 1;
2280
2281 IDirect3DSurface9_GetDesc(dst_surface, &dst_desc);
2282 dst_format_desc = get_format_info(dst_desc.Format);
2283 if (!dst_rect)
2284 {
2285 SetRect(&dst_rect_temp, 0, 0, dst_desc.Width, dst_desc.Height);
2286 dst_rect = &dst_rect_temp;
2287 }
2288 else if (dst_rect->left == dst_rect->right || dst_rect->top == dst_rect->bottom)
2289 {
2290 WARN("Empty dst_rect specified.\n");
2291 return filter == D3DX_FILTER_NONE ? D3D_OK : E_FAIL;
2292 }
2293 else if (dst_rect->left > dst_rect->right || dst_rect->right > dst_desc.Width
2294 || dst_rect->left < 0 || dst_rect->left > dst_desc.Width
2295 || dst_rect->top > dst_rect->bottom || dst_rect->bottom > dst_desc.Height
2296 || dst_rect->top < 0 || dst_rect->top > dst_desc.Height)
2297 {
2298 WARN("Invalid dst_rect specified.\n");
2299 return D3DERR_INVALIDCALL;
2300 }
2301
2302 dst_size.width = dst_rect->right - dst_rect->left;
2303 dst_size.height = dst_rect->bottom - dst_rect->top;
2304 dst_size.depth = 1;
2305
2306 if (!dst_palette && !src_palette && !color_key)
2307 {
2308 if (src_desc.Format == dst_desc.Format
2309 && dst_size.width == src_size.width
2310 && dst_size.height == src_size.height
2311 && color_key == 0
2312 && !(src_rect->left & (src_format_desc->block_width - 1))
2313 && !(src_rect->top & (src_format_desc->block_height - 1))
2314 && !(dst_rect->left & (dst_format_desc->block_width - 1))
2315 && !(dst_rect->top & (dst_format_desc->block_height - 1)))
2316 {
2317 d3d_filter = D3DTEXF_NONE;
2318 }
2319 else
2320 {
2321 switch (filter)
2322 {
2323 case D3DX_FILTER_NONE:
2324 d3d_filter = D3DTEXF_NONE;
2325 break;
2326
2327 case D3DX_FILTER_POINT:
2328 d3d_filter = D3DTEXF_POINT;
2329 break;
2330
2331 case D3DX_FILTER_LINEAR:
2332 d3d_filter = D3DTEXF_LINEAR;
2333 break;
2334
2335 default:
2336 d3d_filter = D3DTEXF_FORCE_DWORD;
2337 break;
2338 }
2339 }
2340
2341 if (d3d_filter != D3DTEXF_FORCE_DWORD)
2342 {
2343 IDirect3DSurface9_GetDevice(src_surface, &device);
2344 hr = IDirect3DDevice9_StretchRect(device, src_surface, src_rect, dst_surface, dst_rect, d3d_filter);
2346 if (SUCCEEDED(hr))
2347 return D3D_OK;
2348 }
2349 }
2350
2351 if (FAILED(lock_surface(src_surface, NULL, &lock, &temp_surface, FALSE)))
2352 return D3DXERR_INVALIDDATA;
2353
2354 hr = D3DXLoadSurfaceFromMemory(dst_surface, dst_palette, dst_rect, lock.pBits,
2355 src_desc.Format, lock.Pitch, src_palette, src_rect, filter, color_key);
2356
2357 if (FAILED(unlock_surface(src_surface, NULL, temp_surface, FALSE)))
2358 return D3DXERR_INVALIDDATA;
2359
2360 return hr;
2361}
@ D3DTEXF_POINT
Definition: d3d8types.h:871
@ D3DTEXF_NONE
Definition: d3d8types.h:870
@ D3DTEXF_LINEAR
Definition: d3d8types.h:872
@ D3DTEXF_FORCE_DWORD
Definition: d3d8types.h:877
enum _D3DTEXTUREFILTERTYPE D3DTEXTUREFILTERTYPE
#define IDirect3DSurface9_GetDevice(p, a)
Definition: d3d9.h:624
#define IDirect3DDevice9_StretchRect(p, a, b, c, d, e)
Definition: d3d9.h:1541
#define IDirect3DDevice9_Release(p)
Definition: d3d9.h:1508
#define D3DX_FILTER_LINEAR
Definition: d3dx9tex.h:29
rwlock_t lock
Definition: tcpcore.h:0

Referenced by copy_render_target_to_cube_texture_face(), D3DXFilterTexture(), D3DXRenderToSurface_EndScene(), test_D3DXCreateTextureFromFileInMemory(), and test_D3DXLoadSurface().

◆ D3DXLoadVolumeFromFileA()

HRESULT WINAPI D3DXLoadVolumeFromFileA ( struct IDirect3DVolume9 *  destvolume,
const PALETTEENTRY destpalette,
const D3DBOX destbox,
const char srcfile,
const D3DBOX srcbox,
DWORD  filter,
D3DCOLOR  colorkey,
D3DXIMAGE_INFO srcinfo 
)

Definition at line 28 of file volume.c.

36{
37 HRESULT hr;
38 int length;
40
41 TRACE("(%p, %p, %p, %s, %p, %#x, %#x, %p)\n",
42 dst_volume, dst_palette, dst_box, debugstr_a(filename), src_box,
44
45 if (!dst_volume || !filename) return D3DERR_INVALIDCALL;
46
49 if (!filenameW) return E_OUTOFMEMORY;
50
51 hr = D3DXLoadVolumeFromFileW(dst_volume, dst_palette, dst_box, filenameW,
52 src_box, filter, color_key, info);
54
55 return hr;
56}
HRESULT WINAPI D3DXLoadVolumeFromFileW(IDirect3DVolume9 *dst_volume, const PALETTEENTRY *dst_palette, const D3DBOX *dst_box, const WCHAR *filename, const D3DBOX *src_box, DWORD filter, D3DCOLOR color_key, D3DXIMAGE_INFO *info)
Definition: volume.c:58
GLuint GLsizei GLsizei * length
Definition: glext.h:6040

◆ D3DXLoadVolumeFromFileInMemory()

HRESULT WINAPI D3DXLoadVolumeFromFileInMemory ( struct IDirect3DVolume9 *  destvolume,
const PALETTEENTRY destpalette,
const D3DBOX destbox,
const void srcdata,
UINT  srcdatasize,
const D3DBOX srcbox,
DWORD  filter,
D3DCOLOR  colorkey,
D3DXIMAGE_INFO srcinfo 
)

Definition at line 230 of file volume.c.

239{
240 HRESULT hr;
241 D3DBOX box;
242 D3DXIMAGE_INFO image_info;
243
244 TRACE("dst_volume %p, dst_palette %p, dst_box %p, src_data %p, src_data_size %u, src_box %p, "
245 "filter %#x, color_key 0x%08x, src_info %p.\n",
246 dst_volume, dst_palette, dst_box, src_data, src_data_size, src_box,
247 filter, color_key, src_info);
248
249 if (!dst_volume || !src_data)
250 return D3DERR_INVALIDCALL;
251
252 if (FAILED(hr = D3DXGetImageInfoFromFileInMemory(src_data, src_data_size, &image_info)))
253 return hr;
254
255 if (src_box)
256 {
257 if (src_box->Right > image_info.Width
258 || src_box->Bottom > image_info.Height
259 || src_box->Back > image_info.Depth)
260 return D3DERR_INVALIDCALL;
261
262 box = *src_box;
263 }
264 else
265 {
266 box.Left = 0;
267 box.Top = 0;
268 box.Right = image_info.Width;
269 box.Bottom = image_info.Height;
270 box.Front = 0;
271 box.Back = image_info.Depth;
272
273 }
274
275 if (image_info.ImageFileFormat != D3DXIFF_DDS)
276 {
277 FIXME("File format %#x is not supported yet\n", image_info.ImageFileFormat);
278 return E_NOTIMPL;
279 }
280
281 hr = load_volume_from_dds(dst_volume, dst_palette, dst_box, src_data, &box,
282 filter, color_key, &image_info);
283 if (FAILED(hr)) return hr;
284
285 if (src_info)
286 *src_info = image_info;
287
288 return D3D_OK;
289}
HRESULT load_volume_from_dds(IDirect3DVolume9 *dst_volume, const PALETTEENTRY *dst_palette, const D3DBOX *dst_box, const void *src_data, const D3DBOX *src_box, DWORD filter, D3DCOLOR color_key, const D3DXIMAGE_INFO *src_info) DECLSPEC_HIDDEN
Definition: surface.c:719
Definition: palette.c:468

Referenced by D3DXLoadVolumeFromFileW(), and test_D3DXLoadVolumeFromFileInMemory().

◆ D3DXLoadVolumeFromFileW()

HRESULT WINAPI D3DXLoadVolumeFromFileW ( struct IDirect3DVolume9 *  destvolume,
const PALETTEENTRY destpalette,
const D3DBOX destbox,
const WCHAR srcfile,
const D3DBOX srcbox,
DWORD  filter,
D3DCOLOR  colorkey,
D3DXIMAGE_INFO srcinfo 
)

Definition at line 58 of file volume.c.

66{
67 HRESULT hr;
68 void *data;
69 UINT data_size;
70
71 TRACE("(%p, %p, %p, %s, %p, %#x, %#x, %p)\n",
72 dst_volume, dst_palette, dst_box, debugstr_w(filename), src_box,
74
75 if (!dst_volume || !filename) return D3DERR_INVALIDCALL;
76
77 if (FAILED(map_view_of_file(filename, &data, &data_size)))
79
80 hr = D3DXLoadVolumeFromFileInMemory(dst_volume, dst_palette, dst_box,
81 data, data_size, src_box, filter, color_key, info);
83
84 return hr;
85}
HRESULT WINAPI D3DXLoadVolumeFromFileInMemory(IDirect3DVolume9 *dst_volume, const PALETTEENTRY *dst_palette, const D3DBOX *dst_box, const void *src_data, UINT src_data_size, const D3DBOX *src_box, DWORD filter, D3DCOLOR color_key, D3DXIMAGE_INFO *src_info)
Definition: volume.c:230

Referenced by D3DXLoadVolumeFromFileA().

◆ D3DXLoadVolumeFromMemory()

HRESULT WINAPI D3DXLoadVolumeFromMemory ( struct IDirect3DVolume9 *  destvolume,
const PALETTEENTRY destpalette,
const D3DBOX destbox,
const void srcmemory,
D3DFORMAT  srcformat,
UINT  srcrowpitch,
UINT  srcslicepitch,
const PALETTEENTRY srcpalette,
const D3DBOX srcbox,
DWORD  filter,
D3DCOLOR  colorkey 
)

Definition at line 87 of file volume.c.

98{
99 HRESULT hr;
101 D3DLOCKED_BOX locked_box;
102 struct volume dst_size, src_size;
103 const struct pixel_format_desc *src_format_desc, *dst_format_desc;
104
105 TRACE("(%p, %p, %p, %p, %#x, %u, %u, %p, %p, %x, %x)\n", dst_volume, dst_palette, dst_box,
106 src_memory, src_format, src_row_pitch, src_slice_pitch, src_palette, src_box,
108
109 if (!dst_volume || !src_memory || !src_box) return D3DERR_INVALIDCALL;
110
111 if (src_format == D3DFMT_UNKNOWN
112 || src_box->Left >= src_box->Right
113 || src_box->Top >= src_box->Bottom
114 || src_box->Front >= src_box->Back)
115 return E_FAIL;
116
117 if (filter == D3DX_DEFAULT)
119
120 IDirect3DVolume9_GetDesc(dst_volume, &desc);
121
122 src_size.width = src_box->Right - src_box->Left;
123 src_size.height = src_box->Bottom - src_box->Top;
124 src_size.depth = src_box->Back - src_box->Front;
125
126 if (!dst_box)
127 {
128 dst_size.width = desc.Width;
129 dst_size.height = desc.Height;
130 dst_size.depth = desc.Depth;
131 }
132 else
133 {
134 if (dst_box->Left >= dst_box->Right || dst_box->Right > desc.Width)
135 return D3DERR_INVALIDCALL;
136 if (dst_box->Top >= dst_box->Bottom || dst_box->Bottom > desc.Height)
137 return D3DERR_INVALIDCALL;
138 if (dst_box->Front >= dst_box->Back || dst_box->Back > desc.Depth)
139 return D3DERR_INVALIDCALL;
140
141 dst_size.width = dst_box->Right - dst_box->Left;
142 dst_size.height = dst_box->Bottom - dst_box->Top;
143 dst_size.depth = dst_box->Back - dst_box->Front;
144 }
145
146 src_format_desc = get_format_info(src_format);
147 if (src_format_desc->type == FORMAT_UNKNOWN)
148 return E_NOTIMPL;
149
150 dst_format_desc = get_format_info(desc.Format);
151 if (dst_format_desc->type == FORMAT_UNKNOWN)
152 return E_NOTIMPL;
153
154 if (desc.Format == src_format
155 && dst_size.width == src_size.width
156 && dst_size.height == src_size.height
157 && dst_size.depth == src_size.depth
158 && color_key == 0)
159 {
160 const BYTE *src_addr;
161
162 if (src_box->Left & (src_format_desc->block_width - 1)
163 || src_box->Top & (src_format_desc->block_height - 1)
164 || (src_box->Right & (src_format_desc->block_width - 1)
165 && src_size.width != desc.Width)
166 || (src_box->Bottom & (src_format_desc->block_height - 1)
167 && src_size.height != desc.Height))
168 {
169 FIXME("Source box (%u, %u, %u, %u) is misaligned\n",
170 src_box->Left, src_box->Top, src_box->Right, src_box->Bottom);
171 return E_NOTIMPL;
172 }
173
174 src_addr = src_memory;
175 src_addr += src_box->Front * src_slice_pitch;
176 src_addr += (src_box->Top / src_format_desc->block_height) * src_row_pitch;
177 src_addr += (src_box->Left / src_format_desc->block_width) * src_format_desc->block_byte_count;
178
179 hr = IDirect3DVolume9_LockBox(dst_volume, &locked_box, dst_box, 0);
180 if (FAILED(hr)) return hr;
181
182 copy_pixels(src_addr, src_row_pitch, src_slice_pitch,
183 locked_box.pBits, locked_box.RowPitch, locked_box.SlicePitch,
184 &dst_size, dst_format_desc);
185
186 IDirect3DVolume9_UnlockBox(dst_volume);
187 }
188 else
189 {
190 const BYTE *src_addr;
191
192 if (!is_conversion_from_supported(src_format_desc)
193 || !is_conversion_to_supported(dst_format_desc))
194 {
195 FIXME("Pixel format conversion is not implemented %#x -> %#x\n",
196 src_format_desc->format, dst_format_desc->format);
197 return E_NOTIMPL;
198 }
199
200 src_addr = src_memory;
201 src_addr += src_box->Front * src_slice_pitch;
202 src_addr += src_box->Top * src_row_pitch;
203 src_addr += src_box->Left * src_format_desc->bytes_per_pixel;
204
205 hr = IDirect3DVolume9_LockBox(dst_volume, &locked_box, dst_box, 0);
206 if (FAILED(hr)) return hr;
207
208 if ((filter & 0xf) == D3DX_FILTER_NONE)
209 {
210 convert_argb_pixels(src_memory, src_row_pitch, src_slice_pitch, &src_size, src_format_desc,
211 locked_box.pBits, locked_box.RowPitch, locked_box.SlicePitch, &dst_size, dst_format_desc, color_key,
212 src_palette);
213 }
214 else
215 {
216 if ((filter & 0xf) != D3DX_FILTER_POINT)
217 FIXME("Unhandled filter %#x.\n", filter);
218
219 point_filter_argb_pixels(src_addr, src_row_pitch, src_slice_pitch, &src_size, src_format_desc,
220 locked_box.pBits, locked_box.RowPitch, locked_box.SlicePitch, &dst_size, dst_format_desc, color_key,
221 src_palette);
222 }
223
224 IDirect3DVolume9_UnlockBox(dst_volume);
225 }
226
227 return D3D_OK;
228}
#define IDirect3DVolume9_UnlockBox(p)
Definition: d3d9.h:392
#define IDirect3DVolume9_LockBox(p, a, b, c)
Definition: d3d9.h:391
#define IDirect3DVolume9_GetDesc(p, a)
Definition: d3d9.h:390
void copy_pixels(const BYTE *src, UINT src_row_pitch, UINT src_slice_pitch, BYTE *dst, UINT dst_row_pitch, UINT dst_slice_pitch, const struct volume *size, const struct pixel_format_desc *format) DECLSPEC_HIDDEN
Definition: surface.c:1700
void point_filter_argb_pixels(const BYTE *src, UINT src_row_pitch, UINT src_slice_pitch, const struct volume *src_size, const struct pixel_format_desc *src_format, BYTE *dst, UINT dst_row_pitch, UINT dst_slice_pitch, const struct volume *dst_size, const struct pixel_format_desc *dst_format, D3DCOLOR color_key, const PALETTEENTRY *palette) DECLSPEC_HIDDEN
Definition: surface.c:1839
void convert_argb_pixels(const BYTE *src, UINT src_row_pitch, UINT src_slice_pitch, const struct volume *src_size, const struct pixel_format_desc *src_format, BYTE *dst, UINT dst_row_pitch, UINT dst_slice_pitch, const struct volume *dst_size, const struct pixel_format_desc *dst_format, D3DCOLOR color_key, const PALETTEENTRY *palette) DECLSPEC_HIDDEN
Definition: surface.c:1731

Referenced by D3DXLoadVolumeFromVolume(), load_volume_from_dds(), load_volume_texture_from_dds(), and test_D3DXLoadVolumeFromMemory().

◆ D3DXLoadVolumeFromResourceA()

HRESULT WINAPI D3DXLoadVolumeFromResourceA ( struct IDirect3DVolume9 *  destvolume,
const PALETTEENTRY destpalette,
const D3DBOX destbox,
HMODULE  srcmodule,
const char resource,
const D3DBOX srcbox,
DWORD  filter,
D3DCOLOR  colorkey,
D3DXIMAGE_INFO srcinfo 
)

◆ D3DXLoadVolumeFromResourceW()

HRESULT WINAPI D3DXLoadVolumeFromResourceW ( struct IDirect3DVolume9 *  destvolume,
const PALETTEENTRY destpalette,
const D3DBOX destbox,
HMODULE  srcmodule,
const WCHAR resource,
const D3DBOX srcbox,
DWORD  filter,
D3DCOLOR  colorkey,
D3DXIMAGE_INFO srcinfo 
)

◆ D3DXLoadVolumeFromVolume()

HRESULT WINAPI D3DXLoadVolumeFromVolume ( struct IDirect3DVolume9 *  destvolume,
const PALETTEENTRY destpalette,
const D3DBOX destbox,
struct IDirect3DVolume9 *  srcvolume,
const PALETTEENTRY srcpalette,
const D3DBOX srcbox,
DWORD  filter,
D3DCOLOR  colorkey 
)

Definition at line 291 of file volume.c.

299{
300 HRESULT hr;
301 D3DBOX box;
303 D3DLOCKED_BOX locked_box;
304
305 TRACE("(%p, %p, %p, %p, %p, %p, %#x, %#x)\n",
306 dst_volume, dst_palette, dst_box, src_volume, src_palette, src_box,
308
309 if (!dst_volume || !src_volume) return D3DERR_INVALIDCALL;
310
311 IDirect3DVolume9_GetDesc(src_volume, &desc);
312
313 if (!src_box)
314 {
315 box.Left = box.Top = 0;
316 box.Right = desc.Width;
317 box.Bottom = desc.Height;
318 box.Front = 0;
319 box.Back = desc.Depth;
320 }
321 else box = *src_box;
322
323 hr = IDirect3DVolume9_LockBox(src_volume, &locked_box, NULL, D3DLOCK_READONLY);
324 if (FAILED(hr)) return hr;
325
326 hr = D3DXLoadVolumeFromMemory(dst_volume, dst_palette, dst_box,
327 locked_box.pBits, desc.Format, locked_box.RowPitch, locked_box.SlicePitch,
328 src_palette, &box, filter, color_key);
329
330 IDirect3DVolume9_UnlockBox(src_volume);
331 return hr;
332}
#define D3DLOCK_READONLY
Definition: d3d8types.h:69
HRESULT WINAPI D3DXLoadVolumeFromMemory(IDirect3DVolume9 *dst_volume, const PALETTEENTRY *dst_palette, const D3DBOX *dst_box, const void *src_memory, D3DFORMAT src_format, UINT src_row_pitch, UINT src_slice_pitch, const PALETTEENTRY *src_palette, const D3DBOX *src_box, DWORD filter, D3DCOLOR color_key)
Definition: volume.c:87

Referenced by D3DXFilterTexture().

◆ D3DXSaveSurfaceToFileA()

HRESULT WINAPI D3DXSaveSurfaceToFileA ( const char destfile,
D3DXIMAGE_FILEFORMAT  destformat,
struct IDirect3DSurface9 *  srcsurface,
const PALETTEENTRY srcpalette,
const RECT srcrect 
)

Definition at line 2364 of file surface.c.

2366{
2367 int len;
2368 WCHAR *filename;
2369 HRESULT hr;
2371
2372 TRACE("(%s, %#x, %p, %p, %s): relay\n",
2373 wine_dbgstr_a(dst_filename), file_format, src_surface, src_palette, wine_dbgstr_rect(src_rect));
2374
2375 if (!dst_filename) return D3DERR_INVALIDCALL;
2376
2377 len = MultiByteToWideChar(CP_ACP, 0, dst_filename, -1, NULL, 0);
2378 filename = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
2379 if (!filename) return E_OUTOFMEMORY;
2380 MultiByteToWideChar(CP_ACP, 0, dst_filename, -1, filename, len);
2381
2382 hr = D3DXSaveSurfaceToFileInMemory(&buffer, file_format, src_surface, src_palette, src_rect);
2383 if (SUCCEEDED(hr))
2384 {
2387 }
2388
2390 return hr;
2391}
struct ID3DXBuffer ID3DXBuffer
Definition: d3dx8core.h:51
HRESULT write_buffer_to_file(const WCHAR *filename, ID3DXBuffer *buffer) DECLSPEC_HIDDEN
Definition: util.c:186
#define ID3DXBuffer_Release(p)
Definition: d3dx9core.h:83
HRESULT WINAPI D3DXSaveSurfaceToFileInMemory(ID3DXBuffer **dst_buffer, D3DXIMAGE_FILEFORMAT file_format, IDirect3DSurface9 *src_surface, const PALETTEENTRY *src_palette, const RECT *src_rect)
Definition: surface.c:2414

Referenced by test_D3DXSaveSurfaceToFile().

◆ D3DXSaveSurfaceToFileInMemory()

HRESULT WINAPI D3DXSaveSurfaceToFileInMemory ( struct ID3DXBuffer **  destbuffer,
D3DXIMAGE_FILEFORMAT  destformat,
struct IDirect3DSurface9 *  srcsurface,
const PALETTEENTRY srcpalette,
const RECT srcrect 
)

Definition at line 2414 of file surface.c.

2416{
2417 IWICBitmapEncoder *encoder = NULL;
2418 IWICBitmapFrameEncode *frame = NULL;
2419 IPropertyBag2 *encoder_options = NULL;
2420 IStream *stream = NULL;
2421 HRESULT hr;
2422 const GUID *container_format;
2423 const GUID *pixel_format_guid;
2424 WICPixelFormatGUID wic_pixel_format;
2426 D3DFORMAT d3d_pixel_format;
2427 D3DSURFACE_DESC src_surface_desc;
2428 IDirect3DSurface9 *temp_surface;
2429 D3DLOCKED_RECT locked_rect;
2430 int width, height;
2431 STATSTG stream_stats;
2432 HGLOBAL stream_hglobal;
2434 DWORD size;
2435
2436 TRACE("dst_buffer %p, file_format %#x, src_surface %p, src_palette %p, src_rect %s.\n",
2437 dst_buffer, file_format, src_surface, src_palette, wine_dbgstr_rect(src_rect));
2438
2439 if (!dst_buffer || !src_surface) return D3DERR_INVALIDCALL;
2440
2441 if (src_palette)
2442 {
2443 FIXME("Saving surfaces with palettized pixel formats is not implemented yet\n");
2444 return D3DERR_INVALIDCALL;
2445 }
2446
2447 switch (file_format)
2448 {
2449 case D3DXIFF_BMP:
2450 case D3DXIFF_DIB:
2451 container_format = &GUID_ContainerFormatBmp;
2452 break;
2453 case D3DXIFF_PNG:
2454 container_format = &GUID_ContainerFormatPng;
2455 break;
2456 case D3DXIFF_JPG:
2457 container_format = &GUID_ContainerFormatJpeg;
2458 break;
2459 case D3DXIFF_DDS:
2460 return save_dds_surface_to_memory(dst_buffer, src_surface, src_rect);
2461 case D3DXIFF_HDR:
2462 case D3DXIFF_PFM:
2463 case D3DXIFF_TGA:
2464 case D3DXIFF_PPM:
2465 FIXME("File format %#x is not supported yet\n", file_format);
2466 return E_NOTIMPL;
2467 default:
2468 return D3DERR_INVALIDCALL;
2469 }
2470
2471 IDirect3DSurface9_GetDesc(src_surface, &src_surface_desc);
2472 if (src_rect)
2473 {
2474 if (src_rect->left == src_rect->right || src_rect->top == src_rect->bottom)
2475 {
2476 WARN("Invalid rectangle with 0 area\n");
2477 return D3DXCreateBuffer(64, dst_buffer);
2478 }
2479 if (src_rect->left < 0 || src_rect->top < 0)
2480 return D3DERR_INVALIDCALL;
2481 if (src_rect->left > src_rect->right || src_rect->top > src_rect->bottom)
2482 return D3DERR_INVALIDCALL;
2483 if (src_rect->right > src_surface_desc.Width || src_rect->bottom > src_surface_desc.Height)
2484 return D3DERR_INVALIDCALL;
2485
2486 width = src_rect->right - src_rect->left;
2487 height = src_rect->bottom - src_rect->top;
2488 }
2489 else
2490 {
2491 width = src_surface_desc.Width;
2492 height = src_surface_desc.Height;
2493 }
2494
2495 hr = WICCreateImagingFactory_Proxy(WINCODEC_SDK_VERSION, &factory);
2496 if (FAILED(hr)) goto cleanup_err;
2497
2498 hr = IWICImagingFactory_CreateEncoder(factory, container_format, NULL, &encoder);
2499 IWICImagingFactory_Release(factory);
2500 if (FAILED(hr)) goto cleanup_err;
2501
2503 if (FAILED(hr)) goto cleanup_err;
2504
2505 hr = IWICBitmapEncoder_Initialize(encoder, stream, WICBitmapEncoderNoCache);
2506 if (FAILED(hr)) goto cleanup_err;
2507
2508 hr = IWICBitmapEncoder_CreateNewFrame(encoder, &frame, &encoder_options);
2509 if (FAILED(hr)) goto cleanup_err;
2510
2511 hr = IWICBitmapFrameEncode_Initialize(frame, encoder_options);
2512 if (FAILED(hr)) goto cleanup_err;
2513
2514 hr = IWICBitmapFrameEncode_SetSize(frame, width, height);
2515 if (FAILED(hr)) goto cleanup_err;
2516
2517 pixel_format_guid = d3dformat_to_wic_guid(src_surface_desc.Format);
2518 if (!pixel_format_guid)
2519 {
2520 FIXME("Pixel format %#x is not supported yet\n", src_surface_desc.Format);
2521 hr = E_NOTIMPL;
2522 goto cleanup;
2523 }
2524
2525 memcpy(&wic_pixel_format, pixel_format_guid, sizeof(GUID));
2526 hr = IWICBitmapFrameEncode_SetPixelFormat(frame, &wic_pixel_format);
2527 d3d_pixel_format = wic_guid_to_d3dformat(&wic_pixel_format);
2528 if (SUCCEEDED(hr) && d3d_pixel_format != D3DFMT_UNKNOWN)
2529 {
2530 TRACE("Using pixel format %s %#x\n", debugstr_guid(&wic_pixel_format), d3d_pixel_format);
2531 if (src_surface_desc.Format == d3d_pixel_format) /* Simple copy */
2532 {
2533 if (FAILED(hr = lock_surface(src_surface, src_rect, &locked_rect, &temp_surface, FALSE)))
2534 goto cleanup;
2535
2536 IWICBitmapFrameEncode_WritePixels(frame, height,
2537 locked_rect.Pitch, height * locked_rect.Pitch, locked_rect.pBits);
2538 unlock_surface(src_surface, src_rect, temp_surface, FALSE);
2539 }
2540 else /* Pixel format conversion */
2541 {
2542 const struct pixel_format_desc *src_format_desc, *dst_format_desc;
2543 struct volume size;
2544 DWORD dst_pitch;
2545 void *dst_data;
2546
2547 src_format_desc = get_format_info(src_surface_desc.Format);
2548 dst_format_desc = get_format_info(d3d_pixel_format);
2549 if (!is_conversion_from_supported(src_format_desc)
2550 || !is_conversion_to_supported(dst_format_desc))
2551 {
2552 FIXME("Unsupported format conversion %#x -> %#x.\n",
2553 src_surface_desc.Format, d3d_pixel_format);
2554 hr = E_NOTIMPL;
2555 goto cleanup;
2556 }
2557
2558 size.width = width;
2559 size.height = height;
2560 size.depth = 1;
2561 dst_pitch = width * dst_format_desc->bytes_per_pixel;
2562 dst_data = HeapAlloc(GetProcessHeap(), 0, dst_pitch * height);
2563 if (!dst_data)
2564 {
2565 hr = E_OUTOFMEMORY;
2566 goto cleanup;
2567 }
2568 if (FAILED(hr = lock_surface(src_surface, src_rect, &locked_rect, &temp_surface, FALSE)))
2569 {
2570 HeapFree(GetProcessHeap(), 0, dst_data);
2571 goto cleanup;
2572 }
2573 convert_argb_pixels(locked_rect.pBits, locked_rect.Pitch, 0, &size, src_format_desc,
2574 dst_data, dst_pitch, 0, &size, dst_format_desc, 0, NULL);
2575 unlock_surface(src_surface, src_rect, temp_surface, FALSE);
2576
2577 IWICBitmapFrameEncode_WritePixels(frame, height, dst_pitch, dst_pitch * height, dst_data);
2578 HeapFree(GetProcessHeap(), 0, dst_data);
2579 }
2580
2581 hr = IWICBitmapFrameEncode_Commit(frame);
2582 if (SUCCEEDED(hr)) hr = IWICBitmapEncoder_Commit(encoder);
2583 }
2584 else WARN("Unsupported pixel format %#x\n", src_surface_desc.Format);
2585
2586 /* copy data from stream to ID3DXBuffer */
2587 hr = IStream_Stat(stream, &stream_stats, STATFLAG_NONAME);
2588 if (FAILED(hr)) goto cleanup_err;
2589
2590 if (stream_stats.cbSize.u.HighPart != 0)
2591 {
2593 goto cleanup;
2594 }
2595 size = stream_stats.cbSize.u.LowPart;
2596
2597 /* Remove BMP header for DIB */
2598 if (file_format == D3DXIFF_DIB)
2599 size -= sizeof(BITMAPFILEHEADER);
2600
2602 if (FAILED(hr)) goto cleanup;
2603
2604 hr = GetHGlobalFromStream(stream, &stream_hglobal);
2605 if (SUCCEEDED(hr))
2606 {
2607 void *buffer_pointer = ID3DXBuffer_GetBufferPointer(buffer);
2608 void *stream_data = GlobalLock(stream_hglobal);
2609 /* Remove BMP header for DIB */
2610 if (file_format == D3DXIFF_DIB)
2611 stream_data = (void*)((BYTE*)stream_data + sizeof(BITMAPFILEHEADER));
2612 memcpy(buffer_pointer, stream_data, size);
2613 GlobalUnlock(stream_hglobal);
2614 *dst_buffer = buffer;
2615 }
2617
2618cleanup_err:
2619 if (FAILED(hr) && hr != E_OUTOFMEMORY)
2621
2622cleanup:
2623 if (stream) IStream_Release(stream);
2624
2625 if (frame) IWICBitmapFrameEncode_Release(frame);
2626 if (encoder_options) IPropertyBag2_Release(encoder_options);
2627
2628 if (encoder) IWICBitmapEncoder_Release(encoder);
2629
2630 return hr;
2631}
enum _D3DFORMAT D3DFORMAT
#define ID3DXBuffer_GetBufferPointer(p)
Definition: d3dx9core.h:85
HRESULT WINAPI D3DXCreateBuffer(DWORD size, ID3DXBuffer **buffer)
Definition: core.c:131
static HRESULT save_dds_surface_to_memory(ID3DXBuffer **dst_buffer, IDirect3DSurface9 *src_surface, const RECT *src_rect)
Definition: surface.c:587
static const GUID * d3dformat_to_wic_guid(D3DFORMAT format)
Definition: surface.c:70
static void cleanup(void)
Definition: main.c:1335
HRESULT WINAPI GetHGlobalFromStream(IStream *pstm, HGLOBAL *phglobal)
HRESULT WINAPI CreateStreamOnHGlobal(HGLOBAL hGlobal, BOOL fDeleteOnRelease, LPSTREAM *ppstm)
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static const char stream_data[]
Definition: mlang.c:2327
@ WICBitmapEncoderNoCache
Definition: wincodec.idl:72
struct tagBITMAPFILEHEADER BITMAPFILEHEADER

Referenced by D3DXSaveSurfaceToFileA(), D3DXSaveSurfaceToFileW(), D3DXSaveTextureToFileInMemory(), and test_D3DXSaveSurfaceToFileInMemory().

◆ D3DXSaveSurfaceToFileW()

HRESULT WINAPI D3DXSaveSurfaceToFileW ( const WCHAR destfile,
D3DXIMAGE_FILEFORMAT  destformat,
struct IDirect3DSurface9 *  srcsurface,
const PALETTEENTRY srcpalette,
const RECT srcrect 
)

Definition at line 2393 of file surface.c.

2395{
2396 HRESULT hr;
2398
2399 TRACE("(%s, %#x, %p, %p, %s): relay\n",
2400 wine_dbgstr_w(dst_filename), file_format, src_surface, src_palette, wine_dbgstr_rect(src_rect));
2401
2402 if (!dst_filename) return D3DERR_INVALIDCALL;
2403
2404 hr = D3DXSaveSurfaceToFileInMemory(&buffer, file_format, src_surface, src_palette, src_rect);
2405 if (SUCCEEDED(hr))
2406 {
2407 hr = write_buffer_to_file(dst_filename, buffer);
2409 }
2410
2411 return hr;
2412}

◆ D3DXSaveTextureToFileA()

HRESULT WINAPI D3DXSaveTextureToFileA ( const char destfile,
D3DXIMAGE_FILEFORMAT  destformat,
struct IDirect3DBaseTexture9 *  srctexture,
const PALETTEENTRY srcpalette 
)

Definition at line 1839 of file texture.c.

1841{
1842 int len;
1843 WCHAR *filename;
1844 HRESULT hr;
1846
1847 TRACE("(%s, %#x, %p, %p): relay\n",
1848 wine_dbgstr_a(dst_filename), file_format, src_texture, src_palette);
1849
1850 if (!dst_filename) return D3DERR_INVALIDCALL;
1851
1852 len = MultiByteToWideChar(CP_ACP, 0, dst_filename, -1, NULL, 0);
1853 filename = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
1854 if (!filename) return E_OUTOFMEMORY;
1855 MultiByteToWideChar(CP_ACP, 0, dst_filename, -1, filename, len);
1856
1857 hr = D3DXSaveTextureToFileInMemory(&buffer, file_format, src_texture, src_palette);
1858 if (SUCCEEDED(hr))
1859 {
1862 }
1863
1865 return hr;
1866}
HRESULT WINAPI D3DXSaveTextureToFileInMemory(ID3DXBuffer **dst_buffer, D3DXIMAGE_FILEFORMAT file_format, IDirect3DBaseTexture9 *src_texture, const PALETTEENTRY *src_palette)
Definition: texture.c:1889

◆ D3DXSaveTextureToFileInMemory()

HRESULT WINAPI D3DXSaveTextureToFileInMemory ( struct ID3DXBuffer **  destbuffer,
D3DXIMAGE_FILEFORMAT  destformat,
struct IDirect3DBaseTexture9 *  srctexture,
const PALETTEENTRY srcpalette 
)

Definition at line 1889 of file texture.c.

1891{
1892 HRESULT hr;
1894 IDirect3DSurface9 *surface;
1895
1896 TRACE("(%p, %#x, %p, %p)\n",
1897 dst_buffer, file_format, src_texture, src_palette);
1898
1899 if (!dst_buffer || !src_texture) return D3DERR_INVALIDCALL;
1900
1901 if (file_format == D3DXIFF_DDS)
1902 return save_dds_texture_to_memory(dst_buffer, src_texture, src_palette);
1903
1904 type = IDirect3DBaseTexture9_GetType(src_texture);
1905 switch (type)
1906 {
1907 case D3DRTYPE_TEXTURE:
1909 hr = get_surface(type, src_texture, D3DCUBEMAP_FACE_POSITIVE_X, 0, &surface);
1910 break;
1912 FIXME("Volume textures aren't supported yet\n");
1913 return E_NOTIMPL;
1914 default:
1915 return D3DERR_INVALIDCALL;
1916 }
1917
1918 if (SUCCEEDED(hr))
1919 {
1920 hr = D3DXSaveSurfaceToFileInMemory(dst_buffer, file_format, surface, src_palette, NULL);
1922 }
1923
1924 return hr;
1925}
@ D3DCUBEMAP_FACE_POSITIVE_X
Definition: d3d8types.h:550
HRESULT save_dds_texture_to_memory(ID3DXBuffer **dst_buffer, IDirect3DBaseTexture9 *src_texture, const PALETTEENTRY *src_palette) DECLSPEC_HIDDEN
Definition: surface.c:672

Referenced by D3DXSaveTextureToFileA(), D3DXSaveTextureToFileW(), and test_D3DXSaveTextureToFileInMemory().

◆ D3DXSaveTextureToFileW()

HRESULT WINAPI D3DXSaveTextureToFileW ( const WCHAR destfile,
D3DXIMAGE_FILEFORMAT  destformat,
struct IDirect3DBaseTexture9 *  srctexture,
const PALETTEENTRY srcpalette 
)

Definition at line 1868 of file texture.c.

1870{
1871 HRESULT hr;
1873
1874 TRACE("(%s, %#x, %p, %p): relay\n",
1875 wine_dbgstr_w(dst_filename), file_format, src_texture, src_palette);
1876
1877 if (!dst_filename) return D3DERR_INVALIDCALL;
1878
1879 hr = D3DXSaveTextureToFileInMemory(&buffer, file_format, src_texture, src_palette);
1880 if (SUCCEEDED(hr))
1881 {
1882 hr = write_buffer_to_file(dst_filename, buffer);
1884 }
1885
1886 return hr;
1887}

◆ D3DXSaveVolumeToFileA()

HRESULT WINAPI D3DXSaveVolumeToFileA ( const char destfile,
D3DXIMAGE_FILEFORMAT  destformat,
struct IDirect3DVolume9 *  srcvolume,
const PALETTEENTRY srcpalette,
const D3DBOX srcbox 
)

◆ D3DXSaveVolumeToFileW()

HRESULT WINAPI D3DXSaveVolumeToFileW ( const WCHAR destfile,
D3DXIMAGE_FILEFORMAT  destformat,
struct IDirect3DVolume9 *  srcvolume,
const PALETTEENTRY srcpalette,
const D3DBOX srcbox 
)