MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / getImageSize

Method getImageSize

ij/src/main/java/ij/gui/ImageWindow.java:440–448  ·  view source on GitHub ↗
(ImagePlus imp)

Source from the content-addressed store, hash-verified

438 }
439
440 public static String getImageSize(ImagePlus imp) {
441 if (imp==null)
442 return null;
443 double size = imp.getSizeInBytes()/1024.0;
444 String s2=null, s3=null;
445 if (size<1024.0) {s2=IJ.d2s(size,0); s3="K";} else if (size<10000.0) {s2=IJ.d2s(size/1024.0,1); s3="MB";} else if (size<1048576.0) {s2=IJ.d2s(Math.round(size/1024.0),0); s3="MB";} else {s2=IJ.d2s(size/1048576.0,1); s3="GB";}
446 if (s2.endsWith(".0")) s2 = s2.substring(0, s2.length()-2);
447 return s2+s3;
448 }
449
450 private String d2s(double n) {
451 int digits = Tools.getDecimalPlaces(n);

Callers 4

addWindowMenuItemMethod · 0.95
updateWindowMenuItemMethod · 0.95
getInfoMethod · 0.95
createSubtitleMethod · 0.95

Calls 5

d2sMethod · 0.95
getSizeInBytesMethod · 0.80
substringMethod · 0.80
lengthMethod · 0.65
roundMethod · 0.45

Tested by

no test coverage detected