-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: copy screenshot image to clipboard
- Loading branch information
1 parent
b1ce4b5
commit 96cc791
Showing
2 changed files
with
60 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/client/java/dev/spiritstudios/snapper/mixinsupport/ImageTransferable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package dev.spiritstudios.snapper.mixinsupport; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.awt.*; | ||
import java.awt.datatransfer.DataFlavor; | ||
import java.awt.datatransfer.Transferable; | ||
import java.awt.datatransfer.UnsupportedFlavorException; | ||
import java.io.IOException; | ||
|
||
public class ImageTransferable implements Transferable { | ||
private static final DataFlavor[] flavors = {DataFlavor.imageFlavor}; | ||
|
||
private final Image image; | ||
|
||
public ImageTransferable(Image im) { | ||
this.image = im; | ||
} | ||
|
||
@Override | ||
public DataFlavor[] getTransferDataFlavors() { | ||
return flavors; | ||
} | ||
|
||
@Override | ||
public boolean isDataFlavorSupported(DataFlavor flavor) { | ||
return flavor.equals(DataFlavor.imageFlavor); | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException { | ||
if (!isDataFlavorSupported(flavor)) throw new UnsupportedFlavorException(flavor); | ||
return image; | ||
} | ||
} |