(String arg)
| 24 | public class BMP_Reader extends ImagePlus implements PlugIn { |
| 25 | |
| 26 | public void run(String arg) { |
| 27 | OpenDialog od = new OpenDialog("Open BMP...", arg); |
| 28 | String directory = od.getDirectory(); |
| 29 | String name = od.getFileName(); |
| 30 | if (name==null) |
| 31 | return; |
| 32 | String path = directory + name; |
| 33 | |
| 34 | //IJ.showStatus("Opening: " + path); |
| 35 | BMPDecoder bmp = new BMPDecoder(); |
| 36 | FileInputStream is = null; |
| 37 | try { |
| 38 | is = new FileInputStream(path); |
| 39 | bmp.read(is); |
| 40 | } catch (Exception e) { |
| 41 | String msg = e.getMessage(); |
| 42 | if (msg==null || msg.equals("")) |
| 43 | msg = ""+e; |
| 44 | if (msg.equals("Compression not supported")) { |
| 45 | ImagePlus imp = Opener.openUsingImageIO(path); |
| 46 | if (imp!=null) { |
| 47 | setProcessor(name, imp.getProcessor()); |
| 48 | if (arg.equals("")) |
| 49 | show(); |
| 50 | } |
| 51 | } else |
| 52 | IJ.error("BMP Reader", msg); |
| 53 | return; |
| 54 | } finally { |
| 55 | if (is!=null) { |
| 56 | try { |
| 57 | is.close(); |
| 58 | } catch (IOException e) {} |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | MemoryImageSource mis = bmp.makeImageSource(); |
| 63 | if (mis==null) IJ.log("BMP_Reader: mis=null"); |
| 64 | Image img = Toolkit.getDefaultToolkit().createImage(mis); |
| 65 | FileInfo fi = new FileInfo(); |
| 66 | fi.fileFormat = FileInfo.BMP; |
| 67 | fi.fileName = name; |
| 68 | fi.directory = directory; |
| 69 | setImage(img); |
| 70 | setTitle(name); |
| 71 | setFileInfo(fi); |
| 72 | if (bmp.topDown) |
| 73 | getProcessor().flipVertical(); |
| 74 | if (arg.equals("")) |
| 75 | show(); |
| 76 | } |
| 77 | |
| 78 | } |
| 79 |
nothing calls this directly
no test coverage detected