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

25
LINES

< > BotCompany Repo | #1007126 // toBufferedImageOpt

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

Libraryless. Click here for Pure Java version (6326L/37K).

1  
static BufferedImage toBufferedImageOpt(O o) {
2  
  if (o cast BufferedImage) ret o;
3  
  if (o cast Image) ret copyImage(o);
4  
  if (o cast MakesBufferedImage)
5  
    ret o.getBufferedImage();
6  
    
7  
  ifdef toBufferedImageOpt_acceptFile
8  
  if (o cast File)
9  
    if (isImageFile(o))
10  
      ret loadBufferedImageFile(o);
11  
  endifdef
12  
      
13  
  S c = getClassName(o);
14  
  
15  
  // Keep this because it also works on imported objects
16  
  if (eqOneOf(c, "main$BWImage", "main$RGBImage"))
17  
    ret (BufferedImage) call(o, "getBufferedImage");
18  
 
19  
  ifdef PNGFile // Who uses this anymore?   
20  
  if (eq(c, "main$PNGFile"))
21  
    ret (BufferedImage) call(o, "getImage");
22  
  endifdef
23  
  
24  
  ret null;
25  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1007126
Snippet name: toBufferedImageOpt
Eternal ID of this version: #1007126/11
Text MD5: f7a8619c771fa5f72a346feb3196aa22
Transpilation MD5: 291fc0e0e26715e5b8c01fa00a3f8412
Author: stefan
Category: javax / imaging
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-03-13 02:51:04
Source code size: 684 bytes / 25 lines
Pitched / IR pitched: No / No
Views / Downloads: 547 / 669
Version history: 10 change(s)
Referenced in: [show references]