From c97a3038f282aa82506232129bd649903e8909ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beatrice=20Dellac=C3=A0?= Date: Tue, 6 Aug 2024 00:35:46 +0200 Subject: [PATCH] change multiple small things --- pom.xml | 19 ++++++++++++ .../beatrice/autosqueal/ui/MainWindow.java | 31 ++++++++++++++++++- .../beatrice/autosqueal/util/SystemUtil.java | 4 ++- 3 files changed, 52 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 3c92719..c77a230 100644 --- a/pom.xml +++ b/pom.xml @@ -61,4 +61,23 @@ + + + central + https://repo1.maven.org/maven2/ + + + + sonatype-nexus-snapshots + https://oss.sonatype.org/content/repositories/snapshots + + + + + + sonatype-nexus-snapshots + https://oss.sonatype.org/content/repositories/snapshots + + + diff --git a/src/main/java/wtf/beatrice/autosqueal/ui/MainWindow.java b/src/main/java/wtf/beatrice/autosqueal/ui/MainWindow.java index a04ca22..b86da19 100644 --- a/src/main/java/wtf/beatrice/autosqueal/ui/MainWindow.java +++ b/src/main/java/wtf/beatrice/autosqueal/ui/MainWindow.java @@ -45,10 +45,15 @@ public class MainWindow imageLabel.setBounds(new Rectangle(bordersPx, bordersPx, rescaleWidth, rescaleHeight)); frame.add(imageLabel); - JLabel timestampLabel = new JLabel(new ImageIcon(getPreciseScreenshot())); + Image preciseScreenshot = getPreciseScreenshot(); + JLabel timestampLabel = new JLabel(new ImageIcon(preciseScreenshot)); timestampLabel.setBounds(new Rectangle(bordersPx, bordersPx + rescaleHeight + bordersPx, 100, 30)); frame.add(timestampLabel); + String ocr = doOCR(preciseScreenshot); + LOGGER.info("OCR FOUND : {}", ocr); + + frame.setLayout(null); frame.setVisible(true); } @@ -80,6 +85,30 @@ public class MainWindow return null; } + public String doOCR(Image image) { + // todo BufferedImage bImage = getBufferedImage(image); + + return null; + } + + public BufferedImage getBufferedImage(Image img) { + if (img instanceof BufferedImage image) + { + return image; + } + + // Create a buffered image with transparency + BufferedImage bimage = new BufferedImage(img.getWidth(null), img.getHeight(null), BufferedImage.TYPE_INT_ARGB); + + // Draw the image on to the buffered image + Graphics2D bGr = bimage.createGraphics(); + bGr.drawImage(img, 0, 0, null); + bGr.dispose(); + + // Return the buffered image + return bimage; + } + public void toggleRunning() { String label; diff --git a/src/main/java/wtf/beatrice/autosqueal/util/SystemUtil.java b/src/main/java/wtf/beatrice/autosqueal/util/SystemUtil.java index 1553e70..4df5939 100644 --- a/src/main/java/wtf/beatrice/autosqueal/util/SystemUtil.java +++ b/src/main/java/wtf/beatrice/autosqueal/util/SystemUtil.java @@ -9,7 +9,9 @@ public class SystemUtil String osName = System.getProperty("os.name").toLowerCase(Locale.ENGLISH); if (osName.contains("win")) { return OperatingSystem.WINDOWS; - } else if (osName.contains("nix") || osName.contains("nux")) { + } else if (osName.contains("nix") || + osName.contains("nux") || + osName.contains("aix")) { return OperatingSystem.LINUX; } else if (osName.contains("mac")) { return OperatingSystem.MAC_OS;