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

32
LINES

< > BotCompany Repo | #1005730 // concept PNGFile

JavaX fragment (include)

sclass PNGFile extends Concept {
  S pngPath; // program ID + "/" + file name
  Rect r; // optional, rectangle that was shot
  
  *() {} // for persistance
  *(S *pngPath) {}
  ifclass RGBImage
    *(RGBImage img) { this(img.getBufferedImage()); }
  endif

  File pngFile() {
    if (pngPath == null) {
      pngPath = _programID() + "/" + id + ".png";
      change();
    }
    ret prepareFile(new File(javaxDataDir(), pngPath));
  }
  
  ifndef Android
  PNGFile(BufferedImage img) {
    savePNG(pngFile(), img);
  }
  BufferedImage loadImage() { ret loadImage2(pngFile()); }
  BufferedImage getImage() { ret loadImage(); }
  BufferedImage getImageSafe() { pcall { ret loadImage(); } null; }
  S md5() { pcall { ret md5OfBufferedImage(getImage()); } ret "-"; }
  endifndef
  
  bool hasImage() {
    ret pngFile().exists();
  }
}

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: 609 / 4391
Version history: 13 change(s)
Referenced in: [show references]