Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
834 B

  1. #include <windows.h>
  2. #include <objbase.h>
  3. #include <gdiplus.h>
  4. using namespace Gdiplus;
  5. Bitmap *LoadTGAResource(char *szResource)
  6. // Returns an allocated Bitmap
  7. {
  8. BYTE Type;
  9. WORD wWidth;
  10. WORD wHeight;
  11. BYTE cBits;
  12. HGLOBAL hGlobal=NULL;
  13. BYTE *pData=NULL;
  14. hGlobal=LoadResource(GetModuleHandle(NULL),FindResource(GetModuleHandle(NULL),szResource,"TGA"));
  15. pData=(BYTE*)LockResource(hGlobal);
  16. // There is no Unlock or unload, it will get thrown away once module gets destroyed.
  17. memcpy(&Type,(pData+2),sizeof(Type));
  18. memcpy(&wWidth,(pData+12),sizeof(wWidth));
  19. memcpy(&wHeight,(pData+14),sizeof(wHeight));
  20. memcpy(&cBits,(pData+16),sizeof(cBits));
  21. if (cBits!=32) { return NULL; }
  22. if (Type!=2) { return NULL; }
  23. return new Bitmap(wWidth,wHeight,wWidth*(32/8),PixelFormat32bppARGB,(pData+18));
  24. }