/** * Makes the Mandelbrot image. * * @param width the width * @parah height the height * @return the image */ public BufferedImage makeMandelbrot(int width, int height) { BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); WritableRaster raster = image.getRaster(); ColorModel model = image.getColorModel(); Color fractalColor = Color.red; int argb = fractalColor.getRGB(); Object colorData = model.getDataElements(argb, null); for (int i = 0; i < width; i++) for (int j = 0; j < height; j++) { double a = XMIN + i * (XMAX - XMIN) / width; double b = YMIN + j * (YMAX - YMIN) / height; if (!escapesToInfinity(a, b)) raster.setDataElements(i, j, colorData); } return image; }
public DisplayImage16(int w, int h) { this(); iWidth = w; iHeight = h; iSize = iWidth * iHeight; imageBufferArray = new short[iSize]; for (int i = 0; i < iSize; i++) { imageBufferArray[i] = 0; } bImage = new BufferedImage(iWidth, iHeight, BufferedImage.TYPE_USHORT_GRAY); bRaster = bImage.getRaster(); bRaster.setDataElements(0, 0, iWidth, iHeight, imageBufferArray); // buffGraphics = (Graphics2D) bImage.createGraphics(); // buffGraphics.setFont(font); this.setPreferredSize(new Dimension(iWidth, iHeight)); setVisible(true); // this.setBorder(BorderFactory.createLoweredBevelBorder()); }
public void updateImage(short[] imageData) { bRaster.setDataElements(0, 0, iWidth, iHeight, imageData); repaint(); }