static final class FloatBWImage implements MakesBufferedImage, IBWImage { int width, height; float[] pixels; // 0 to 255 usually // color returned when getPixel is called with a position outside the actual image float borderColor = 0.0f; // for unstructure() *() {} // BLACK! *(int *width, int *height) { pixels = new float[width*height]; } *(int *width, int *height, float brightness) { pixels = new float[width*height]; fillArrayUnlessZero(pixels, brightness); } *(int width, int height, float[] pixels) { this.height = height; this.width = width; this.pixels = pixels; } public float getPixel(int x, int y) { return inRange(x, y) ? getPixel_noRangeCheck(x, y) : borderColor; } float getPixel(Pt p) { ret getPixel(p.x, p.y); } private boolean inRange(int x, int y) { return x >= 0 && x < width && y >= 0 && y < height; } public int getWidth() { return width; } int w() { return width; } public int getHeight() { return height; } int h() { return height; } public void setPixel(int x, int y, float brightness) { pixels[y*width+x] = brightness; } float getPixel_noRangeCheck(int x, int y) { return pixels[y*width+x]; } public BufferedImage getBufferedImage() { for (int y = 0; y < height; y++) for (int x = 0; x < width; x++) { int b = ((int) getByte(x, y) & 0xFF); bufferedImage.setRGB(x, y, b*0x010101); } ret bufferedImage; } }