Skip to content

Commit

Permalink
2023.07.30 (1.54g8; ImageCanvas.fitToWindow)
Browse files Browse the repository at this point in the history
  • Loading branch information
rasband committed Jul 30, 2023
1 parent f491399 commit b40cfc7
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 18 deletions.
2 changes: 1 addition & 1 deletion ij/ImageJ.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public class ImageJ extends Frame implements ActionListener,

/** Plugins should call IJ.getVersion() or IJ.getFullVersion() to get the version string. */
public static final String VERSION = "1.54g";
public static final String BUILD = "4";
public static final String BUILD = "8";
public static Color backgroundColor = new Color(237,237,237);
/** SansSerif, 12-point, plain font. */
public static final Font SansSerif12 = new Font("SansSerif", Font.PLAIN, 12);
Expand Down
5 changes: 3 additions & 2 deletions ij/gui/ImageCanvas.java
Original file line number Diff line number Diff line change
Expand Up @@ -769,14 +769,15 @@ public void fitToWindow() {
ImageWindow win = imp.getWindow();
if (win==null) return;
Rectangle bounds = win.getBounds();
Insets insets = win.getInsets();
Insets insets = win.getInsets(false); // do not include small window padding
int sliderHeight = win.getSliderHeight();
double xmag = (double)(bounds.width-(insets.left+insets.right+ImageWindow.HGAP*2))/srcRect.width;
double ymag = (double)(bounds.height-(ImageWindow.VGAP*2+insets.top+insets.bottom+sliderHeight))/srcRect.height;
setMagnification(Math.min(xmag, ymag));
int width=(int)(imageWidth*magnification);
int height=(int)(imageHeight*magnification);
if (width==dstWidth&&height==dstHeight) return;
if (width==dstWidth && height==dstHeight)
return;
srcRect=new Rectangle(0,0,imageWidth, imageHeight);
setSize(width, height);
getParent().doLayout();
Expand Down
19 changes: 14 additions & 5 deletions ij/gui/ImageWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -257,16 +257,25 @@ public double getInitialMagnification() {
return initialMagnification;
}

/** Override Container getInsets() to make room for some text above the image. */
public Insets getInsets() {
return getInsets(true);
}

/** Override Container getInsets() to make room for some text above the image.
* With "includeSmallImageMargins", also includes the margins for padding an image
* that is too small for the window size. */
public Insets getInsets(boolean includeSmallImageMargins) {
Insets insets = super.getInsets();
if (imp==null)
return insets;
double mag = ic.getMagnification();
int extraWidth = (int)((MIN_WIDTH - imp.getWidth()*mag)/2.0);
if (extraWidth<0) extraWidth = 0;
int extraHeight = (int)((MIN_HEIGHT - imp.getHeight()*mag)/2.0);
if (extraHeight<0) extraHeight = 0;
int extraWidth = 0, extraHeight = 0;
if (includeSmallImageMargins) {
extraWidth = (int)((MIN_WIDTH - imp.getWidth()*mag)/2.0);
if (extraWidth<0) extraWidth = 0;
extraHeight = (int)((MIN_HEIGHT - imp.getHeight()*mag)/2.0);
if (extraHeight<0) extraHeight = 0;
}
insets = new Insets(insets.top+textGap+extraHeight, insets.left+extraWidth, insets.bottom+extraHeight, insets.right+extraWidth);
return insets;
}
Expand Down
2 changes: 1 addition & 1 deletion ij/io/Opener.java
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ public static ImagePlus openUsingImageIO(String path) {
img = bi;
}
imp = new ImagePlus(f.getName(), img);
if (imp.getBitDepth()==16)
if (imp.getBitDepth()==16 && imp.getStackSize()>1)
imp = new CompositeImage(imp, IJ.COMPOSITE);
FileInfo fi = new FileInfo();
fi.fileFormat = fi.IMAGEIO;
Expand Down
5 changes: 4 additions & 1 deletion ij/plugin/ImageInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,10 @@ private double yy(double y, ImagePlus imp) {
}

private void showInfo(ImagePlus imp, String info, int width, int height) {
new TextWindow("Info for "+imp.getTitle(), info, width, height);
if (GraphicsEnvironment.isHeadless())
IJ.log(info);
else
new TextWindow("Info for "+imp.getTitle(), info, width, height);
//Editor ed = new Editor();
//ed.setSize(width, height);
//ed.create("Info for "+imp.getTitle(), info);
Expand Down
15 changes: 8 additions & 7 deletions ij/plugin/ScaleBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import ij.util.Tools;
import java.awt.*;
import java.awt.event.*;
import java.util.ArrayList;
import java.util.*;

/** This plugin implements the Analyze/Tools/Scale Bar command.
* Divakar Ramachandran added options to draw a background
Expand Down Expand Up @@ -728,12 +728,13 @@ public boolean dialogItemChanged(GenericDialog gd, AWTEvent e) {
config.barThicknessInPixels = (int)config.vBarHeight;
config.vBarHeight = 0.0;
}

String widthString = ((TextField) gd.getNumericFields().elementAt(0)).getText();
config.hDigits = Utils.getDigits(widthString);
String heightString = ((TextField) gd.getNumericFields().elementAt(1)).getText();
config.vDigits = Utils.getDigits(heightString);

Vector numericFields = gd.getNumericFields();
if (numericFields!=null) {
String widthString = ((TextField) numericFields.elementAt(0)).getText();
config.hDigits = Utils.getDigits(widthString);
String heightString = ((TextField) numericFields.elementAt(1)).getText();
config.vDigits = Utils.getDigits(heightString);
}
updateScalebar(true);
return true;
}
Expand Down
8 changes: 7 additions & 1 deletion release-notes.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,19 @@
</head>
<body>

<li> <u>1.54g4 10 July 2023</u>
<li> <u>1.54g8 30 July 2023</u>
<ul>
<li> Thanks to Robert Baer, the “Associate ’Show All’ ROIs with slices”
option in the ROI Manager’s More&gt;&gt;Options dialog is now always
enabled when ImageJ starts up.
<li> Thanks to 'Phiir42', fixed bug with closed tables reopening after
a macro finishes.
<li> Thanks to 'Ender', fixed headless mode "Scale Bar" and "Show Info" bugs.
<li> Thanks to Michael Schmid, fixed ImageCanvas.fitToWindow() bug with
very small images or user resized windows
(<a href="http://wsr.imagej.net/macros/js/FitToWindowBug.js">example</a>).
<li> Thanks to Guenter Pudmich, fixed a 1.54d regression that caused 16-bit
grayscale PNGs to be opened incorrectly.
</ul>

<li> <u>1.54f 29 June 2023</u>
Expand Down

0 comments on commit b40cfc7

Please sign in to comment.