ColorImage.cs 865 B

1234567891011121314151617181920212223242526272829303132333435363738
  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.DataSource
  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. return Color.FromArgb(data[4 * (y * width + x) + 3], data[4 * (y * width + x) + 2],
  30. data[4 * (y * width + x) + 0], data[4 * (y * width + x) + 1]);
  31. }
  32. }
  33. }