BitmapData.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. //
  2. // System.Drawing.Imaging.BitmapData.cs
  3. //
  4. // Author:
  5. // Miguel de Icaza ([email protected]
  6. //
  7. // (C) 2002 Ximian, Inc. http://www.ximian.com
  8. //
  9. using System;
  10. using System.Runtime.InteropServices;
  11. using System.IO;
  12. namespace System.Drawing.Imaging
  13. {
  14. // MUST BE KEPT IN SYNC WITH gdip.h in libgdiplus!
  15. [StructLayout(LayoutKind.Sequential)]
  16. public sealed class BitmapData {
  17. internal int width, height, stride;
  18. internal PixelFormat pixel_format;
  19. internal IntPtr address;
  20. internal int reserved;
  21. internal bool own_scan0;
  22. ~BitmapData()
  23. {
  24. if (address != IntPtr.Zero && own_scan0) {
  25. GDIPlus.GdipFree (address);
  26. address = IntPtr.Zero;
  27. }
  28. }
  29. public int Height {
  30. get {
  31. return height;
  32. }
  33. set {
  34. height = value;
  35. }
  36. }
  37. public int Width {
  38. get {
  39. return width;
  40. }
  41. set {
  42. width = value;
  43. }
  44. }
  45. public PixelFormat PixelFormat {
  46. get {
  47. return pixel_format;
  48. }
  49. set {
  50. pixel_format = value;
  51. }
  52. }
  53. public int Reserved {
  54. get {
  55. return reserved;
  56. }
  57. set {
  58. reserved = value;
  59. }
  60. }
  61. public IntPtr Scan0 {
  62. get {
  63. return address;
  64. }
  65. set {
  66. if (address == value)
  67. return;
  68. // FIXME -- do we really want to prevent the
  69. // user from shooting themselves in the foot,
  70. // if they want to?
  71. if (address != IntPtr.Zero && own_scan0) {
  72. GDIPlus.GdipFree (address);
  73. address = IntPtr.Zero;
  74. }
  75. address = value;
  76. }
  77. }
  78. public int Stride {
  79. get {
  80. return stride;
  81. }
  82. set {
  83. stride = value;
  84. }
  85. }
  86. }
  87. }