- Main Page
- Data Structures
- Files

- File List

# E:/DevIL/src-ILUT/src/ilut_directx.c

    00001 //-----------------------------------------------------------------------------
    00002 //
    00003 // ImageLib Utility Toolkit Sources
    00004 // Copyright (C) 2000-2008 by Denton Woods
    00005 // Last modified: 12/25/2001
    00006 //
    00007 // Filename: src-ILUT/src/ilut_directx.c
    00008 //
    00009 // Description: DirectX 8 functions for textures
    00010 //
    00011 //-----------------------------------------------------------------------------
    00012
    00013 #include "ilut_internal.h"
    00014 #ifdef ILUT_USE_DIRECTX8
    00015
    00016 #include <d3d8.h>
    00017 //#include <d3dx8tex.h>
    00018 //pragma comment(lib, "d3d8.lib")
    00019 //pragma comment(lib, "d3dx8.lib")
    00020
    00021 ILimage*        MakeD3D8Compliant(IDirect3DDevice8 *Device, D3DFORMAT *DestFormat);
    00022 ILenum          GetD3D8Compat(ILenum Format);
    00023 D3DFORMAT       GetD3DFormat(ILenum Format);
    00024 ILboolean       iD3D8CreateMipmaps(IDirect3DTexture8 *Texture, ILimage *Image);
    00025
    00026 ILboolean       FormatsDX8Checked = IL_FALSE;
    00027 ILboolean       FormatsDX8supported[6] =
    00028         { IL_FALSE, IL_FALSE, IL_FALSE, IL_FALSE, IL_FALSE, IL_FALSE };
    00029 D3DFORMAT       FormatsDX8[6] =
    00030         { D3DFMT_R8G8B8, D3DFMT_A8R8G8B8, D3DFMT_L8, D3DFMT_DXT1, D3DFMT_DXT3, D3DFMT_DXT5 };
    00031
    00032
    00033 ILboolean ilutD3D8Init()
    00034 {
    00035
    00036         return IL_TRUE;
    00037 }
    00038
    00039
    00040 ILvoid CheckFormatsDX8(IDirect3DDevice8 *Device)
    00041 {
    00042         D3DDISPLAYMODE  DispMode;
    00043         HRESULT                 hr;
    00044         IDirect3D8              *TestD3D8;
    00045         ILuint                  i;
    00046
    00047         IDirect3DDevice8_GetDirect3D(Device, (IDirect3D8**)&TestD3D8);
    00048         IDirect3DDevice8_GetDisplayMode(Device, &DispMode);
    00049
    00050         for (i = 0; i < 6; i++) {
    00051                 hr = IDirect3D8_CheckDeviceFormat(TestD3D8, D3DADAPTER_DEFAULT,
    00052                         D3DDEVTYPE_HAL, DispMode.Format, 0, D3DRTYPE_TEXTURE, FormatsDX8[i]);
    00053                 FormatsDX8supported[i] = SUCCEEDED(hr);
    00054         }
    00055
    00056         IDirect3D8_Release(TestD3D8);
    00057         FormatsDX8Checked = IL_TRUE;
    00058
    00059         return;
    00060 }
    00061
    00062
    00063 #ifndef _WIN32_WCE
    00064 ILboolean ILAPIENTRY ilutD3D8TexFromFile(IDirect3DDevice8 *Device, char *FileName, IDirect3DTexture8 **Texture)
    00065 {
    00066         iBindImageTemp();
    00067         if (!ilLoadImage(FileName))
    00068                 return IL_FALSE;
    00069
    00070         *Texture = ilutD3D8Texture(Device);
    00071
    00072         return IL_TRUE;
    00073 }
    00074 #endif//_WIN32_WCE
    00075
    00076
    00077 #ifndef _WIN32_WCE
    00078 ILboolean ILAPIENTRY ilutD3D8VolTexFromFile(IDirect3DDevice8 *Device, char *FileName, IDirect3DVolumeTexture8 **Texture)
    00079 {
    00080         iBindImageTemp();
    00081         if (!ilLoadImage(FileName))
    00082                 return IL_FALSE;
    00083
    00084         *Texture = ilutD3D8VolumeTexture(Device);
    00085
    00086         return IL_TRUE;
    00087 }
    00088 #endif//_WIN32_WCE
    00089
    00090
    00091 ILboolean ILAPIENTRY ilutD3D8TexFromFileInMemory(IDirect3DDevice8 *Device, ILvoid *Lump, ILuint Size, IDirect3DTexture8 **Texture)
    00092 {
    00093         iBindImageTemp();
    00094         if (!ilLoadL(IL_TYPE_UNKNOWN, Lump, Size))
    00095                 return IL_FALSE;
    00096
    00097         *Texture = ilutD3D8Texture(Device);
    00098
    00099         return IL_TRUE;
    00100 }
    00101
    00102
    00103 ILboolean ILAPIENTRY ilutD3D8VolTexFromFileInMemory(IDirect3DDevice8 *Device, ILvoid *Lump, ILuint Size, IDirect3DVolumeTexture8 **Texture)
    00104 {
    00105         iBindImageTemp();
    00106         if (!ilLoadL(IL_TYPE_UNKNOWN, Lump, Size))
    00107                 return IL_FALSE;
    00108
    00109         *Texture = ilutD3D8VolumeTexture(Device);
    00110
    00111         return IL_TRUE;
    00112 }
    00113
    00114
    00115 ILboolean ILAPIENTRY ilutD3D8TexFromResource(IDirect3DDevice8 *Device, HMODULE SrcModule, char *SrcResource, IDirect3DTexture8 **Texture)
    00116 {
    00117         HRSRC   Resource;
    00118         ILubyte *Data;
    00119
    00120         iBindImageTemp();
    00121
    00122         Resource = (HRSRC)LoadResource(SrcModule, FindResource(SrcModule, SrcResource, RT_BITMAP));
    00123         Data = (ILubyte*)LockResource(Resource);
    00124         if (!ilLoadL(IL_TYPE_UNKNOWN, Data, SizeofResource(SrcModule, FindResource(SrcModule, SrcResource, RT_BITMAP))))
    00125                 return IL_FALSE;
    00126
    00127         *Texture = ilutD3D8Texture(Device);
    00128
    00129         return IL_TRUE;
    00130 }
    00131
    00132
    00133 ILboolean ILAPIENTRY ilutD3D8VolTexFromResource(IDirect3DDevice8 *Device, HMODULE SrcModule, char *SrcResource, IDirect3DVolumeTexture8 **Texture)
    00134 {
    00135         HRSRC   Resource;
    00136         ILubyte *Data;
    00137
    00138         iBindImageTemp();
    00139
    00140         Resource = (HRSRC)LoadResource(SrcModule, FindResource(SrcModule, SrcResource, RT_BITMAP));
    00141         Data = (ILubyte*)LockResource(Resource);
    00142         if (!ilLoadL(IL_TYPE_UNKNOWN, Data, SizeofResource(SrcModule, FindResource(SrcModule, SrcResource, RT_BITMAP))))
    00143                 return IL_FALSE;
    00144
    00145         *Texture = ilutD3D8VolumeTexture(Device);
    00146
    00147         return IL_TRUE;
    00148 }
    00149
    00150
    00151 ILboolean ILAPIENTRY ilutD3D8TexFromFileHandle(IDirect3DDevice8 *Device, ILHANDLE File, IDirect3DTexture8 **Texture)
    00152 {
    00153         iBindImageTemp();
    00154         if (!ilLoadF(IL_TYPE_UNKNOWN, File))
    00155                 return IL_FALSE;
    00156
    00157         *Texture = ilutD3D8Texture(Device);
    00158
    00159         return IL_TRUE;
    00160 }
    00161
    00162
    00163 ILboolean ILAPIENTRY ilutD3D8VolTexFromFileHandle(IDirect3DDevice8 *Device, ILHANDLE File, IDirect3DVolumeTexture8 **Texture)
    00164 {
    00165         iBindImageTemp();
    00166         if (!ilLoadF(IL_TYPE_UNKNOWN, File))
    00167                 return IL_FALSE;
    00168
    00169         *Texture = ilutD3D8VolumeTexture(Device);
    00170
    00171         return IL_TRUE;
    00172 }
    00173
    00174
    00175 D3DFORMAT D3DGetDXTCNumDX8(ILenum DXTCFormat)
    00176 {
    00177         switch (DXTCFormat)
    00178         {
    00179                 case IL_DXT1:
    00180                         return D3DFMT_DXT1;
    00181                 case IL_DXT3:
    00182                         return D3DFMT_DXT3;
    00183                 case IL_DXT5:
    00184                         return D3DFMT_DXT5;
    00185         }
    00186
    00187         return D3DFMT_UNKNOWN;
    00188 }
    00189
    00190
    00191 IDirect3DTexture8* ILAPIENTRY ilutD3D8Texture(IDirect3DDevice8 *Device)
    00192 {
    00193         IDirect3DTexture8 *Texture;
    00194         D3DLOCKED_RECT Rect;
    00195         D3DFORMAT Format;
    00196         ILimage *Image;
    00197         ILenum  DXTCFormat;
    00198         ILuint  Size;
    00199         ILubyte *Buffer;
    00200
    00201         Image = ilutCurImage = ilGetCurImage();
    00202         if (ilutCurImage == NULL) {
    00203                 ilSetError(ILUT_ILLEGAL_OPERATION);
    00204                 return NULL;
    00205         }
    00206
    00207         if (!FormatsDX8Checked)
    00208                 CheckFormatsDX8(Device);
    00209
    00210         if (ilutGetBoolean(ILUT_D3D_USE_DXTC) && FormatsDX8supported[3] && FormatsDX8supported[4] && FormatsDX8supported[5]) {
    00211                 if (ilutCurImage->DxtcData != NULL && ilutCurImage->DxtcSize != 0) {
    00212                         Format = D3DGetDXTCNumDX8(ilutCurImage->DxtcFormat);
    00213
    00214                         if (FAILED(IDirect3DDevice8_CreateTexture(Device, ilutCurImage->Width,
    00215                                 ilutCurImage->Height, ilutGetInteger(ILUT_D3D_MIPLEVELS), 0, Format,
    00216                                 (D3DPOOL)ilutGetInteger(ILUT_D3D_POOL), &Texture)))
    00217                                         return NULL;
    00218                         if (FAILED(IDirect3DTexture8_LockRect(Texture, 0, &Rect, NULL, 0)))
    00219                                 return NULL;
    00220                         memcpy(Rect.pBits, ilutCurImage->DxtcData, ilutCurImage->DxtcSize);
    00221                         goto success;
    00222                 }
    00223
    00224                 if (ilutGetBoolean(ILUT_D3D_GEN_DXTC)) {
    00225                         DXTCFormat = ilutGetInteger(ILUT_DXTC_FORMAT);
    00226
    00227                         Size = ilGetDXTCData(NULL, 0, DXTCFormat);
    00228                         if (Size != 0) {
    00229                                 Buffer = (ILubyte*)ialloc(Size);
    00230                                 if (Buffer == NULL)
    00231                                         return NULL;
    00232                                 Size = ilGetDXTCData(Buffer, Size, DXTCFormat);
    00233                                 if (Size == 0) {
    00234                                         ifree(Buffer);
    00235                                         return NULL;
    00236                                 }
    00237
    00238                                 Format = D3DGetDXTCNumDX8(DXTCFormat);
    00239                                 if (FAILED(IDirect3DDevice8_CreateTexture(Device, ilutCurImage->Width,
    00240                                         ilutCurImage->Height, ilutGetInteger(ILUT_D3D_MIPLEVELS), 0, Format,
    00241                                         (D3DPOOL)ilutGetInteger(ILUT_D3D_POOL), &Texture))) {
    00242                                                 ifree(Buffer);
    00243                                                 return NULL;
    00244                                 }
    00245                                 if (FAILED(IDirect3DTexture8_LockRect(Texture, 0, &Rect, NULL, 0))) {
    00246                                         ifree(Buffer);
    00247                                         return NULL;
    00248                                 }
    00249                                 memcpy(Rect.pBits, Buffer, Size);
    00250                                 ifree(Buffer);
    00251                                 goto success;
    00252                         }
    00253                 }
    00254         }
    00255
    00256         Image = MakeD3D8Compliant(Device, &Format);
    00257         if (Image == NULL) {
    00258                 if (Image != ilutCurImage)
    00259                         ilCloseImage(Image);
    00260                 return NULL;
    00261         }
    00262         if (FAILED(IDirect3DDevice8_CreateTexture(Device, Image->Width, Image->Height,
    00263                 ilutGetInteger(ILUT_D3D_MIPLEVELS), 0, Format, (D3DPOOL)ilutGetInteger(ILUT_D3D_POOL), &Texture))) {
    00264                 if (Image != ilutCurImage)
    00265                         ilCloseImage(Image);
    00266                 return NULL;
    00267         }
    00268         if (FAILED(IDirect3DTexture8_LockRect(Texture, 0, &Rect, NULL, 0)))
    00269                 return NULL;
    00270         memcpy(Rect.pBits, Image->Data, Image->SizeOfPlane);
    00271
    00272 success:
    00273         IDirect3DTexture8_UnlockRect(Texture, 0);
    00274         // Just let D3DX filter for us.
    00275         //D3DXFilterTexture(Texture, NULL, D3DX_DEFAULT, D3DX_FILTER_BOX);
    00276         iD3D8CreateMipmaps(Texture, Image);
    00277
    00278         if (Image != ilutCurImage)
    00279                 ilCloseImage(Image);
    00280
    00281         return Texture;
    00282 }
    00283
    00284
    00285 IDirect3DVolumeTexture8* ILAPIENTRY ilutD3D8VolumeTexture(IDirect3DDevice8 *Device)
    00286 {
    00287         IDirect3DVolumeTexture8 *Texture;
    00288         D3DLOCKED_BOX   Box;
    00289         D3DFORMAT               Format;
    00290         ILimage                 *Image;
    00291
    00292         ilutCurImage = ilGetCurImage();
    00293         if (ilutCurImage == NULL) {
    00294                 ilSetError(ILUT_ILLEGAL_OPERATION);
    00295                 return NULL;
    00296         }
    00297
    00298         if (!FormatsDX8Checked)
    00299                 CheckFormatsDX8(Device);
    00300
    00301         Image = MakeD3D8Compliant(Device, &Format);
    00302         if (Image == NULL)
    00303                 return NULL;
    00304         if (FAILED(IDirect3DDevice8_CreateVolumeTexture(Device, Image->Width, Image->Height,
    00305                 Image->Depth, 1, 0, Format, (D3DPOOL)ilutGetInteger(ILUT_D3D_POOL), &Texture)))
    00306                 return NULL;
    00307         if (FAILED(IDirect3DVolumeTexture8_LockBox(Texture, 0, &Box, NULL, 0)))
    00308                 return NULL;
    00309
    00310         memcpy(Box.pBits, Image->Data, Image->SizeOfData);
    00311         if (!IDirect3DVolumeTexture8_UnlockBox(Texture, 0))
    00312                 return IL_FALSE;
    00313
    00314         // We don't want to have mipmaps for such a large image.
    00315
    00316         if (Image != ilutCurImage)
    00317                 ilCloseImage(Image);
    00318
    00319         return Texture;
    00320 }
    00321
    00322
    00323 ILimage *MakeD3D8Compliant(IDirect3DDevice8 *Device, D3DFORMAT *DestFormat)
    00324 {
    00325         ILimage *Converted, *Scaled, *CurImage;
    00326
    00327         *DestFormat = D3DFMT_A8R8G8B8;
    00328
    00329         // Images must be in BGRA format.
    00330         if (ilutCurImage->Format != IL_BGRA) {
    00331                 Converted = iConvertImage(ilutCurImage, IL_BGRA, IL_UNSIGNED_BYTE);
    00332                 if (Converted == NULL)
    00333                         return NULL;
    00334         }
    00335         else {
    00336                 Converted = ilutCurImage;
    00337         }
    00338
    00339         // Images must have their origin in the upper left.
    00340         if (Converted->Origin != IL_ORIGIN_UPPER_LEFT) {
    00341                 CurImage = ilutCurImage;
    00342                 ilSetCurImage(Converted);
    00343                 iluFlipImage();
    00344                 ilSetCurImage(CurImage);
    00345         }
    00346
    00347         // Images must have powers-of-2 dimensions.
    00348         if (ilNextPower2(ilutCurImage->Width) != ilutCurImage->Width ||
    00349                 ilNextPower2(ilutCurImage->Height) != ilutCurImage->Height ||
    00350                 ilNextPower2(ilutCurImage->Depth) != ilutCurImage->Depth) {
    00351                         Scaled = iluScale_(Converted, ilNextPower2(ilutCurImage->Width),
    00352                                                 ilNextPower2(ilutCurImage->Height), ilNextPower2(ilutCurImage->Depth));
    00353                         if (Converted != ilutCurImage) {
    00354                                 ilCloseImage(Converted);
    00355                         }
    00356                         if (Scaled == NULL) {
    00357                                 return NULL;
    00358                         }
    00359                         Converted = Scaled;
    00360         }
    00361
    00362         return Converted;
    00363 }
    00364
    00365
    00366 ILboolean iD3D8CreateMipmaps(IDirect3DTexture8 *Texture, ILimage *Image)
    00367 {
    00368         D3DLOCKED_RECT  Rect;
    00369         D3DSURFACE_DESC Desc;
    00370         ILuint                  NumMips, Width, Height, i;
    00371         ILimage                 *CurImage, *MipImage, *Temp;
    00372
    00373         NumMips = IDirect3DTexture8_GetLevelCount(Texture);
    00374         Width = Image->Width;
    00375         Height = Image->Height;
    00376
    00377         CurImage = ilGetCurImage();
    00378         MipImage = ilCopyImage_(CurImage);
    00379         ilSetCurImage(MipImage);
    00380         if (!iluBuildMipmaps()) {
    00381                 ilCloseImage(MipImage);
    00382                 ilSetCurImage(CurImage);
    00383                 return IL_FALSE;
    00384         }
    00385         ilSetCurImage(CurImage);
    00386         Temp = MipImage->Mipmaps;
    00387
    00388         // Counts the base texture as 1.
    00389         for (i = 1; i < NumMips && Temp != NULL; i++) {
    00390                 if (FAILED(IDirect3DTexture8_LockRect(Texture, i, &Rect, NULL, 0)))
    00391                         return IL_FALSE;
    00392
    00393                 Width = IL_MAX(1, Width / 2);
    00394                 Height = IL_MAX(1, Height / 2);
    00395
    00396                 IDirect3DTexture8_GetLevelDesc(Texture, i, &Desc);
    00397                 if (Desc.Width != Width || Desc.Height != Height) {
    00398                         IDirect3DTexture8_UnlockRect(Texture, i);
    00399                         return IL_FALSE;
    00400                 }
    00401
    00402                 memcpy(Rect.pBits, Temp->Data, Temp->SizeOfData);
    00403
    00404                 IDirect3DTexture8_UnlockRect(Texture, i);
    00405                 Temp = Temp->Next;
    00406         }
    00407
    00408         ilCloseImage(MipImage);
    00409
    00410         return IL_TRUE;
    00411 }
    00412
    00413
    00414 //
    00415 // SaveSurfaceToFile.cpp
    00416 //
    00417 // Copyright (c) 2001 David Galeano
    00418 //
    00419 // Permission to use, copy, modify and distribute this software
    00420 // is hereby granted, provided that both the copyright notice and
    00421 // this permission notice appear in all copies of the software,
    00422 // derivative works or modified versions.
    00423 //
    00424 // THE AUTHOR ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
    00425 // CONDITION AND DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
    00426 // WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
    00427 //
    00428
    00429 ILAPI ILboolean ILAPIENTRY ilutD3D8LoadSurface(IDirect3DDevice8 *Device, IDirect3DSurface8 *Surface)
    00430 {
    00431         HRESULT                         hr;
    00432         D3DSURFACE_DESC         d3dsd;
    00433         LPDIRECT3DSURFACE8      SurfaceCopy;
    00434         D3DLOCKED_RECT          d3dLR;
    00435         ILboolean                       bHasAlpha;
    00436         ILubyte                         *Image, *ImageAux, *Data;
    00437         ILuint                          y, x;
    00438         ILushort                        dwColor;
    00439
    00440         IDirect3DSurface8_GetDesc(Surface, &d3dsd);
    00441
    00442         bHasAlpha = (d3dsd.Format == D3DFMT_A8R8G8B8 || d3dsd.Format == D3DFMT_A1R5G5B5);
    00443
    00444         if (bHasAlpha) {
    00445                 if (!ilTexImage(d3dsd.Width, d3dsd.Height, 1, 4, IL_BGRA, IL_UNSIGNED_BYTE, NULL)) {
    00446                         return IL_FALSE;
    00447                 }
    00448         }
    00449         else {
    00450                 if (!ilTexImage(d3dsd.Width, d3dsd.Height, 1, 3, IL_BGR, IL_UNSIGNED_BYTE, NULL)) {
    00451                         return IL_FALSE;
    00452                 }
    00453         }
    00454
    00455         hr = IDirect3DDevice8_CreateImageSurface(Device, d3dsd.Width, d3dsd.Height, d3dsd.Format, &SurfaceCopy);
    00456         if (FAILED(hr)) {
    00457                 ilSetError(ILUT_ILLEGAL_OPERATION);
    00458                 return IL_FALSE;
    00459         }
    00460
    00461         hr = IDirect3DDevice8_CopyRects(Device, Surface, NULL, 0, SurfaceCopy, NULL);
    00462         if (FAILED(hr)) {
    00463                 ilSetError(ILUT_ILLEGAL_OPERATION);
    00464                 return IL_FALSE;
    00465         }
    00466
    00467         hr = IDirect3DSurface8_LockRect(SurfaceCopy, &d3dLR, NULL, D3DLOCK_NO_DIRTY_UPDATE | D3DLOCK_NOSYSLOCK | D3DLOCK_READONLY);
    00468         if (FAILED(hr)) {
    00469                 IDirect3DSurface8_Release(SurfaceCopy);
    00470                 ilSetError(ILUT_ILLEGAL_OPERATION);
    00471                 return IL_FALSE;
    00472         }
    00473
    00474         Image = (ILubyte*)d3dLR.pBits;
    00475         Data = ilutCurImage->Data;
    00476
    00477         for (y = 0; y < d3dsd.Height; y++) {
    00478                 if (d3dsd.Format == D3DFMT_X8R8G8B8) {
    00479                         ImageAux = Image;
    00480                         for (x = 0; x < d3dsd.Width; x++) {
    00481                                 Data[0] = ImageAux[0];
    00482                                 Data[1] = ImageAux[1];
    00483                                 Data[2] = ImageAux[2];
    00484
    00485                                 Data += 3;
    00486                                 ImageAux += 4;
    00487                         }
    00488                 }
    00489                 else if (d3dsd.Format == D3DFMT_A8R8G8B8) {
    00490                         memcpy(Data, Image, d3dsd.Width * 4);
    00491                 }
    00492                 else if (d3dsd.Format == D3DFMT_R5G6B5) {
    00493                         ImageAux = Image;
    00494                         for (x = 0; x < d3dsd.Width; x++) {
    00495                                 dwColor = *((ILushort*)ImageAux);
    00496
    00497                                 Data[0] = (ILubyte)((dwColor&0x001f)<<3);
    00498                                 Data[1] = (ILubyte)(((dwColor&0x7e0)>>5)<<2);
    00499                                 Data[2] = (ILubyte)(((dwColor&0xf800)>>11)<<3);
    00500
    00501                                 Data += 3;
    00502                                 ImageAux += 2;
    00503                         }
    00504                 }
    00505                 else if (d3dsd.Format == D3DFMT_X1R5G5B5) {
    00506                         ImageAux = Image;
    00507                         for (x = 0; x < d3dsd.Width; x++) {
    00508                                 dwColor = *((ILushort*)ImageAux);
    00509
    00510                                 Data[0] = (ILubyte)((dwColor&0x001f)<<3);
    00511                                 Data[1] = (ILubyte)(((dwColor&0x3e0)>>5)<<3);
    00512                                 Data[2] = (ILubyte)(((dwColor&0x7c00)>>10)<<3);
    00513
    00514                                 Data += 3;
    00515                                 ImageAux += 2;
    00516                         }
    00517                 }
    00518                 else if (d3dsd.Format == D3DFMT_A1R5G5B5) {
    00519                         ImageAux = Image;
    00520                         for (x = 0; x < d3dsd.Width; x++) {
    00521                                 dwColor = *((ILushort*)ImageAux);
    00522
    00523                                 Data[0] = (ILubyte)((dwColor&0x001f)<<3);
    00524                                 Data[1] = (ILubyte)(((dwColor&0x3e0)>>5)<<3);
    00525                                 Data[2] = (ILubyte)(((dwColor&0x7c00)>>10)<<3);
    00526                                 Data[3] = (ILubyte)(((dwColor&0x8000)>>15)*255);
    00527
    00528                                 Data += 4;
    00529                                 ImageAux += 2;
    00530                         }
    00531                 }
    00532
    00533                 Image += d3dLR.Pitch;
    00534         }
    00535
    00536         IDirect3DSurface8_UnlockRect(SurfaceCopy);
    00537         IDirect3DSurface8_Release(SurfaceCopy);
    00538
    00539         return IL_TRUE;
    00540 }
    00541
    00542 #endif//ILUT_USE_DIRECTX8