com.hippo.image.Image Java Examples

The following examples show how to use com.hippo.image.Image. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ImageWrapperHelper.java    From Nimingban with Apache License 2.0 6 votes vote down vote up
@Nullable
@Override
public ImageWrapper decode(@NonNull InputStreamPipe isPipe) {
    try {
        isPipe.obtain();
        Image image = Image.decode(isPipe.open(), false);
        if (image != null) {
            return new ImageWrapper(image);
        } else {
            return null;
        }
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    } finally {
        isPipe.close();
        isPipe.release();
    }
}
 
Example #2
Source File: ImageTest.java    From Nimingban with Apache License 2.0 6 votes vote down vote up
public void testPngDecode() throws FileNotFoundException {
    int i = 1;
    while (i-- > 0) {

        if (i % 10 == 0) {
            Log.d("TAG", "" + (i / 10));
        }

        Image image = Image.decode(new FileInputStream("/sdcard/b.png"), false);
        if (image != null) {
            image.recycle();
        } else {
            Log.d("TAG", "image is null");
        }
    }
}
 
Example #3
Source File: SpiderQueen.java    From MHViewer with Apache License 2.0 5 votes vote down vote up
private void notifyGetImageSuccess(int index, Image image) {
    synchronized (mSpiderListeners) {
        for (OnSpiderListener listener : mSpiderListeners) {
            listener.onGetImageSuccess(index, image);
        }
    }
}
 
Example #4
Source File: ArchiveGalleryProvider.java    From MHViewer with Apache License 2.0 5 votes vote down vote up
@Override
public void run() {
  while (!Thread.currentThread().isInterrupted()) {
    int index;
    InputStream stream;
    synchronized (streams) {
      if (streams.isEmpty()) {
        try {
          streams.wait();
        } catch (InterruptedException e) {
          // Interrupted
          break;
        }
        continue;
      }

      Iterator<Map.Entry<Integer, InputStream>> iterator = streams.entrySet().iterator();
      Map.Entry<Integer, InputStream> entry = iterator.next();
      iterator.remove();
      index = entry.getKey();
      stream = entry.getValue();
      decodingIndex.lazySet(index);
    }

    try {
      Image image = Image.decode(stream, true);
      if (image != null) {
        notifyPageSucceed(index, image);
      } else {
        notifyPageFailed(index, GetText.getString(R.string.error_decoding_failed));
      }
    } finally {
      decodingIndex.lazySet(GalleryPageView.INVALID_INDEX);
    }
  }
}
 
Example #5
Source File: EhApplication.java    From MHViewer with Apache License 2.0 5 votes vote down vote up
private void debugPrint() {
    new Runnable() {
        @Override
        public void run() {
            if (DEBUG_PRINT_NATIVE_MEMORY) {
                Log.i(TAG, "Native memory: " + FileUtils.humanReadableByteCount(
                        Debug.getNativeHeapAllocatedSize(), false));
            }
            if (DEBUG_PRINT_IMAGE_COUNT) {
                Log.i(TAG, "Image count: " + Image.getImageCount());
            }
            SimpleHandler.getInstance().postDelayed(this, DEBUG_PRINT_INTERVAL);
        }
    }.run();
}
 
Example #6
Source File: SpiderQueen.java    From EhViewer with Apache License 2.0 5 votes vote down vote up
private void notifyGetImageSuccess(int index, Image image) {
    synchronized (mSpiderListeners) {
        for (OnSpiderListener listener : mSpiderListeners) {
            listener.onGetImageSuccess(index, image);
        }
    }
}
 
Example #7
Source File: ArchiveGalleryProvider.java    From EhViewer with Apache License 2.0 5 votes vote down vote up
@Override
public void run() {
  while (!Thread.currentThread().isInterrupted()) {
    int index;
    InputStream stream;
    synchronized (streams) {
      if (streams.isEmpty()) {
        try {
          streams.wait();
        } catch (InterruptedException e) {
          // Interrupted
          break;
        }
        continue;
      }

      Iterator<Map.Entry<Integer, InputStream>> iterator = streams.entrySet().iterator();
      Map.Entry<Integer, InputStream> entry = iterator.next();
      iterator.remove();
      index = entry.getKey();
      stream = entry.getValue();
      decodingIndex.lazySet(index);
    }

    try {
      Image image = Image.decode(stream, true);
      if (image != null) {
        notifyPageSucceed(index, image);
      } else {
        notifyPageFailed(index, GetText.getString(R.string.error_decoding_failed));
      }
    } finally {
      decodingIndex.lazySet(GalleryPageView.INVALID_INDEX);
    }
  }
}
 
Example #8
Source File: EhApplication.java    From EhViewer with Apache License 2.0 5 votes vote down vote up
private void debugPrint() {
    new Runnable() {
        @Override
        public void run() {
            if (DEBUG_PRINT_NATIVE_MEMORY) {
                Log.i(TAG, "Native memory: " + FileUtils.humanReadableByteCount(
                        Debug.getNativeHeapAllocatedSize(), false));
            }
            if (DEBUG_PRINT_IMAGE_COUNT) {
                Log.i(TAG, "Image count: " + Image.getImageCount());
            }
            SimpleHandler.getInstance().postDelayed(this, DEBUG_PRINT_INTERVAL);
        }
    }.run();
}
 
Example #9
Source File: EhGalleryProvider.java    From MHViewer with Apache License 2.0 4 votes vote down vote up
@Override
public void onGetImageSuccess(int index, Image image) {
    notifyPageSucceed(index, image);
}
 
Example #10
Source File: DownloadManager.java    From MHViewer with Apache License 2.0 4 votes vote down vote up
@Override
public void onGetImageSuccess(int index, Image image) {
    // Ignore
}
 
Example #11
Source File: ImageWrapper.java    From Nimingban with Apache License 2.0 4 votes vote down vote up
public ImageWrapper(@NonNull Image image) {
    mImage = image;
}
 
Example #12
Source File: EhGalleryProvider.java    From EhViewer with Apache License 2.0 4 votes vote down vote up
@Override
public void onGetImageSuccess(int index, Image image) {
    notifyPageSucceed(index, image);
}
 
Example #13
Source File: DownloadManager.java    From EhViewer with Apache License 2.0 4 votes vote down vote up
@Override
public void onGetImageSuccess(int index, Image image) {
    // Ignore
}
 
Example #14
Source File: SpiderQueen.java    From MHViewer with Apache License 2.0 votes vote down vote up
void onGetImageSuccess(int index, Image image); 
Example #15
Source File: SpiderQueen.java    From EhViewer with Apache License 2.0 votes vote down vote up
void onGetImageSuccess(int index, Image image);