We're Hiring!

Start up example loader

Historical discussions about the Bio-Formats library. Please look for and ask new questions at https://forum.image.sc/tags/bio-formats
Please note:
Historical discussions about the Bio-Formats library. Please look for and ask new questions at https://forum.image.sc/tags/bio-formats

If you are having trouble with image files, there is information about reporting bugs in the Bio-Formats documentation. Please send us the data and let us know what version of Bio-Formats you are using. For issues with your code, please provide a link to a public repository, ideally GitHub.

Start up example loader

Postby Marcel » Mon Jul 15, 2013 10:59 am

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;
   }
}
Marcel
 
Posts: 1
Joined: Mon Jul 15, 2013 9:34 am

Re: Start up example loader

Postby mlinkert » Mon Jul 15, 2013 2:39 pm

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().
User avatar
mlinkert
Team Member
 
Posts: 353
Joined: Fri May 29, 2009 2:12 pm
Location: Southwest Wisconsin


Return to User Discussion [Legacy]

Who is online

Users browsing this forum: No registered users and 1 guest