当前位置: 首页>>代码示例>>Java>>正文


Java BitmapRegionDecoder.getWidth方法代码示例

本文整理汇总了Java中android.graphics.BitmapRegionDecoder.getWidth方法的典型用法代码示例。如果您正苦于以下问题:Java BitmapRegionDecoder.getWidth方法的具体用法?Java BitmapRegionDecoder.getWidth怎么用?Java BitmapRegionDecoder.getWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.graphics.BitmapRegionDecoder的用法示例。


在下文中一共展示了BitmapRegionDecoder.getWidth方法的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: getStatusBarPalette

import android.graphics.BitmapRegionDecoder; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.N)
private Palette getStatusBarPalette() {
    WallpaperManager wallpaperManager = WallpaperManager.getInstance(this);
    int statusBarHeight = getResources()
            .getDimensionPixelSize(R.dimen.status_bar_height);

    if (AndroidVersion.isAtLeastNougat) {
        try (ParcelFileDescriptor fd = wallpaperManager
                .getWallpaperFile(WallpaperManager.FLAG_SYSTEM)) {
            BitmapRegionDecoder decoder = BitmapRegionDecoder
                    .newInstance(fd.getFileDescriptor(), false);
            Rect decodeRegion = new Rect(0, 0,
                    decoder.getWidth(), statusBarHeight);
            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, 0, wallpaper.getWidth(), statusBarHeight)
            .clearFilters()
            .generate();
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:30,代码来源:ColorExtractionService.java

示例3: 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

示例4: 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

示例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.getWidth方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。