#pragma once

#include <X11/Xlib.h>

#include <string>
#include <vector>

#include "screen.hh"

namespace uw {
  typedef unsigned char uchar;
  typedef unsigned long ulong;

  typedef struct Extent3D {
    int width;
    int height;
    int depth;
  } Extent3D;

  class Image {
    public:
      Image(Screen &screen, const std::string imgPath);
      ~Image();

      Visual *getVisual() { return v; }
      XImage *getImage() { return image; }
      GC getGC() { return gc; }
      Pixmap getPixmap() { return pm; }
      Extent3D getExtent() { return imageExtent; }
      uchar *getImageData() { return data; }
      std::string getImagePath() { return imagePath; }

    private:
      void createDepth();
      void createPixmap();
      void createImage();
      void createGC();

      Visual *v;
      XImage *image;
      GC gc;
      Pixmap pm;

      uchar *data = nullptr;
      std::vector<uchar> cdata;
      Extent3D imageExtent;
      int chan;
      int width;
      int height;
      int depth;
      std::string imagePath;

      Screen &uwScreen;
  };
}
