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

54
LINES

< > BotCompany Repo | #1010759 // Screenshot Quick Select [new image server, uses JPG]

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Uses 3874K of libraries. Click here for Pure Java version (12351L/88K/299K).

!7

static ImageSurface imageSurface;
static JButton btnUpload;
static JFrame frame;
static JLabel lStatus;

concept Title {
  S title;
}

p-subst {
  concepts();
  final BufferedImage img = shootScreenHidingConsole();
  awt {
    ImageSurface.verbose = true;
    
    imageSurface = new ImageSurface(img) {
      public void setSelection(Rectangle r) {
        super.setSelection(r);
        btnUpload.setText(r != null ? "Upload (selected area)" : "Upload");
        lStatus.setText(r == null ? "" : str(new Rect(r)));
      }
    };
    
    JPanel buttons = jcenteredline(
      lStatus = jlabel(),
      btnUpload = jbutton("Upload", r {
        String title = or2(uniq(Title).title, "A screenshot");
        title = JOptionPane.showInputDialog(null, "Please enter screenshot title", title);
        if (title == null) return;
        BufferedImage image = imageSurface.getImage();
        if (imageSurface.getSelection() != null)
          image = new RGBImage(image).clip(imageSurface.getSelection()).getBufferedImage();
        cset(uniq(Title), +title);
        S url = uploadJPEGToImageServer(image, title);
        popup("Image uploaded: " + url);
      }),
      jbutton("Shoot again", r {
        hideFrame(frame);
        swingLater(1000, r {
          imageSurface.setImage(shootScreen2());
          makeFrameVisible(imageSurface);
          maximizeFrame(imageSurface);
        });
      })
    );
  
    frame = showMaximizedFrame(centerAndSouth(
      new JScrollPane(imageSurface), buttons));
      
    if (amFirstProgram()) hideConsole();
  }
}

Author comment

Began life as a copy of #1004147

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, nnmtytuibrzp, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1010759
Snippet name: Screenshot Quick Select [new image server, uses JPG]
Eternal ID of this version: #1010759/5
Text MD5: fa05caf378a39fd8387cf694869170a3
Transpilation MD5: 0988ef906dda1037df52789ca4ed85d7
Author: stefan
Category: javax / gui
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-05-06 17:49:34
Source code size: 1619 bytes / 54 lines
Pitched / IR pitched: No / No
Views / Downloads: 426 / 724
Version history: 4 change(s)
Referenced in: [show references]