String[] (BufferedImage image, EffectPainter2D painter, Paint foreground, int offset) { int width = image.getWidth(); int height = image.getHeight(); double width2D = width; double height2D = height; double offset2D = offset; // prepare buffers String[] content = new String[width]; char[] chars = new char[height]; if (image instanceof JBHiDPIScaledImage) { double scale = ((JBHiDPIScaledImage)image).getScale(); width2D = width / scale; height2D = height / scale; offset2D = offset / scale; } Graphics2D graphics = image.createGraphics(); // clear image content graphics.setPaint(BACKGROUND); RectanglePainter2D.FILL.paint(graphics, 0, 0, width2D, height2D); if (painter != null) { // paint image content boolean over = painter == EffectPainter2D.STRIKE_THROUGH; // paint over baseline graphics.setPaint(foreground); painter.paint(graphics, offset2D, over ? height2D : 0, width2D - offset2D, height2D, null); } graphics.dispose(); // convert content int bg = BACKGROUND.getRGB(); int fg = FOREGROUND.getRGB(); for (int x = 0; x < content.length; x++) { for (int y = 0; y < chars.length; y++) { int rgb = image.getRGB(x, y); chars[y] = rgb == bg ? ' ' : rgb == fg ? '0' : '.'; } content[x] = new String(chars); } return content; }