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

32
LINES

< > BotCompany Repo | #1005730 // concept PNGFile

JavaX fragment (include)

1  
sclass PNGFile extends Concept {
2  
  S pngPath; // program ID + "/" + file name
3  
  Rect r; // optional, rectangle that was shot
4  
  
5  
  *() {} // for persistance
6  
  *(S *pngPath) {}
7  
  ifclass RGBImage
8  
    *(RGBImage img) { this(img.getBufferedImage()); }
9  
  endif
10  
11  
  File pngFile() {
12  
    if (pngPath == null) {
13  
      pngPath = _programID() + "/" + id + ".png";
14  
      change();
15  
    }
16  
    ret prepareFile(new File(javaxDataDir(), pngPath));
17  
  }
18  
  
19  
  ifndef Android
20  
  PNGFile(BufferedImage img) {
21  
    savePNG(pngFile(), img);
22  
  }
23  
  BufferedImage loadImage() { ret loadImage2(pngFile()); }
24  
  BufferedImage getImage() { ret loadImage(); }
25  
  BufferedImage getImageSafe() { pcall { ret loadImage(); } null; }
26  
  S md5() { pcall { ret md5OfBufferedImage(getImage()); } ret "-"; }
27  
  endifndef
28  
  
29  
  bool hasImage() {
30  
    ret pngFile().exists();
31  
  }
32  
}

Author comment

Began life as a copy of #1005728

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1005730
Snippet name: concept PNGFile
Eternal ID of this version: #1005730/14
Text MD5: 54cf9488cae2f571636f67ecab560ac4
Author: stefan
Category: javax / concepts / imaging
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-05-24 14:03:49
Source code size: 864 bytes / 32 lines
Pitched / IR pitched: No / No
Views / Downloads: 613 / 4397
Version history: 13 change(s)
Referenced in: [show references]