ColorImage.cs 944 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Drawing;
  7. namespace bbiwarg.Images
  8. {
  9. class ColorImage
  10. {
  11. private int width, height;
  12. private byte[] data;
  13. public ColorImage(int width, int height, byte[] data)
  14. {
  15. this.width = width;
  16. this.height = height;
  17. this.data = data;
  18. }
  19. public int getWidth()
  20. {
  21. return width;
  22. }
  23. public int getHeight()
  24. {
  25. return height;
  26. }
  27. public Color getColor(int x, int y)
  28. {
  29. int offset = 4 * (y * width + x);
  30. byte alpha = data[offset + 3];
  31. byte red = data[offset + 2];
  32. byte green = data[offset + 1];
  33. byte blue = data[offset + 0];
  34. return Color.FromArgb(alpha, red, green, blue);
  35. }
  36. }
  37. }