sclass Hi15Image extends WidthAndHeightImpl is MakesBufferedImage { short[] pixels; *() {} // for persistence // TODO: optimize! *(BufferedImage img) { this(RGBImage(img)); } *(RGBImage img) { w = img.getWidth(); h = img.getHeight(); pixels = new short[w*h]; for y to h: for x to w: pixels[y*w+x] = rgbToHi15(img.getInt(x, y)); } RGBImage toRGB() { int h = h(); RGBImage img = new RGBImage(w, h); int i = 0; for y to h: for x to w: img.setPixel(x, y, hi15ToRGBInt_dirty(pixels[i++])); ret img; } public BufferedImage getBufferedImage() { ret toRGB().getBufferedImage(); } // 0 to 32767 short getHi15Pixel(int x, int y) { ret pixels[y*w+x]; } }