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).

1  
!7
2  
3  
static ImageSurface imageSurface;
4  
static JButton btnUpload;
5  
static JFrame frame;
6  
static JLabel lStatus;
7  
8  
concept Title {
9  
  S title;
10  
}
11  
12  
p-subst {
13  
  concepts();
14  
  final BufferedImage img = shootScreenHidingConsole();
15  
  awt {
16  
    ImageSurface.verbose = true;
17  
    
18  
    imageSurface = new ImageSurface(img) {
19  
      public void setSelection(Rectangle r) {
20  
        super.setSelection(r);
21  
        btnUpload.setText(r != null ? "Upload (selected area)" : "Upload");
22  
        lStatus.setText(r == null ? "" : str(new Rect(r)));
23  
      }
24  
    };
25  
    
26  
    JPanel buttons = jcenteredline(
27  
      lStatus = jlabel(),
28  
      btnUpload = jbutton("Upload", r {
29  
        String title = or2(uniq(Title).title, "A screenshot");
30  
        title = JOptionPane.showInputDialog(null, "Please enter screenshot title", title);
31  
        if (title == null) return;
32  
        BufferedImage image = imageSurface.getImage();
33  
        if (imageSurface.getSelection() != null)
34  
          image = new RGBImage(image).clip(imageSurface.getSelection()).getBufferedImage();
35  
        cset(uniq(Title), +title);
36  
        S url = uploadJPEGToImageServer(image, title);
37  
        popup("Image uploaded: " + url);
38  
      }),
39  
      jbutton("Shoot again", r {
40  
        hideFrame(frame);
41  
        swingLater(1000, r {
42  
          imageSurface.setImage(shootScreen2());
43  
          makeFrameVisible(imageSurface);
44  
          maximizeFrame(imageSurface);
45  
        });
46  
      })
47  
    );
48  
  
49  
    frame = showMaximizedFrame(centerAndSouth(
50  
      new JScrollPane(imageSurface), buttons));
51  
      
52  
    if (amFirstProgram()) hideConsole();
53  
  }
54  
}

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: 428 / 727
Version history: 4 change(s)
Referenced in: [show references]