/** Creates a new instance of IDEJRManFramebufferImpl */
  public IDEJRManFramebufferImpl(String name, BufferedImage image) {
    super("JRMan rendered: " + name, true, true, true, true);
    this.name = name;

    save.setEnabled(false);

    imagePanel.setImage(image);
    imagePanel.addToolbarAction(save);
    if (image.getType() == BufferedImage.TYPE_INT_ARGB
        || image.getType() == BufferedImage.TYPE_INT_ARGB_PRE) {
      imagePanel.setShowTransparencyPattern(true);
    }

    getRootPane().setDoubleBuffered(false);
    getContentPane().add(imagePanel);
    pack();

    ImageResource images = ImageResource.getInstance();

    // set the frame icon
    setFrameIcon(images.getJrMan());

    // add this to the IDE desktop
    MainMenuEventHandlers.getInstance(null)
        .getIdeInstance()
        .getWorkspaceDesktop()
        .addInternalFrame(this, true);
  }
示例#2
0
 static BufferedImage addMagnitudes(BufferedImage img1, BufferedImage img2) {
   BufferedImage dst = new BufferedImage(img1.getWidth(), img1.getHeight(), img1.getType());
   for (int y = 0; y < img1.getHeight(); ++y) {
     for (int x = 0; x < img1.getWidth(); ++x) {
       int rgb1 = img1.getRGB(x, y);
       int rgb2 = img2.getRGB(x, y);
       int r1 = (rgb1 & 0x00FF0000) >> 16;
       int r2 = (rgb2 & 0x00FF0000) >> 16;
       int r = (int) (Math.sqrt(r1 * r1 + r2 * r2) / Math.sqrt(2.0));
       if (r > 255) r = 255;
       if (r < 0) r = 0;
       int g1 = (rgb1 & 0x0000FF00) >> 8;
       int g2 = (rgb2 & 0x0000FF00) >> 8;
       int g = (int) (Math.sqrt(g1 * g1 + g2 * g2) / Math.sqrt(2.0));
       if (g > 255) g = 255;
       if (g < 0) g = 0;
       int b1 = rgb1 & 0x000000FF;
       int b2 = rgb2 & 0x000000FF;
       int b = (int) (Math.sqrt(b1 * b1 + b2 * b2) / Math.sqrt(2.0));
       if (b > 255) b = 255;
       if (b < 0) b = 0;
       int rgb = b + (g << 8) + (r << 16);
       dst.setRGB(x, y, rgb);
     }
   }
   return dst;
 }
示例#3
0
  private BufferedImage convert(BufferedImage image, int imageType) {
    if (image.getType() == imageType) {
      return image;
    }

    int w = image.getWidth();
    int h = image.getHeight();
    BufferedImage newImg = new BufferedImage(w, h, imageType);
    ColorSpace srcSpace = image.getColorModel().getColorSpace();
    ColorSpace newSpace = newImg.getColorModel().getColorSpace();
    ColorConvertOp convert = new ColorConvertOp(srcSpace, newSpace, null);
    convert.filter(image, newImg);
    return newImg;
  }
示例#4
0
 private static void initImg(BufferedImage img, int pf, int flags) throws Exception {
   WritableRaster wr = img.getRaster();
   int imgType = img.getType();
   if (imgType == BufferedImage.TYPE_INT_RGB
       || imgType == BufferedImage.TYPE_INT_BGR
       || imgType == BufferedImage.TYPE_INT_ARGB
       || imgType == BufferedImage.TYPE_INT_ARGB_PRE) {
     SinglePixelPackedSampleModel sm = (SinglePixelPackedSampleModel) img.getSampleModel();
     int pitch = sm.getScanlineStride();
     DataBufferInt db = (DataBufferInt) wr.getDataBuffer();
     int[] buf = db.getData();
     initIntBuf(buf, img.getWidth(), pitch, img.getHeight(), pf, flags);
   } else {
     ComponentSampleModel sm = (ComponentSampleModel) img.getSampleModel();
     int pitch = sm.getScanlineStride();
     DataBufferByte db = (DataBufferByte) wr.getDataBuffer();
     byte[] buf = db.getData();
     initBuf(buf, img.getWidth(), pitch, img.getHeight(), pf, flags);
   }
 }