RGB.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. using System;
  2. using System.Drawing;
  3. namespace LYFZ.OtherExpansion.Imaging
  4. {
  5. public class RGB
  6. {
  7. public const short RIndex = 2;
  8. public const short GIndex = 1;
  9. public const short BIndex = 0;
  10. private byte _r;
  11. private byte _g;
  12. private byte _b;
  13. public byte R
  14. {
  15. get
  16. {
  17. return this._r;
  18. }
  19. set
  20. {
  21. this._r = value;
  22. }
  23. }
  24. public byte G
  25. {
  26. get
  27. {
  28. return this._g;
  29. }
  30. set
  31. {
  32. this._g = value;
  33. }
  34. }
  35. public byte B
  36. {
  37. get
  38. {
  39. return this._b;
  40. }
  41. set
  42. {
  43. this._b = value;
  44. }
  45. }
  46. public Color Color
  47. {
  48. get
  49. {
  50. return Color.FromArgb((int)this._r, (int)this._g, (int)this._b);
  51. }
  52. set
  53. {
  54. this._r = value.R;
  55. this._g = value.G;
  56. this._b = value.B;
  57. }
  58. }
  59. public RGB()
  60. {
  61. }
  62. public RGB(byte r, byte g, byte b)
  63. {
  64. this._r = r;
  65. this._g = g;
  66. this._b = b;
  67. }
  68. public RGB(Color color)
  69. {
  70. this._r = color.R;
  71. this._g = color.G;
  72. this._b = color.B;
  73. }
  74. public override string ToString()
  75. {
  76. return string.Format("RGB [R={0}, G={1}, B={2}]", this._r, this._g, this._b);
  77. }
  78. }
  79. }