Esempio n. 1
0
  public static void debug(String message, java.util.List v) {
    String suffix = " [" + counter++ + "]";

    debug(message + " (" + v.size() + ")" + suffix);
    for (int i = 0; i < v.size(); i++) debug("\t" + v.get(i).toString() + suffix);
    debug();
  }
Esempio n. 2
0
 public static void debug(String message, ICC_Profile value) {
   debug("ICC_Profile " + message + ": " + ((value == null) ? "null" : value.toString()));
   if (value != null) {
     debug("\t getProfileClass: " + byteQuadToString(value.getProfileClass()));
     debug("\t getPCSType: " + byteQuadToString(value.getPCSType()));
     debug("\t getColorSpaceType() : " + byteQuadToString(value.getColorSpaceType()));
   }
 }
Esempio n. 3
0
  public static void debug(String message, Object value[]) {
    if (value == null) debug(message, "null");

    debug(message, value.length);
    final int max = 10;
    for (int i = 0; i < value.length && i < max; i++) debug("\t" + i, value[i]);
    if (value.length > max) debug("\t...");
    debug();
  }
Esempio n. 4
0
  public void testFullColorRoundtrip() throws IOException, ImageReadException, ImageWriteException {
    BufferedImage testImages[] = { //
      createFullColorImage(1, 1), // minimal
      createFullColorImage(2, 2), //
      createFullColorImage(10, 10), // larger than 8
      createFullColorImage(300, 300), // larger than 256
    };

    for (int j = 0; j < testImages.length; j++) {
      BufferedImage testImage = testImages[j];

      for (int i = 0; i < FORMAT_INFOS.length; i++) {
        FormatInfo formatInfo = FORMAT_INFOS[i];
        if ((!formatInfo.canRead) || (!formatInfo.canWrite)) continue;

        Debug.debug("fullColor test: " + formatInfo.format.name);

        boolean imageExact = true;
        if (formatInfo.colorSupport == COLOR_BITMAP) imageExact = false;
        if (formatInfo.colorSupport == COLOR_GRAYSCALE) imageExact = false;
        if (formatInfo.colorSupport == COLOR_LIMITED_INDEX) imageExact = false;

        roundtrip(formatInfo, testImage, "fullColor", imageExact);
      }
    }
  }
Esempio n. 5
0
  public void testBitmapRoundtrip() throws IOException, ImageReadException, ImageWriteException {
    BufferedImage testImages[] = { //
      createArgbBitmapImage(1, 1), // minimal
      createArgbBitmapImage(2, 2), //
      createArgbBitmapImage(10, 10), // larger than 8
      createArgbBitmapImage(300, 300), // larger than 256
      createBitmapBitmapImage(1, 1), // minimal
      createBitmapBitmapImage(2, 2), //
      createBitmapBitmapImage(10, 10), // larger than 8
      createBitmapBitmapImage(300, 300), // larger than 256
    };

    for (int j = 0; j < testImages.length; j++) {
      BufferedImage testImage = testImages[j];

      for (int i = 0; i < FORMAT_INFOS.length; i++) {
        FormatInfo formatInfo = FORMAT_INFOS[i];
        if ((!formatInfo.canRead) || (!formatInfo.canWrite)) continue;

        Debug.debug("bitmap test: " + formatInfo.format.name);

        roundtrip(formatInfo, testImage, "bitmap", true);
      }
    }
  }
Esempio n. 6
0
 public static final void purgeMemory() {
   try {
     //			Thread.sleep(50);
     System.runFinalization();
     Thread.sleep(50);
     System.gc();
     Thread.sleep(50);
   } catch (Throwable e) {
     Debug.debug(e);
   }
 }
Esempio n. 7
0
  private void compareFilesExact(File a, File b) throws IOException {
    assertTrue(a.exists() && a.isFile());
    assertTrue(b.exists() && b.isFile());
    assertEquals(a.length(), b.length());

    byte aData[] = IOUtils.getFileBytes(a);
    byte bData[] = IOUtils.getFileBytes(b);

    for (int i = 0; i < a.length(); i++) {
      int aByte = 0xff & aData[i];
      int bByte = 0xff & bData[i];

      if (aByte != bByte) {
        Debug.debug("a", a);
        Debug.debug("b", b);
        Debug.debug("i", i);
        Debug.debug("aByte", aByte + " (0x" + Integer.toHexString(aByte) + ")");
        Debug.debug("bByte", bByte + " (0x" + Integer.toHexString(bByte) + ")");
      }
      assertEquals(aByte, bByte);
    }
  }
