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

71
LINES

< > BotCompany Repo | #1005389 // Mark Screenshot Sections [works]

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

Libraryless. Click here for Pure Java version (7593L/51K/165K).

1  
!752
2  
3  
concepts.
4  
5  
!include #1005393 // Marked Screenshot Classes
6  
7  
static ImageSurface imageSurface;
8  
static JButton btnMark;
9  
static JFrame frame;
10  
static BufferedImage img;
11  
static BWImage bwImage;
12  
static Screenshot screenshot;
13  
static JTextField tfDesc;
14  
15  
svoid makeScreenshot {
16  
  img = shootScreen2();
17  
  screenshot = new Screenshot(img);
18  
  bwImage = new BWImage(img);
19  
}
20  
21  
p {
22  
  concepts();
23  
  
24  
  screenshot = last(list(Screenshot));
25  
  if (screenshot != null) {
26  
    // keep working with last screenshot
27  
    img = loadImage2(screenshot.pngFile());
28  
    bwImage = new BWImage(img);
29  
  } else
30  
    // make new one
31  
    makeScreenshot();
32  
33  
  imageSurface = new ImageSurface(img) {
34  
    public void setSelection(Rectangle r) {
35  
      super.setSelection(r);
36  
      btnMark.setEnabled(r != null);
37  
    }
38  
  };
39  
  
40  
  JPanel buttons = jcenteredline(
41  
    jMinWidth(300, onEnter(tfDesc = new JTextField, "mark")),
42  
    btnMark = jbutton("Mark", "mark"),
43  
    jbutton("Shoot again", r {
44  
      hideFrame(frame);
45  
      swingLater(5000, r {
46  
        makeScreenshot();
47  
        imageSurface.setImage(img);
48  
        makeFrameVisible(imageSurface);
49  
        maximizeFrame(imageSurface);
50  
      });
51  
    })
52  
  );
53  
  
54  
  frame = showMaximizedFrame(centerAndSouth(
55  
    new JScrollPane(imageSurface), buttons));
56  
}
57  
58  
svoid mark {
59  
  Rectangle r = imageSurface.getSelection();
60  
  if (r == null) ret;
61  
  
62  
  S desc = tfDesc.getText().trim();
63  
  cnew(MarkedClip, +screenshot,
64  
    positionInScreenshot := new Rect(r),
65  
    img := bwImage.clip(r),
66  
    description := desc);
67  
  showAnimation("#1005392", quote(desc), 1);
68  
  print("Marked clip! " + quote(desc) + " (" + r + ")");
69  
  tfDesc.selectAll();
70  
  tfDesc.requestFocus();
71  
}

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, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1005389
Snippet name: Mark Screenshot Sections [works]
Eternal ID of this version: #1005389/1
Text MD5: 62a7b9486064bae34b516756f6e75331
Transpilation MD5: fa334adf45028f08e337625f77abd7a7
Author: stefan
Category: javax / ocr
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-11-26 01:40:04
Source code size: 1730 bytes / 71 lines
Pitched / IR pitched: No / No
Views / Downloads: 562 / 1904
Referenced in: [show references]