diff -r 1f0034e370aa -r 71ad690e91f5 javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/org/eclipse/swt/internal/qt/graphics/ImageLoader.java --- a/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/org/eclipse/swt/internal/qt/graphics/ImageLoader.java Fri Sep 17 16:44:34 2010 +0300 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/org/eclipse/swt/internal/qt/graphics/ImageLoader.java Mon Oct 04 11:29:25 2010 +0300 @@ -13,6 +13,7 @@ import java.io.*; import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.Device; /** * ImageLoader is class for image loading from various data formats. @@ -230,6 +231,33 @@ } /** + * Returns the bounds of an Image without creating an actual Image instance. + * + * @param is The InputStream from where to read the image data from + * @return Bounds of the image + */ + public static Point getImageSize(InputStream is) throws IOException { + + if (is == null) { + throw new NullPointerException("InputStream is null"); + } + + int bytesAvailable = is.available(); // may throw IOException + + if (bytesAvailable == 0) { + throw new IllegalArgumentException("Empty file"); + } + + byte [] data = new byte[bytesAvailable]; + + if (is.read(data, 0, data.length) != bytesAvailable) { + throw new IOException("Could not load data from InputStream"); + } + + return OS.imageLoader_getImageSize(data); + } + + /** * Private helper to check the state of the current instance. */ private void checkState() {