Esempio n. 1
0
 static void error(String msg, FileInfo fi, long offset, long length) {
   IJ.error(
       "FileOpener",
       "FileInfo parameter error. \n"
           + msg
           + "\n \n"
           + "  Width: "
           + fi.width
           + "\n"
           + "  Height: "
           + fi.height
           + "\n"
           + "  Offset: "
           + offset
           + "\n"
           + "  Bytes/pixel: "
           + fi.getBytesPerPixel()
           + "\n"
           + (length > 0 ? "  File length: " + length + "\n" : ""));
 }
Esempio n. 2
0
 static boolean validateFileInfo(File f, FileInfo fi) {
   long offset = fi.getOffset();
   long length = 0;
   if (fi.width <= 0 || fi.height < 0) {
     error("Width or height <= 0.", fi, offset, length);
     return false;
   }
   if (offset >= 0 && offset < 1000L) return true;
   if (offset < 0L) {
     error("Offset is negative.", fi, offset, length);
     return false;
   }
   if (fi.fileType == FileInfo.BITMAP || fi.compression != FileInfo.COMPRESSION_NONE) return true;
   length = f.length();
   long size = fi.width * fi.height * fi.getBytesPerPixel();
   size = fi.nImages > 1 ? size : size / 4;
   if (fi.height == 1) size = 0; // allows plugins to read info of unknown length at end of file
   if (offset + size > length) {
     error("Offset + image size > file length.", fi, offset, length);
     return false;
   }
   return true;
 }