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

22
LINES

< > BotCompany Repo | #1003962 // savePNG

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (4789L/27K).

static void savePNG(BufferedImage img, File file) ctex {
  File tempFile = new File(file.getPath() + "_temp");
  CriticalAction ca = beginCriticalAction("Save " + f2s(file));
  try {
    ImageIO.write(img, "png", mkdirsFor(tempFile));
    file.delete();
    tempFile.renameTo(file);
  } finally {
    ca.done();
  }
}

// gotta love convenience & program-smartness
static void savePNG(File etc file, BufferedImage img) {
  savePNG(img, file);
}

ifclass RGBImage
static void savePNG(File file, RGBImage img) {
  savePNG(file, img.getBufferedImage());
}
endif

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1003962
Snippet name: savePNG
Eternal ID of this version: #1003962/9
Text MD5: d96a9e8864bea038dbd521e27975a876
Transpilation MD5: 75f62297081d0df803a58c0741f0afff
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-01-08 19:25:42
Source code size: 579 bytes / 22 lines
Pitched / IR pitched: No / No
Views / Downloads: 694 / 763
Version history: 8 change(s)
Referenced in: [show references]