Page 1 of 1

Start up example loader

PostPosted: Mon Jul 15, 2013 10:59 am
by Marcel
I'm trying to program a new FormatReader and am following the guide on http://www.openmicroscopy.org/site/supp ... guide.html.
I'm programming in Eclipse and got things started up. But what would be the best way to test the code? How to load the image, such the openBytes() method is called?
For example, how to implement the run method to call the dialog for selecting the image and thus load the file?

Code: Select all
import java.io.IOException;
import loci.formats.FormatException;
import loci.formats.FormatReader;

public class Test extends FormatReader {
   public Test(String format, String suffix) {
      super(format, suffix);
   }
      
   public static void main(String[] args) throws FormatException, IOException {   
      Test test = new Test(null, null);
      test.run(args);
      test.close();
   }
   
   private void run(String[] args) throws FormatException, IOException {
      // TODO load an image
   }

   @Override
   public byte[] openBytes(int no, byte[] buf, int x, int y, int w, int h) throws FormatException, IOException {
      for(int i=0; i<buf.length; i++) {
         buf[i] = (byte)(Math.random()*255);
      }
      return buf;
   }
}

Re: Start up example loader

PostPosted: Mon Jul 15, 2013 2:39 pm
by mlinkert
One of the easiest ways to test your reader would be to use the command line tool 'showinf':

http://www.openmicroscopy.org/site/supp ... rom-source

If everything is working correctly, you should see the image dimensions and various other metadata output to the console, in addition to a window that displays all of the images read from the file using openBytes().