sclass Hi15Image is MakesBufferedImage { int w; short[] pixels; *() {} // for persistence // TODO: optimize! *(BufferedImage img) { this(RGBImage(img)); } *(RGBImage img) { w = img.getWidth(); int h = img.getHeight(); pixels = new byte[w*h]; for y to h: for x to w: pixels[y*w+x] = rgbToHi15(img.getInt(x, y)); } public int getWidth() { ret w; } public int getHeight() { ret h(); } int h() { ret l(pixels)/w; } 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(pixels[i++])); ret img; } public BufferedImage getBufferedImage() { ret toRGB().getBufferedImage(); } // 0 to 32767 short getHi15Pixel(int x, int y) { ret pixels[y*w+x]; } }