Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

107
LINES

< > BotCompany Repo | #1001346 // showImage

JavaX fragment (include)

static S showImage_defaultIcon = "#1004230"; // "#1004227";

static ImageSurface showImage(S snippetIDOrURL, S title) {
  return showImage(loadImage(snippetIDOrURL), title);
}

static ImageSurface showImage(S title, BufferedImage img) {
  ret showImage(img, title);
}

static ImageSurface showImage(final BufferedImage img, fS title) {
  ret (ImageSurface) swing(func {
    ImageSurface is = showImage(img);
    getFrame(is).setTitle(title);
    return is;
  });
}

static ImageSurface showImage(final BufferedImage img) {
  ret (ImageSurface) swing(func {
    ImageSurface is = new ImageSurface(img);
    JFrame frame = showPackedFrame(new JScrollPane(is));
    moveToTopRightCorner(frame);
    frameIcon(frame, showImage_defaultIcon);
    return is;
  });
}

static ImageSurface showImage(S imageID) {
  return showImage(loadImage2(imageID));
}

static ImageSurface showImage(ImageSurface surface, BufferedImage img) {
  ret showImage(img, surface);
}

static ImageSurface showImage(ImageSurface surface, S title, BufferedImage img) {
  ret showImage(surface, img, title);
}

static ImageSurface showImage(ImageSurface surface, BufferedImage img, S title) {
  ret setFrameTitle(showImage(img, surface), title);
}

static ImageSurface showImage(BufferedImage img, ImageSurface surface) {
  if (surface == null)
    ret showImage(img);
  else {
    surface.setImage(img);
    ret surface;
  }
}

ifclass MakesBufferedImage
  static ImageSurface showImage(S title, MakesBufferedImage img) {
    return showImage(title, img.getBufferedImage());
  }
  
  static ImageSurface showImage(ImageSurface is, MakesBufferedImage img) {
    return showImage(is, img.getBufferedImage());
  }
  
  static ImageSurface showImage(RGBImage img) {
    return showImage(img.getBufferedImage());
  }
  
  static ImageSurface showImage(RGBImage img, S title) {
    ImageSurface is = showImage(img.getBufferedImage());
    getFrame(is).setTitle(title);
    return is;
  }
  
  static ImageSurface showImage(ImageSurface surface, RGBImage img) {
    ret showImage(img, surface);
  }
  
  static ImageSurface showImage(RGBImage img, ImageSurface surface) {
    if (surface == null)
      ret showImage(img);
    else {
      surface.setImage(img);
      ret surface;
    }
  }
  
  static ImageSurface showImage(ImageSurface surface, S title, RGBImage img) {
    ret showImage(surface, img, title);
  }
  
  static ImageSurface showImage(ImageSurface surface, RGBImage img, S title) {
    ret setFrameTitle(showImage(img, surface), title);
  }
endif

ifclass MakesBufferedImage
  static ImageSurface showImage(MakesBufferedImage img) {
    return showImage(img.getBufferedImage());
  }
endif

static ImageSurface showImage() {
  ret showImage(currentImage());
}

static ImageSurface showImage(File f) {
  ret showImage(f2s(f), loadImage2(f)).setFile(f);
}

download  show line numbers  debug dex  old transpilations   

Travelled to 17 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mowyntqkapby, mqqgnosmbjvj, ofpaelxlmzfo, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1001346
Snippet name: showImage
Eternal ID of this version: #1001346/19
Text MD5: 81dfd137d82dd375ad04248dfc7a5bd3
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-02-26 18:29:34
Source code size: 2937 bytes / 107 lines
Pitched / IR pitched: No / No
Views / Downloads: 1066 / 1476
Version history: 18 change(s)
Referenced in: [show references]