- Main Page
- Data Structures
- Files

- File List

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

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