當前位置: 首頁>>代碼示例>>Java>>正文


Java BitmapRegionDecoder類代碼示例

本文整理匯總了Java中android.graphics.BitmapRegionDecoder的典型用法代碼示例。如果您正苦於以下問題:Java BitmapRegionDecoder類的具體用法?Java BitmapRegionDecoder怎麽用?Java BitmapRegionDecoder使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


BitmapRegionDecoder類屬於android.graphics包,在下文中一共展示了BitmapRegionDecoder類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: init

import android.graphics.BitmapRegionDecoder; //導入依賴的package包/類
@RequiresApi(api = Build.VERSION_CODES.GINGERBREAD_MR1)
@Override
public Point init(Context context, Uri uri) throws Exception {
  Log.w(TAG, "Init!");
  if (!PartAuthority.isLocalUri(uri)) {
    passthrough = new SkiaImageRegionDecoder();
    return passthrough.init(context, uri);
  }

  MasterSecret masterSecret = KeyCachingService.getMasterSecret(context);

  if (masterSecret == null) {
    throw new IllegalStateException("No master secret available...");
  }

  InputStream inputStream = PartAuthority.getAttachmentStream(context, masterSecret, uri);

  this.bitmapRegionDecoder = BitmapRegionDecoder.newInstance(inputStream, false);
  inputStream.close();

  return new Point(bitmapRegionDecoder.getWidth(), bitmapRegionDecoder.getHeight());
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:23,代碼來源:AttachmentRegionDecoder.java

示例2: intercept

import android.graphics.BitmapRegionDecoder; //導入依賴的package包/類
@Override
public BitmapRegionDecoder intercept(Chain chain) throws IOException {
    final Uri uri = chain.uri();
    BitmapRegionDecoder decoder = chain.chain(uri);
    if (decoder != null){
        return decoder;
    }

    if (UriUtil.isNetworkUri(uri)){
        if (BuildConfig.DEBUG) {
            Log.d("NetworkInterceptor", "從我這加載");
        }
        File file = processFile(uri.toString());
        try {
            //InputStream inputStream = processBitmap(uri.toString());
            return BitmapRegionDecoder.newInstance(new FileInputStream(file),false);
        } catch (IOException e) {
            //e.printStackTrace();
            return Interceptors.fixJPEGDecoder(file,e);
        }
    }
    return null;
}
 
開發者ID:EvilBT,項目名稱:HDImageView,代碼行數:24,代碼來源:NetworkInterceptor.java

示例3: fixJPEGDecoder

import android.graphics.BitmapRegionDecoder; //導入依賴的package包/類
public static BitmapRegionDecoder fixJPEGDecoder(File file, IOException e) throws IOException {

        if (file == null || !file.exists()){
            throw e;
        }

        Bitmap bitmap = BitmapFactory.decodeFile(file.getAbsolutePath(),new BitmapFactory.Options());
        if (bitmap == null) {
            if (BuildConfig.DEBUG) {
                Log.d(TAG, "加載緩存失敗:" + file.getAbsolutePath());
            }
            throw e;
        }
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        bitmap.compress(Bitmap.CompressFormat.PNG, 85, baos);
        BitmapRegionDecoder decoder = BitmapRegionDecoder.newInstance(baos.toByteArray(),0,baos.size(),false);
        bitmap.recycle();
        if (BuildConfig.DEBUG) {
            Log.d(TAG, "fixJPEGDecoder: 從此處修複Bitmap");
        }
        return decoder;
    }
 
開發者ID:EvilBT,項目名稱:HDImageView,代碼行數:23,代碼來源:Interceptors.java

示例4: intercept

import android.graphics.BitmapRegionDecoder; //導入依賴的package包/類
@Override
public BitmapRegionDecoder intercept(Chain chain) throws IOException {
    final Uri uri = chain.uri();
    BitmapRegionDecoder decoder = chain.chain(uri);
    if (decoder != null){
        return decoder;
    }


    if (UriUtil.isLocalFileUri(uri)){
        File file = new File(uri.getPath());
        if (BuildConfig.DEBUG) {
            Log.d("FileInterceptor", "從我這加載");
        }
        try {
            return BitmapRegionDecoder.newInstance(new FileInputStream(file.toString()),false);
        } catch (IOException e) {
            return Interceptors.fixJPEGDecoder(file,e);
        }
    }
    return null;
}
 
開發者ID:EvilBT,項目名稱:HDImageView,代碼行數:23,代碼來源:FileInterceptor.java

示例5: createBitmapRegionDecoder

import android.graphics.BitmapRegionDecoder; //導入依賴的package包/類
public static BitmapRegionDecoder createBitmapRegionDecoder(
        ThreadPool.JobContext jc, byte[] bytes, int offset, int length,
        boolean shareable) {
    if (offset < 0 || length <= 0 || offset + length > bytes.length) {
        throw new IllegalArgumentException(String.format(
                "offset = %s, length = %s, bytes = %s",
                offset, length, bytes.length));
    }

    try {
        return BitmapRegionDecoder.newInstance(
                bytes, offset, length, shareable);
    } catch (Throwable t)  {
        Log.w(TAG, t);
        return null;
    }
}
 
開發者ID:mayurkaul,項目名稱:medialibrary,代碼行數:18,代碼來源:DecodeUtils.java

示例6: decodeRegion

import android.graphics.BitmapRegionDecoder; //導入依賴的package包/類
private static Bitmap decodeRegion(BitmapRegionDecoder decoder, Rect rect, BitmapFactory.Options options) {
    Bitmap bitmap = null;
    options.inPreferredConfig = Constants.PREFERRED_CONFIG;
    if (options.inPreferredConfig == Bitmap.Config.RGB_565) {
        options.inDither = true;
    }
    synchronized (sDecodeLock) {
        bitmap = decoder.decodeRegion(rect, options);
    }
    if (options.inBitmap != null) {
        if (bitmap != options.inBitmap) {
            Log.d("LocalRunnable", "decodeRegion inBitmap failed");
            options.inBitmap.recycle();
        } else {
            Log.d("LocalRunnable", "decodeRegion inBitmap success");
        }
    }
    return bitmap;
}
 
開發者ID:qii,項目名稱:BitmapView,代碼行數:20,代碼來源:LocalRunnable.java

示例7: getTileImage

import android.graphics.BitmapRegionDecoder; //導入依賴的package包/類
public TileImage getTileImage() {
    if (mIsGif) {
        return null;
    }

    BitmapFactory.Options options = new BitmapFactory.Options();
    options.inJustDecodeBounds = true;
    BitmapFactory.decodeFile(this.mFilePath, options);
    int width = options.outWidth;
    int height = options.outHeight;

    if (width <= 0 || height <= 0) {
        return null;
    }

    try {
        BitmapRegionDecoder bitmapRegionDecoder = BitmapRegionDecoder.newInstance(this.mFilePath, false);
        return TileImage.newInstance(width, height, OrientationInfoUtility.getOrientation(this.mFilePath), bitmapRegionDecoder);
    } catch (IOException e) {
        e.printStackTrace();
    }
    return null;
}
 
開發者ID:qii,項目名稱:BitmapView,代碼行數:24,代碼來源:BitmapSource.java

示例8: createBitmapRegionDecoder

import android.graphics.BitmapRegionDecoder; //導入依賴的package包/類
public static BitmapRegionDecoder createBitmapRegionDecoder(
        JobContext jc, byte[] bytes, int offset, int length,
        boolean shareable) {
    if (offset < 0 || length <= 0 || offset + length > bytes.length) {
        throw new IllegalArgumentException(String.format(
                "offset = %s, length = %s, bytes = %s",
                offset, length, bytes.length));
    }

    try {
        return BitmapRegionDecoder.newInstance(
                bytes, offset, length, shareable);
    } catch (Throwable t)  {
        Log.w(TAG, t);
        return null;
    }
}
 
開發者ID:asm-products,項目名稱:nexus-gallery,代碼行數:18,代碼來源:DecodeUtils.java

示例9: updateFullImage

import android.graphics.BitmapRegionDecoder; //導入依賴的package包/類
private void updateFullImage(Path path, Future<BitmapRegionDecoder> future) {
    ImageEntry entry = mImageCache.get(path);
    if (entry == null || entry.fullImageTask != future) {
        BitmapRegionDecoder fullImage = future.get();
        if (fullImage != null) fullImage.recycle();
        return;
    }

    entry.fullImageTask = null;
    entry.fullImage = future.get();
    if (entry.fullImage != null) {
        if (path == getPath(mCurrentIndex)) {
            updateTileProvider(entry);
            mPhotoView.notifyImageChange(0);
        }
    }
    updateImageRequests();
}
 
開發者ID:asm-products,項目名稱:nexus-gallery,代碼行數:19,代碼來源:PhotoDataAdapter.java

示例10: updateTileProvider

import android.graphics.BitmapRegionDecoder; //導入依賴的package包/類
private void updateTileProvider(ImageEntry entry) {
    ScreenNail screenNail = entry.screenNail;
    BitmapRegionDecoder fullImage = entry.fullImage;
    if (screenNail != null) {
        if (fullImage != null) {
            mTileProvider.setScreenNail(screenNail,
                    fullImage.getWidth(), fullImage.getHeight());
            mTileProvider.setRegionDecoder(fullImage);
        } else {
            int width = screenNail.getWidth();
            int height = screenNail.getHeight();
            mTileProvider.setScreenNail(screenNail, width, height);
        }
    } else {
        mTileProvider.clear();
    }
}
 
開發者ID:asm-products,項目名稱:nexus-gallery,代碼行數:18,代碼來源:PhotoDataAdapter.java

示例11: CachedImage

import android.graphics.BitmapRegionDecoder; //導入依賴的package包/類
/**
 * Initialisiert und erzeugt einen Tile-Cache als LRU-Cache.
 * 
 * @param inputStream Stream zur Bilddatei (nur JPEG und PNG)
 * @param cacheCallback Callback, wenn ein Tile nach einem Cache-Miss generiert und im Cache gespeichert wurde.
 * @throws IOException Wird geworfen, wenn BitmapRegionDecoder nicht instanziiert werden kann (falls das Bild
 *             weder JPEG noch PNG ist, oder bei einem anderen IO-Fehler)
 */
public CachedImage(InputStream inputStream, CachedImage.CacheMissResolvedCallback cacheCallback) throws IOException {
	// Tilecache erzeugen durch Aufruf des LruCache<String, Bitmap>-Konstruktors
	super(calculateCacheSize());
	
	// Callback setzen
	cacheMissResolvedCallback = cacheCallback;
	
	// BitmapRegionDecoder instanziieren. Wirft bei nicht unterstütztem Format (andere als JPEG und PNG)
	// eine IOException.
	regionDecoder = BitmapRegionDecoder.newInstance(inputStream, true);
	
	if (regionDecoder == null) {
		throw new IOException("BitmapRegionDecoder could not create instance for unknown reasons");
	}
}
 
開發者ID:diedricm,項目名稱:MapEver,代碼行數:24,代碼來源:CachedImage.java

示例12: ViewportWithCache

import android.graphics.BitmapRegionDecoder; //導入依賴的package包/類
ViewportWithCache(Point sceneSize, String filepath) throws IOException {
    mSceneSize = sceneSize;

    mVisibleViewport = new Viewport();
    mVisibleViewport.CONFIG = DEFAULT_CONFIG;

    mCachedBitmap = null;
    mCachedWindow = null;

    mDecoder = BitmapRegionDecoder.newInstance(filepath, false);

    // TODO Create the sample image, should calculate DOWN_SAMPLE_SHIFT here
    Options opts = new Options();
    opts.inPreferredConfig = DEFAULT_CONFIG;
    opts.inSampleSize = (1 << DOWN_SAMPLE_SHIFT);
    mSampledBitmap = BitmapFactory.decodeFile(filepath, opts);
}
 
開發者ID:LouisPeng,項目名稱:HugePhotoView,代碼行數:18,代碼來源:ViewportWithCache.java

示例13: createBitmapRegionDecoder

import android.graphics.BitmapRegionDecoder; //導入依賴的package包/類
public static BitmapRegionDecoder createBitmapRegionDecoder(
        JobContext jc, byte[] bytes, int offset, int length,
        boolean shareable) {
    if (offset < 0 || length <= 0 || offset + length > bytes.length) {
        throw new IllegalArgumentException(String.format(
                "offset = %s, length = %s, bytes = %s",
                offset, length, bytes.length));
    }

    try {
        return BitmapRegionDecoder.newInstance(
                bytes, offset, length, shareable);
    } catch (Throwable t)  {
        WLog.w(TAG, t);
        return null;
    }
}
 
開發者ID:jituo666,項目名稱:WoTu,代碼行數:18,代碼來源:BitmapDecoder.java

示例14: loadCroppedBitmap

import android.graphics.BitmapRegionDecoder; //導入依賴的package包/類
/**
 * Loads cropped bitmap from the disk.
 * @param region Region to be cropped
 * @param imageWidth Width of original image
 * @param imageHeight Height of original image
 * @param rotation rotation applied to width and height
 * @param imagePath Path to the image on disk.
 * @param opts Options for loading the image
 * @return
 */
public static Bitmap loadCroppedBitmap(
		Rect region, 
		int imageWidth, 
		int imageHeight,
		int rotation,
		String imagePath, 
		BitmapFactory.Options opts){
	
	Bitmap bmap = null;
	try {
		
		BitmapRegionDecoder decoder = BitmapRegionDecoder.newInstance(imagePath, false);
		
		// inversely rotate the crop region to undo the rotation applied to image width and height
		int invRotation = (-rotation + 360) %360;
		Rect rect = applyRotation(invRotation, imageWidth, imageHeight, region);
		
		// Load the cropped bitmap
		bmap = decoder.decodeRegion(rect, opts);
	} catch (IOException e) {
		e.printStackTrace();
	}
	return bmap;
}
 
開發者ID:fouady,項目名稱:DocuTranslator,代碼行數:35,代碼來源:BitmapUtils.java

示例15: buildBlocksFromImage

import android.graphics.BitmapRegionDecoder; //導入依賴的package包/類
public void buildBlocksFromImage(InputStream imageStream) {

        this.originalImageInputStream = imageStream;

        BitmapRegionDecoder brp = null;

        try {
            brp = BitmapRegionDecoder.newInstance(imageStream, false);
        } catch (IOException e) {
            e.printStackTrace();
        }

        for (int row = 0; row < this.rowCount; row++) {
            for (int col = 0; col < this.columnCount; col++) {
                int left = col * subdivisionWidth, top = row * subdivisionWidth;
                int right = left + subdivisionWidth, bottom = top + subdivisionWidth;
                Bitmap region = brp.decodeRegion(new Rect(left, top, right, bottom), null);
                RgbColor averageColor = calculateAverageColor(region);
                Block bestBlock = Block.bestMatchedBlock(averageColor);
                this.setBlockAtIndices(row, col, bestBlock);
            }
        }

        return;
    }
 
開發者ID:bcaudell95,項目名稱:HackISU3,代碼行數:26,代碼來源:BlockBitmap.java


注:本文中的android.graphics.BitmapRegionDecoder類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。