diff --git a/image.d b/image.d index 13a7662..ab80c79 100644 --- a/image.d +++ b/image.d @@ -19,123 +19,5 @@ module arsd.image; */ +// the basic image definitions have all been moved to the color module public import arsd.color; - -interface Image { - //IndexedImage convertToIndexedImage() const; - //TrueColorImage convertToTrueColor() const; - TrueColorImage getAsTrueColorImage(); -} - -class IndexedImage : Image { - bool hasAlpha; - Color[] palette; - ubyte[] data; - - int width; - int height; - - this(int w, int h) { - width = w; - height = h; - data = new ubyte[w*h]; - } - - /* - void resize(int w, int h, bool scale) { - - } - */ - - override TrueColorImage getAsTrueColorImage() { - return convertToTrueColor(); - } - - TrueColorImage convertToTrueColor() const { - auto tci = new TrueColorImage(width, height); - foreach(i, b; data) { - tci.imageData.colors[i] = palette[b]; - } - return tci; - } - - ubyte getOrAddColor(Color c) { - foreach(i, co; palette) { - if(c == co) - return cast(ubyte) i; - } - - return addColor(c); - } - - int numColors() const { - return palette.length; - } - - ubyte addColor(Color c) { - assert(palette.length < 256); - if(c.a != 255) - hasAlpha = true; - palette ~= c; - - return cast(ubyte) (palette.length - 1); - } -} - -class TrueColorImage : Image { -// bool hasAlpha; -// bool isGreyscale; - //ubyte[] data; // stored as rgba quads, upper left to right to bottom - union Data { - ubyte[] bytes; - Color[] colors; - - static assert(Color.sizeof == 4); - } - - Data imageData; - alias imageData.bytes data; - - int width; - int height; - - this(int w, int h) { - width = w; - height = h; - imageData.bytes = new ubyte[w*h*4]; - } - - override TrueColorImage getAsTrueColorImage() { - return this; - } - -/+ - IndexedImage convertToIndexedImage(int maxColors = 256) { - - } -+/ -} - -/** - Operations take a mask, which tells them where to apply. - - ImageMask.All means to just apply it - -*/ - -/+ -struct ImageMask { - int width; - int height; - int left; - int top; - enum Shape { Rect, Custom } - - // Fills in each line, from the far left most set bit to the far right. - // So you can take an outline, do filled and affect it all - ImageMask filled() { - - } -} -+/ -//TrueColorImage gradient