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


Java BitmapRegionDecoder.getHeight方法代碼示例

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


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

示例1: getHotseatPalette

import android.graphics.BitmapRegionDecoder; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.N)
private Palette getHotseatPalette() {
    WallpaperManager wallpaperManager = WallpaperManager.getInstance(this);
    if (AndroidVersion.isAtLeastNougat) {
        try (ParcelFileDescriptor fd = wallpaperManager
                .getWallpaperFile(WallpaperManager.FLAG_SYSTEM)) {
            BitmapRegionDecoder decoder = BitmapRegionDecoder
                    .newInstance(fd.getFileDescriptor(), false);
            int height = decoder.getHeight();
            Rect decodeRegion = new Rect(0, (int) (height * (1f - HOTSEAT_FRACTION)),
                    decoder.getWidth(), height);
            Bitmap bitmap = decoder.decodeRegion(decodeRegion, null);
            decoder.recycle();
            if (bitmap != null) {
                return Palette.from(bitmap).clearFilters().generate();
            }
        } catch (IOException | NullPointerException e) {
            e.printStackTrace();
        }
    }

    Bitmap wallpaper = ((BitmapDrawable) wallpaperManager.getDrawable()).getBitmap();
    return Palette.from(wallpaper)
            .setRegion(0, (int) (wallpaper.getHeight() * (1f - HOTSEAT_FRACTION)),
                    wallpaper.getWidth(), wallpaper.getHeight())
            .clearFilters()
            .generate();
}
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:29,代碼來源:ColorExtractionService.java

示例2: run

import android.graphics.BitmapRegionDecoder; //導入方法依賴的package包/類
@Override
public BitmapRegionDecoder run(JobContext jc) {
    if (!prepareInputFile(jc)) return null;
    BitmapRegionDecoder decoder = DecodeUtils.createBitmapRegionDecoder(
            jc, mFileDescriptor.getFileDescriptor(), false);
    mWidth = decoder.getWidth();
    mHeight = decoder.getHeight();
    return decoder;
}
 
開發者ID:asm-products,項目名稱:nexus-gallery,代碼行數:10,代碼來源:UriImage.java

示例3: onFutureDone

import android.graphics.BitmapRegionDecoder; //導入方法依賴的package包/類
@Override
public void onFutureDone(Future<BitmapRegionDecoder> future) {
    BitmapRegionDecoder decoder = future.get();
    if (decoder == null) return;
    int width = decoder.getWidth();
    int height = decoder.getHeight();
    BitmapFactory.Options options = new BitmapFactory.Options();
    options.inSampleSize = BitmapUtils.computeSampleSize(
            (float) SIZE_BACKUP / Math.max(width, height));
    Bitmap bitmap = decoder.decodeRegion(new Rect(0, 0, width, height), options);
    mHandler.sendMessage(mHandler.obtainMessage(
            MSG_UPDATE_IMAGE, new ImageBundle(decoder, bitmap)));
}
 
開發者ID:asm-products,項目名稱:nexus-gallery,代碼行數:14,代碼來源:SinglePhotoDataAdapter.java

示例4: buildTimeLine

import android.graphics.BitmapRegionDecoder; //導入方法依賴的package包/類
private void buildTimeLine() {
    Bitmap source = BitmapFactory.decodeResource(getActivity().getResources(), R.drawable.time_line_6_am);
    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    source.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream);
    try {
        BitmapRegionDecoder decoder = BitmapRegionDecoder.newInstance(new ByteArrayInputStream(byteArrayOutputStream.toByteArray()), true);
        imageLength = decoder.getHeight();
        int regionCount = 3;
        int height = decoder.getHeight() / regionCount;
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        for (int i = 0; i < 3; i++) {
            TimeLineLayout[i].removeAllViews();
        }
        for (int i = 0; i < regionCount; i++) {
            Bitmap bitmap;
            if (i == regionCount - 1) {
                bitmap = decoder.decodeRegion(new Rect(0, i * height, decoder.getWidth(), decoder.getHeight()), null);
            } else {
                bitmap = decoder.decodeRegion(new Rect(0, i * height, decoder.getWidth(), (i + 1) * height), null);
            }
            for (int j = 0; j < 3; j++) {
                ImageView imageView = new ImageView(getActivity());
                imageView.setImageBitmap(bitmap);
                imageView.setLayoutParams(params);
                TimeLineLayout[j].addView(imageView);
            }
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
開發者ID:UtopiaGroup,項目名稱:Utopia,代碼行數:32,代碼來源:ViewPagerFragment2.java

示例5: doInBackground

import android.graphics.BitmapRegionDecoder; //導入方法依賴的package包/類
@Override
protected Bitmap doInBackground (final Void... params) {
	LOG.i("Generating preview: s=%s q=%s.", this.dlg.getScale(), this.dlg.getQuality());
	try {
		final Bitmap scaled = this.srcMetadata.getBitmap(this.dlg.getScale().getPercentage());
		final ByteArrayOutputStream compOut = new ByteArrayOutputStream(512 * 1024);
		if (scaled.compress(Bitmap.CompressFormat.JPEG, this.dlg.getQuality().getPercentage(), compOut)) {
			this.summary
					.append(this.srcMetadata.getWidth()).append(" x ").append(this.srcMetadata.getHeight())
					.append(" (").append(IoHelper.readableFileSize(this.srcMetadata.getSize())).append(")")
					.append(" --> ").append(scaled.getWidth()).append(" x ").append(scaled.getHeight())
					.append(" (").append(IoHelper.readableFileSize(compOut.size())).append(")");
			final BitmapRegionDecoder dec = BitmapRegionDecoder.newInstance(compOut.toBufferedInputStream(), true);
			try {
				final int srcW = dec.getWidth();
				final int srcH = dec.getHeight();
				final int tgtW = this.dlg.getRootView().getWidth(); // FIXME Workaround for ImageView width issue.  Fix properly with something like FixedWidthImageView.
				final int tgtH = this.imgPreview.getHeight();
				final int left = srcW > tgtW ? (srcW - tgtW) / 2 : 0;
				final int top = srcH > tgtH ? (srcH - tgtH) / 2 : 0;
				final BitmapFactory.Options options = new BitmapFactory.Options();
				options.inPurgeable = true;
				options.inInputShareable = true;
				return dec.decodeRegion(new Rect(left, top, left + tgtW, top + tgtH), options);
			}
			finally {
				dec.recycle();
			}
		}
		this.summary.append("Failed to compress image."); //ES
		return null;
	}
	// XXX Many cases of OutOfMemoryError have been reported, particularly on low end hardware.
	// Try not to upset the user too much by not dying completely if possible.
	catch (final Throwable e) {
		LOG.e("Failed to generate preview image.", e);
		this.summary.append(e.toString());
		return null;
	}
}
 
開發者ID:haku,項目名稱:Onosendai,代碼行數:41,代碼來源:PictureResizeDialog.java

示例6: setRegionDecoder

import android.graphics.BitmapRegionDecoder; //導入方法依賴的package包/類
public synchronized void setRegionDecoder(BitmapRegionDecoder decoder) {
    mRegionDecoder = Utils.checkNotNull(decoder);
    mImageWidth = decoder.getWidth();
    mImageHeight = decoder.getHeight();
    mLevelCount = calculateLevelCount();
}
 
開發者ID:asm-products,項目名稱:nexus-gallery,代碼行數:7,代碼來源:TileImageViewAdapter.java


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