diff options
author | Jakob Heher <jakob.heher@iaik.tugraz.at> | 2022-08-12 10:44:29 +0200 |
---|---|---|
committer | Jakob Heher <jakob.heher@iaik.tugraz.at> | 2022-08-12 10:44:29 +0200 |
commit | b6410288131170760e7e74faa91b50a6557c1482 (patch) | |
tree | 3562cfcb14f9691228603b4a797ed22570cf81db /pdf-over-commons/src/main/java/at/asit/pdfover/commons/utils | |
parent | c4ede06f58b029c997931ecd9c103edf204d4089 (diff) | |
download | pdf-over-b6410288131170760e7e74faa91b50a6557c1482.tar.gz pdf-over-b6410288131170760e7e74faa91b50a6557c1482.tar.bz2 pdf-over-b6410288131170760e7e74faa91b50a6557c1482.zip |
debugDisplayImage for SWT
Diffstat (limited to 'pdf-over-commons/src/main/java/at/asit/pdfover/commons/utils')
-rw-r--r-- | pdf-over-commons/src/main/java/at/asit/pdfover/commons/utils/ImageUtil.java | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/pdf-over-commons/src/main/java/at/asit/pdfover/commons/utils/ImageUtil.java b/pdf-over-commons/src/main/java/at/asit/pdfover/commons/utils/ImageUtil.java index 416e0157..6855a62a 100644 --- a/pdf-over-commons/src/main/java/at/asit/pdfover/commons/utils/ImageUtil.java +++ b/pdf-over-commons/src/main/java/at/asit/pdfover/commons/utils/ImageUtil.java @@ -11,9 +11,17 @@ import java.awt.image.DirectColorModel; import java.awt.image.IndexColorModel; import java.awt.image.WritableRaster; +import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.ImageData; import org.eclipse.swt.graphics.PaletteData; import org.eclipse.swt.graphics.RGB; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.layout.FormAttachment; +import org.eclipse.swt.layout.FormData; +import org.eclipse.swt.layout.FormLayout; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; import javax.imageio.ImageIO; import javax.imageio.ImageReadParam; @@ -167,6 +175,28 @@ public final class ImageUtil { return image; } + public static org.eclipse.swt.graphics.Image debugDisplayImage(org.eclipse.swt.graphics.Image image) { + Display display = Display.getDefault(); + Shell shell = new Shell(display, SWT.CLOSE); + shell.setLayout(new FormLayout()); + + Rectangle imgBounds = image.getBounds(); + Label imgLabel = new Label(shell, SWT.NATIVE); + FormData imgFD = new FormData(); + imgFD.left = new FormAttachment(0); + imgFD.top = new FormAttachment(0); + imgFD.width = imgBounds.width; + imgFD.height = imgBounds.height; + imgLabel.setLayoutData(imgFD); + imgLabel.setImage(image); + + shell.setSize(imgBounds.width + 20, imgBounds.height + 60); + + shell.open(); + shell.forceActive(); + return image; + } + /** * Convert AWT Image to SWT Image * |