Esempio n. 8
0
  public void test() throws Exception {

    List images = getImagesWithExifData(300);
    for (int i = 0; i < images.size(); i++) {
      if (i % 10 == 0) Debug.purgeMemory();

      File imageFile = (File) images.get(i);

      //			Debug.debug();
      //			Debug.debug("imageFile", imageFile);

      if (imageFile.getParentFile().getName().toLowerCase().equals("@broken")) continue;

      try {
        Map params = new HashMap();
        boolean ignoreImageData = isPhilHarveyTestImage(imageFile);
        params.put(PARAM_KEY_READ_THUMBNAILS, new Boolean(!ignoreImageData));

        JpegImageMetadata metadata = (JpegImageMetadata) Sanselan.getMetadata(imageFile, params);
        if (null == metadata) continue;

        TiffImageMetadata exifMetadata = metadata.getExif();
        if (null == exifMetadata) continue;

        TiffImageMetadata.GPSInfo gpsInfo = exifMetadata.getGPS();
        if (null == gpsInfo) continue;

        Debug.debug("imageFile", imageFile);
        Debug.debug("gpsInfo", gpsInfo);
        Debug.debug("gpsInfo longitude as degrees east", gpsInfo.getLongitudeAsDegreesEast());
        Debug.debug("gpsInfo latitude as degrees north", gpsInfo.getLatitudeAsDegreesNorth());

        Debug.debug();
      } catch (Exception e) {
        Debug.debug("imageFile", imageFile.getAbsoluteFile());
        Debug.debug("imageFile", imageFile.length());
        Debug.debug(e, 13);

        //				File brokenFolder = new File(imageFile.getParentFile(), "@Broken");
        //				if(!brokenFolder.exists())
        //					brokenFolder.mkdirs();
        //				File movedFile = new File(brokenFolder, imageFile.getName());
        //				imageFile.renameTo(movedFile);

        throw e;
      }
    }
  }
Esempio n. 9
0
  private void compareImages(BufferedImage a, BufferedImage b, int tolerance) {
    assertEquals(a.getWidth(), b.getWidth());
    assertEquals(a.getHeight(), b.getHeight());

    for (int x = 0; x < a.getWidth(); x++)
      for (int y = 0; y < a.getHeight(); y++) {
        int a_argb = a.getRGB(x, y);
        int b_argb = b.getRGB(x, y);
        if (a_argb != b_argb) {
          if (calculateARGBDistance(a_argb, b_argb) <= tolerance) continue; // ignore.
        }
        if (a_argb != b_argb) {
          Debug.debug("width", a.getWidth());
          Debug.debug("height", a.getHeight());
          Debug.debug("distance", calculateARGBDistance(a_argb, b_argb));
          Debug.debug("x", x);
          Debug.debug("y", y);
          Debug.debug("a_argb", a_argb + " (0x" + Integer.toHexString(a_argb) + ")");
          Debug.debug("b_argb", b_argb + " (0x" + Integer.toHexString(b_argb) + ")");
        }
        assertEquals(a_argb, b_argb);
      }
  }
Esempio n. 10
0
 public static void dumpStack() {
   debug(getStackTrace(new Exception("Stack trace"), -1, 1));
 }
Esempio n. 11
0
 public static void debug(Throwable e) {
   debug(getDebug(e));
 }
Esempio n. 12
0
 public static void debug(Throwable e, int value) {
   debug(getDebug(e, value));
 }
Esempio n. 13
0
 public static void debug(String message, String value) {
   debug(message + " " + value);
 }
Esempio n. 14
0
 public static void debug(String message, Throwable e) {
   debug(getDebug(message, e));
 }
