Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Windos
win32.3rdparty
win32.directx.audio
win32.directx.ddk
win32.directx.graphics
win32.directx.input
win32.directx.managed
win32.directx.misc
win32.directx.networking
win32.directx.sdk
win32.directx.video
win32.dirx.grap.shaders
win32.gdi
win32.international
win32.kernel
win32.messaging
win32.mmedia
win32.networks
win32.ole
win32.rtc
win32.tapi
win32.tapi.beta
win32.tools
win32.ui
win32.wince
win32.wmi
windows.mediacenter
winfx.aero
winfx.announcements
winfx.avalon
winfx.collaboration
winfx.fundamentals
winfx.general
winfx.indigo
winfx.sdk
winfx.winfs
  
 
date: Sun, 26 Mar 2006 15:07:27 -0800,    group: microsoft.public.win32.programmer.directx.sdk        back       


Does D3DXLoadSurfaceFromFileInMemory function really support png   
Hi , guys,

In my project, I will use file buffer to create texture instead of local 
file. The buffer is downloaded through http. I want to avoid save the buffer 
to local file then create texture .So I try to use 
D3DXLoadSurfaceFromFileInMemory() function to create surface. It works fine 
if the buffer is bmp file buffer. All other file type will return 
failed,D3DXERR_INVALIDDATA.

In MSDN ,This function supports the following file formats: .bmp, .dds, 
..dib, .jpg, .png, and .tga.

Did I do anything wrong?  Thank you for any suggestion and help!

Bravew

Here is the code:
  //testing code , simulating get image buffer from internet
  //char fileName[] = "c:\\image\\a.bmp";
  char fileName[] = "c:\\image\\transparent.png"; //error 
  struct __stat64 buf;
  int fd, result;
  fd = _open( fileName, _O_RDONLY );
  result = _fstat64( fd, &buf );
  BYTE *  buffer  = new BYTE [  buf.st_size ];
   FILE *fp = 0;
   fp = fopen(fileName,"r");
   int bytes;
  bytes = fread(buffer, 1,  buf.st_size, fp);
 
  mpNormTex->GetSurfaceLevel(levelMipMap, &surface);
  // get D3DXIMAGE_INFO first
  D3DXIMAGE_INFO imageInfo;
  hr = D3DXGetImageInfoFromFileInMemory(buffer,size,&imageInfo);
   // Here is the problem, it will return D3DXERR_INVALIDDATA for not bmp file
  hr = D3DXLoadSurfaceFromFileInMemory (surface, NULL, NULL,  buffer,   
buf.st_size,  NULL, D3DX_FILTER_NONE, 0,  &imageInfo) ;

_close( fd );
fclose(fp);
date: Sun, 26 Mar 2006 15:07:27 -0800   author:   Bravew

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us