Skip to content

Commit fc4d82b

Browse files
committed
imageviewer: screenresolution to bound window
1 parent c14cbf3 commit fc4d82b

File tree

3 files changed

+22
-11
lines changed

3 files changed

+22
-11
lines changed

src/main/java/org/hvdw/jexiftoolgui/Utils.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,17 @@ public static int[] getResolution() {
178178
return res;
179179
}
180180

181+
/*
182+
/ Base function to get screen bounds (resolution minus taskbar and/or menu bar
183+
*/
184+
public static Rectangle getScreenBounds() {
185+
GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
186+
Rectangle bounds = env.getMaximumWindowBounds();
187+
logger.debug("MyVariables.getScreenWidth {} MyVariables.getScreenHeight {} Screen Bounds {}", MyVariables.getScreenWidth(), MyVariables.getScreenHeight(), bounds);
188+
189+
return bounds;
190+
}
191+
181192
/*
182193
* Opens the default browser of the Operating System
183194
* and displays the specified URL

src/main/java/org/hvdw/jexiftoolgui/controllers/ImageFunctions.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ public Void doInBackground() {
192192
public void done() {
193193
logger.debug("Finished reading all the metadata in the background");
194194
progressBar.setVisible(false);
195-
mainScreenLabels[0].setText(ResourceBundle.getBundle("translations/program_strings").getString("pt.finishedreadingmetadatabackground"));
195+
mainScreenLabels[0].setText(ResourceBundle.getBundle("translations/program_strings").getString("pt.finishedreadingmetadabackground"));
196196
buttonSearchMetadata.setEnabled(true);
197197
}
198198
};
@@ -413,7 +413,8 @@ public static ImageIcon analyzeImageAndCreateIcon (File file) {
413413
icon = new ImageIcon(resizedImg);
414414
// Save our created icon
415415
if ( (filenameExt.toLowerCase().equals("jpg")) || (filenameExt.toLowerCase().equals("jpeg")) ) {
416-
StandardFileIO.saveIconToCache(filename, resizedImg);
416+
BufferedImage thumbImg = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(),BufferedImage.TYPE_INT_RGB);
417+
StandardFileIO.saveIconToCache(filename, thumbImg);
417418
} else { //tiff
418419
//BufferedImage thumbImg = new BufferedImage(icon);
419420
BufferedImage thumbImg = new BufferedImage(resizedImg.getWidth(), resizedImg.getHeight(), BufferedImage.OPAQUE);

src/main/java/org/hvdw/jexiftoolgui/view/JavaImageViewer.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,15 @@ public class JavaImageViewer {
3232
private BufferedImage ResizeImage(File image, int orientation) {
3333

3434
int scrwidth = MyVariables.getScreenWidth();
35-
int scrheight = MyVariables.getScreenHeight();
35+
int scrheight = MyVariables.getScreenHeight()-50;
36+
Rectangle screenBounds = Utils.getScreenBounds();
3637
try {
3738
BufferedImage img = ImageIO.read(new File(image.getPath().replace("\\", "/")));
3839
if (orientation > 1) {
3940
resizedImg = ImageFunctions.rotate(img, orientation);
40-
resizedImg = ImageFunctions.scaleImageToContainer(resizedImg, scrwidth, scrheight);
41+
resizedImg = ImageFunctions.scaleImageToContainer(resizedImg, screenBounds.width, screenBounds.height);
4142
} else { // No rotation necessary
42-
resizedImg = ImageFunctions.scaleImageToContainer(img, scrwidth, scrheight);
43+
resizedImg = ImageFunctions.scaleImageToContainer(img, screenBounds.width, screenBounds.height);
4344
}
4445
} catch (IOException iex) {
4546
logger.error("error in resizing the image {}", iex);
@@ -283,21 +284,19 @@ public void actionPerformed(ActionEvent actionEvent) {
283284

284285

285286

287+
Rectangle screenBounds = Utils.getScreenBounds();
286288

287289
thePanel.add(InfoPanel, BorderLayout.PAGE_START);
288290
ImageIcon icon = new ImageIcon(resizedImg);
289291
ImgLabel.setIcon(icon);
290292
thePanel.add(ImgLabel, BorderLayout.CENTER);
291293
thePanel.add(buttonPanel, BorderLayout.PAGE_END);
292294
//thePanel.setPreferredSize(new Dimension(panelWidth, panelHeight));
293-
thePanel.setPreferredSize(new Dimension(MyVariables.getScreenWidth(), MyVariables.getScreenHeight() - 30));
295+
thePanel.setPreferredSize(new Dimension(screenBounds.width, screenBounds.height - 30));
294296
frame.add(thePanel);
295297

296-
//if (!frameborder) {
297-
frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
298-
//frame.setUndecorated(true) will create a borderless window. Only use in slideshow where we have buttons anyway.
299-
frame.setUndecorated(true);
300-
//}
298+
299+
frame.setLocation(0,0);
301300
frame.pack();
302301
frame.setVisible(true);
303302

0 commit comments

Comments
 (0)