Esempio n. 15
0
 public static void dump(String prefix, Object value) {
   if (value == null) debug(prefix, "null");
   else if (value instanceof Object[]) {
     Object[] array = (Object[]) value;
     debug(prefix, array);
     for (int i = 0; i < array.length; i++) dump(prefix + "\t" + i + ": ", array[i]);
   } else if (value instanceof int[]) {
     int[] array = (int[]) value;
     debug(prefix, array);
     for (int i = 0; i < array.length; i++) debug(prefix + "\t" + i + ": ", array[i]);
   } else if (value instanceof char[]) {
     char[] array = (char[]) value;
     debug(prefix, "[" + new String(array) + "]");
   } else if (value instanceof long[]) {
     long[] array = (long[]) value;
     debug(prefix, array);
     for (int i = 0; i < array.length; i++) debug(prefix + "\t" + i + ": ", array[i]);
   } else if (value instanceof boolean[]) {
     boolean[] array = (boolean[]) value;
     debug(prefix, array);
     for (int i = 0; i < array.length; i++) debug(prefix + "\t" + i + ": ", array[i]);
   } else if (value instanceof byte[]) {
     byte[] array = (byte[]) value;
     debug(prefix, array);
     for (int i = 0; i < array.length; i++) debug(prefix + "\t" + i + ": ", array[i]);
   } else if (value instanceof float[]) {
     float[] array = (float[]) value;
     debug(prefix, array);
     for (int i = 0; i < array.length; i++) debug(prefix + "\t" + i + ": ", array[i]);
   } else if (value instanceof byte[]) {
     double[] array = (double[]) value;
     debug(prefix, array);
     for (int i = 0; i < array.length; i++) debug(prefix + "\t" + i + ": ", array[i]);
   } else if (value instanceof java.util.List) {
     java.util.List list = (java.util.List) value;
     debug(prefix, "list");
     for (int i = 0; i < list.size(); i++) dump(prefix + "\t" + "list: " + i + ": ", list.get(i));
   } else if (value instanceof Map) {
     java.util.Map map = (java.util.Map) value;
     debug(prefix, "map");
     ArrayList keys = new ArrayList(map.keySet());
     Collections.sort(keys);
     for (int i = 0; i < keys.size(); i++) {
       Object key = keys.get(i);
       dump(prefix + "\t" + "map: " + key + " -> ", map.get(key));
     }
   }
   //		else if (value instanceof String)
   //			debug(prefix, value);
   else {
     debug(prefix, value.toString());
     debug(prefix + "\t", value.getClass().getName());
   }
 }
Esempio n. 16
0
 public static void debug(String message, boolean value) {
   debug(message + " " + ((value) ? ("true") : ("false")));
 }
Esempio n. 17
0
 public static void debug(String message, byte v[], int max) {
   debug(getDebug(message, v, max));
 }
Esempio n. 18
0
 public static void debug(String message, Map map) {
   debug(getDebug(message, map));
 }
Esempio n. 19
0
 private static void log(StringBuffer buffer, String s) {
   Debug.debug(s);
   if (buffer != null) buffer.append(s + newline);
 }
Esempio n. 20
0
 public static void debug(String message, int v[]) {
   debug(getDebug(message, v));
 }
Esempio n. 21
0
 public static void debug(String message, Object value) {
   if (value == null) debug(message, "null");
   else if (value instanceof char[]) debug(message, (char[]) value);
   else if (value instanceof byte[]) debug(message, (byte[]) value);
   else if (value instanceof int[]) debug(message, (int[]) value);
   else if (value instanceof String) debug(message, (String) value);
   else if (value instanceof java.util.List) debug(message, (java.util.List) value);
   else if (value instanceof Map) debug(message, (Map) value);
   //		else if (value instanceof Object)
   //			debug(message, (Object) value);
   else if (value instanceof ICC_Profile) debug(message, (ICC_Profile) value);
   else if (value instanceof File) debug(message, (File) value);
   else if (value instanceof Date) debug(message, (Date) value);
   else if (value instanceof Calendar) debug(message, (Calendar) value);
   else debug(message, value.toString());
 }
Esempio n. 22
0
 public static void debug(String message, File file) {
   debug(message + ": " + ((file == null) ? "null" : file.getPath()));
 }
Esempio n. 23
0
 public static void debug(String message, Date value) {
   DateFormat df = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
   debug(message, (value == null) ? "null" : df.format(value));
 }
Esempio n. 24
0
 public static void dumpStack(int limit) {
   debug(getStackTrace(new Exception("Stack trace"), limit, 1));
 }
Esempio n. 25
0
 public static void debug(String message, long value) {
   debug(message + " " + Long.toString(value));
 }
Esempio n. 26
0
 public static void debug(String prefix, Dimension r) {
   debug(getDebug(prefix, r));
 }
Esempio n. 27
0
 public static void debug(String prefix, Rectangle r) {
   debug(getDebug(prefix, r));
 }
Esempio n. 28
0
 public static void debug(String message, int value) {
   debug(message + ": " + (value));
 }
Esempio n. 29
0
 public static void debug(Class fClass, Throwable e) {
   debug(fClass.getName(), e);
 }