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.

44 rivejä
1.8 KiB

  1. namespace RenderHookAPI.Hook
  2. {
  3. public static class DX9FormatExtension
  4. {
  5. public static int ToPixelDepth(this SharpDX.Direct3D9.Format format)
  6. {
  7. // Only support the DX9 BackBuffer formats: http://msdn.microsoft.com/en-us/library/windows/desktop/bb172558(v=vs.85).aspx
  8. switch (format)
  9. {
  10. case SharpDX.Direct3D9.Format.A2R10G10B10:
  11. case SharpDX.Direct3D9.Format.A8R8G8B8:
  12. case SharpDX.Direct3D9.Format.X8R8G8B8:
  13. return 32;
  14. case SharpDX.Direct3D9.Format.R5G6B5:
  15. case SharpDX.Direct3D9.Format.A1R5G5B5:
  16. case SharpDX.Direct3D9.Format.X1R5G5B5:
  17. return 16;
  18. default:
  19. return -1;
  20. }
  21. }
  22. public static System.Drawing.Imaging.PixelFormat ToPixelFormat(this SharpDX.Direct3D9.Format format)
  23. {
  24. // Only support the BackBuffer formats: http://msdn.microsoft.com/en-us/library/windows/desktop/bb172558(v=vs.85).aspx
  25. // and of these only those that have a direct mapping to supported PixelFormat's
  26. switch (format)
  27. {
  28. case SharpDX.Direct3D9.Format.A8R8G8B8:
  29. case SharpDX.Direct3D9.Format.X8R8G8B8:
  30. return System.Drawing.Imaging.PixelFormat.Format32bppArgb;
  31. case SharpDX.Direct3D9.Format.R5G6B5:
  32. return System.Drawing.Imaging.PixelFormat.Format16bppRgb565;
  33. case SharpDX.Direct3D9.Format.A1R5G5B5:
  34. case SharpDX.Direct3D9.Format.X1R5G5B5:
  35. return System.Drawing.Imaging.PixelFormat.Format16bppArgb1555;
  36. default:
  37. return System.Drawing.Imaging.PixelFormat.Undefined;
  38. }
  39. }
  40. }
  41. }