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

15
LINES

< > BotCompany Repo | #1035797 // clipboardContainsImage

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

Libraryless. Click here for Pure Java version (9460L/52K).

sbool clipboardContainsImage() false on exception {
  Transferable t = rawClipboardContents();
  if (t == null) false;
  
  // Try image flavor
  if (t.isDataFlavorSupported(DataFlavor.imageFlavor)) true;
  
  // Try image file
  L<File> l = cast getTransferData(t, DataFlavor.javaFileListFlavor);
  if (isImageFile(first(l))) true;
  
  // Try image as data URL
  S text = getTextFromClipboard();
  ret isImageMimeType(dataURLMimeType(text));
}

Author comment

Began life as a copy of #1006059

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): elmgxqgtpvxh, mqqgnosmbjvj, wnsclhtenguj

No comments. add comment

Snippet ID: #1035797
Snippet name: clipboardContainsImage
Eternal ID of this version: #1035797/3
Text MD5: ba4634dd18b5e2422e68f332adff4924
Transpilation MD5: bd0909a067557c4adab35895de0194db
Author: stefan
Category: javax / clipboard
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-07-29 19:25:58
Source code size: 459 bytes / 15 lines
Pitched / IR pitched: No / No
Views / Downloads: 145 / 204
Version history: 2 change(s)
Referenced in: [show references]