CWin32Bitmaps.cs 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Runtime.InteropServices;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. //IntPtr
  8. using HDC = System.IntPtr;
  9. using LPVOID = System.IntPtr;
  10. //UInt32
  11. using DWORD = System.UInt32;
  12. using UINT = System.UInt32;
  13. namespace TeamAAS_VP.Core.GalaxyMethod
  14. {
  15. public class CWin32Bitmaps
  16. {
  17. [StructLayout(LayoutKind.Sequential)]
  18. public struct BITMAPFILEHEADER
  19. {
  20. public ushort bfType;
  21. public int bfSize;
  22. public ushort bfReserved1;
  23. public ushort bfReserved2;
  24. public uint bfOffBits;
  25. }
  26. [StructLayout(LayoutKind.Sequential)]
  27. public struct BITMAPINFOHEADER
  28. {
  29. public uint biSize;
  30. public int biWidth;
  31. public int biHeight;
  32. public ushort biPlanes;
  33. public ushort biBitCount;
  34. public uint biCompression;
  35. public int biSizeImage;
  36. public int biXPelsPerMeter;
  37. public int biYPelsPerMeter;
  38. public uint biClrUsed;
  39. public uint biClrImportant;
  40. }
  41. [StructLayout(LayoutKind.Sequential)]
  42. public struct RGBQUAD
  43. {
  44. public byte rgbBlue;
  45. public byte rgbGreen;
  46. public byte rgbRed;
  47. public byte rgbReserved;
  48. }
  49. [StructLayout(LayoutKind.Sequential)]
  50. public struct BITMAPINFO
  51. {
  52. public BITMAPINFOHEADER bmiHeader;
  53. [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
  54. public RGBQUAD[] bmiColors;
  55. }
  56. [DllImport("gdi32.dll", CharSet = CharSet.Auto)]
  57. public static extern int SetStretchBltMode(
  58. HDC hdc, // handle to DC
  59. int iStretchMode // bitmap stretching mode
  60. );
  61. [DllImport("gdi32.dll", CharSet = CharSet.Auto)]
  62. public static extern int StretchDIBits(
  63. HDC hdc, // handle to DC
  64. int XDest, // x-coord of destination upper-left corner
  65. int YDest, // y-coord of destination upper-left corner
  66. int nDestWidth, // width of destination rectangle
  67. int nDestHeight, // height of destination rectangle
  68. int XSrc, // x-coord of source upper-left corner
  69. int YSrc, // y-coord of source upper-left corner
  70. int nSrcWidth, // width of source rectangle
  71. int nSrcHeight, // height of source rectangle
  72. byte[] lpBits, // bitmap bits
  73. LPVOID lpBitsInfo, // bitmap data
  74. UINT iUsage, // usage options
  75. DWORD dwRop // raster operation code
  76. );
  77. }
  78. }