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

55
LINES

< > BotCompany Repo | #1004147 // Screenshot Quick Select - make a screenshot and allow selection immediately

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

Libraryless. Click here for Pure Java version (9786L/69K/233K).

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

download  show line numbers  debug dex  old transpilations   

Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, sawdedvomwva, tslmcundralx, tvejysmllsmz, vouqrxazstgt

Comments [hide]

ID Author/Program Comment Date
1291 stefan TODO: does not reshoot properly 2016-08-20 15:17:58

add comment

Snippet ID: #1004147
Snippet name: Screenshot Quick Select - make a screenshot and allow selection immediately
Eternal ID of this version: #1004147/1
Text MD5: e7f138d801d1a9cec3264a3017f1853f
Transpilation MD5: 472ce5038dba34a33556497508a4b6e7
Author: stefan
Category: javax / gui
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-07-16 16:52:38
Source code size: 1563 bytes / 55 lines
Pitched / IR pitched: No / No
Views / Downloads: 1097 / 1608
Referenced in: [show references]