本文整理汇总了Java中com.android.gallery3d.common.BitmapUtils类的典型用法代码示例。如果您正苦于以下问题:Java BitmapUtils类的具体用法?Java BitmapUtils怎么用?Java BitmapUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BitmapUtils类属于com.android.gallery3d.common包,在下文中一共展示了BitmapUtils类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getPreKKDefaultWallpaperInfo
import com.android.gallery3d.common.BitmapUtils; //导入依赖的package包/类
private ResourceWallpaperInfo getPreKKDefaultWallpaperInfo() {
Resources sysRes = Resources.getSystem();
int resId = sysRes.getIdentifier("default_wallpaper", "drawable", "android");
File defaultThumbFile = getDefaultThumbFile();
Bitmap thumb = null;
boolean defaultWallpaperExists = false;
if (defaultThumbFile.exists()) {
thumb = BitmapFactory.decodeFile(defaultThumbFile.getAbsolutePath());
defaultWallpaperExists = true;
} else {
Resources res = getResources();
Point defaultThumbSize = getDefaultThumbnailSize(res);
int rotation = BitmapUtils.getRotationFromExif(res, resId);
thumb = createThumbnail(
defaultThumbSize, getContext(), null, null, sysRes, resId, rotation, false);
if (thumb != null) {
defaultWallpaperExists = saveDefaultWallpaperThumb(thumb);
}
}
if (defaultWallpaperExists) {
return new ResourceWallpaperInfo(sysRes, resId, new BitmapDrawable(thumb));
}
return null;
}
开发者ID:TeamBrainStorm,项目名称:SimpleUILauncher,代码行数:26,代码来源:WallpaperPickerActivity.java
示例2: setWallpaper
import com.android.gallery3d.common.BitmapUtils; //导入依赖的package包/类
protected void setWallpaper(Uri uri, final boolean finishActivityWhenDone) {
int rotation = BitmapUtils.getRotationFromExif(getContext(), uri);
BitmapCropTask cropTask = new BitmapCropTask(
getContext(), uri, null, rotation, 0, 0, true, false, null);
final Point bounds = cropTask.getImageBounds();
Runnable onEndCrop = new Runnable() {
public void run() {
updateWallpaperDimensions(bounds.x, bounds.y);
if (finishActivityWhenDone) {
setResult(Activity.RESULT_OK);
finish();
}
}
};
cropTask.setOnEndRunnable(onEndCrop);
cropTask.setNoCrop(true);
cropTask.execute();
}
开发者ID:Mr-lin930819,项目名称:SimplOS,代码行数:19,代码来源:WallpaperCropActivity.java
示例3: cropImageAndSetWallpaper
import com.android.gallery3d.common.BitmapUtils; //导入依赖的package包/类
protected void cropImageAndSetWallpaper(
Resources res, int resId, final boolean finishActivityWhenDone) {
// crop this image and scale it down to the default wallpaper size for
// this device
int rotation = BitmapUtils.getRotationFromExif(res, resId);
Point inSize = mCropView.getSourceDimensions();
Point outSize = WallpaperUtils.getDefaultWallpaperSize(getResources(),
getWindowManager());
RectF crop = Utils.getMaxCropRect(
inSize.x, inSize.y, outSize.x, outSize.y, false);
Runnable onEndCrop = new Runnable() {
public void run() {
// Passing 0, 0 will cause launcher to revert to using the
// default wallpaper size
updateWallpaperDimensions(0, 0);
if (finishActivityWhenDone) {
setResult(Activity.RESULT_OK);
finish();
}
}
};
BitmapCropTask cropTask = new BitmapCropTask(getContext(), res, resId,
crop, rotation, outSize.x, outSize.y, true, false, onEndCrop);
cropTask.execute();
}
开发者ID:Mr-lin930819,项目名称:SimplOS,代码行数:26,代码来源:WallpaperCropActivity.java
示例4: decodePreview
import com.android.gallery3d.common.BitmapUtils; //导入依赖的package包/类
/**
* Note that the returned bitmap may have a long edge that's longer
* than the targetSize, but it will always be less than 2x the targetSize
*/
private Bitmap decodePreview(BitmapSource source, int targetSize) {
Bitmap result = source.getPreviewBitmap();
if (result == null) {
return null;
}
// We need to resize down if the decoder does not support inSampleSize
// or didn't support the specified inSampleSize (some decoders only do powers of 2)
float scale = (float) targetSize / (float) (Math.max(result.getWidth(), result.getHeight()));
if (scale <= 0.5) {
result = BitmapUtils.resizeBitmapByScale(result, scale, true);
}
return ensureGLCompatibleBitmap(result);
}
开发者ID:Phonemetra,项目名称:TurboLauncher,代码行数:20,代码来源:BitmapRegionTileSource.java
示例5: setWallpaper
import com.android.gallery3d.common.BitmapUtils; //导入依赖的package包/类
protected void setWallpaper(Uri uri, final boolean finishActivityWhenDone,
final boolean shouldFadeOutOnFinish) {
int rotation = BitmapUtils.getRotationFromExif(getContext(), uri);
BitmapCropTask cropTask = new BitmapCropTask(
getContext(), uri, null, rotation, 0, 0, true, false, null);
final Point bounds = cropTask.getImageBounds();
BitmapCropTask.OnEndCropHandler onEndCrop = new BitmapCropTask.OnEndCropHandler() {
public void run(boolean cropSucceeded) {
updateWallpaperDimensions(bounds.x, bounds.y);
if (finishActivityWhenDone) {
setResult(Activity.RESULT_OK);
finish();
if (cropSucceeded && shouldFadeOutOnFinish) {
overridePendingTransition(0, R.anim.fade_out);
}
}
}
};
cropTask.setOnEndRunnable(onEndCrop);
cropTask.setNoCrop(true);
NycWallpaperUtils.executeCropTaskAfterPrompt(this, cropTask, getOnDialogCancelListener());
}
开发者ID:RunasSudo,项目名称:FLauncher,代码行数:23,代码来源:WallpaperCropActivity.java
示例6: decodePreview
import com.android.gallery3d.common.BitmapUtils; //导入依赖的package包/类
/**
* Note that the returned bitmap may have a long edge that's longer
* than the targetSize, but it will always be less than 2x the targetSize
*/
private Bitmap decodePreview(String file, int targetSize) {
float scale = (float) targetSize / Math.max(mWidth, mHeight);
mOptions.inSampleSize = BitmapUtils.computeSampleSizeLarger(scale);
mOptions.inJustDecodeBounds = false;
Bitmap result = BitmapFactory.decodeFile(file, mOptions);
if (result == null) {
return null;
}
// We need to resize down if the decoder does not support inSampleSize
// or didn't support the specified inSampleSize (some decoders only do powers of 2)
scale = (float) targetSize / (float) (Math.max(result.getWidth(), result.getHeight()));
if (scale <= 0.5) {
result = BitmapUtils.resizeBitmapByScale(result, scale, true);
}
return ensureGLCompatibleBitmap(result);
}
开发者ID:asm-products,项目名称:nexus-gallery,代码行数:24,代码来源:BitmapRegionTileSource.java
示例7: run
import com.android.gallery3d.common.BitmapUtils; //导入依赖的package包/类
@Override
public Bitmap run(JobContext jc) {
if (!prepareInputFile(jc)) return null;
int targetSize = MediaItem.getTargetSize(mType);
Options options = new Options();
options.inPreferredConfig = Config.ARGB_8888;
Bitmap bitmap = DecodeUtils.decodeThumbnail(jc,
mFileDescriptor.getFileDescriptor(), options, targetSize, mType);
if (jc.isCancelled() || bitmap == null) {
return null;
}
if (mType == MediaItem.TYPE_MICROTHUMBNAIL) {
bitmap = BitmapUtils.resizeAndCropCenter(bitmap, targetSize, true);
} else {
bitmap = BitmapUtils.resizeDownBySideLength(bitmap, targetSize, true);
}
return bitmap;
}
开发者ID:asm-products,项目名称:nexus-gallery,代码行数:21,代码来源:UriImage.java
示例8: getSupportedOperations
import com.android.gallery3d.common.BitmapUtils; //导入依赖的package包/类
@Override
public int getSupportedOperations() {
int operation = SUPPORT_DELETE | SUPPORT_SHARE | SUPPORT_CROP
| SUPPORT_SETAS | SUPPORT_PRINT | SUPPORT_INFO;
if (BitmapUtils.isSupportedByRegionDecoder(mimeType)) {
operation |= SUPPORT_FULL_IMAGE | SUPPORT_EDIT;
}
if (BitmapUtils.isRotationSupported(mimeType)) {
operation |= SUPPORT_ROTATE;
}
if (GalleryUtils.isValidLocation(latitude, longitude)) {
operation |= SUPPORT_SHOW_ON_MAP;
}
return operation;
}
开发者ID:asm-products,项目名称:nexus-gallery,代码行数:18,代码来源:LocalImage.java
示例9: decodeIfBigEnough
import com.android.gallery3d.common.BitmapUtils; //导入依赖的package包/类
/**
* Decodes the bitmap from the given byte array if the image size is larger than the given
* requirement.
*
* Note: The returned image may be resized down. However, both width and height must be
* larger than the <code>targetSize</code>.
*/
public static Bitmap decodeIfBigEnough(JobContext jc, byte[] data,
Options options, int targetSize) {
if (options == null) options = new Options();
jc.setCancelListener(new DecodeCanceller(options));
options.inJustDecodeBounds = true;
BitmapFactory.decodeByteArray(data, 0, data.length, options);
if (jc.isCancelled()) return null;
if (options.outWidth < targetSize || options.outHeight < targetSize) {
return null;
}
options.inSampleSize = BitmapUtils.computeSampleSizeLarger(
options.outWidth, options.outHeight, targetSize);
options.inJustDecodeBounds = false;
setOptionsMutable(options);
return ensureGLCompatibleBitmap(
BitmapFactory.decodeByteArray(data, 0, data.length, options));
}
开发者ID:asm-products,项目名称:nexus-gallery,代码行数:27,代码来源:DecodeUtils.java
示例10: run
import com.android.gallery3d.common.BitmapUtils; //导入依赖的package包/类
@Override
public ScreenNail run(JobContext jc) {
// We try to get a ScreenNail first, if it fails, we fallback to get
// a Bitmap and then wrap it in a BitmapScreenNail instead.
ScreenNail s = mItem.getScreenNail();
if (s != null) return s;
// If this is a temporary item, don't try to get its bitmap because
// it won't be available. We will get its bitmap after a data reload.
if (isTemporaryItem(mItem)) {
return newPlaceholderScreenNail(mItem);
}
Bitmap bitmap = mItem.requestImage(MediaItem.TYPE_THUMBNAIL).run(jc);
if (jc.isCancelled()) return null;
if (bitmap != null) {
bitmap = BitmapUtils.rotateBitmap(bitmap,
mItem.getRotation() - mItem.getFullImageRotation(), true);
}
return bitmap == null ? null : new TiledScreenNail(bitmap);
}
开发者ID:asm-products,项目名称:nexus-gallery,代码行数:22,代码来源:PhotoDataAdapter.java
示例11: loadInBackground
import com.android.gallery3d.common.BitmapUtils; //导入依赖的package包/类
public boolean loadInBackground() {
ExifInterface ei = new ExifInterface();
if (readExif(ei)) {
Integer ori = ei.getTagIntValue(ExifInterface.TAG_ORIENTATION);
if (ori != null) {
mRotation = ExifInterface.getRotationForOrientationValue(ori.shortValue());
}
}
mDecoder = loadBitmapRegionDecoder();
if (mDecoder == null) {
mState = State.ERROR_LOADING;
return false;
} else {
int width = mDecoder.getWidth();
int height = mDecoder.getHeight();
if (mPreviewSize != 0) {
int previewSize = Math.min(mPreviewSize, MAX_PREVIEW_SIZE);
BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inPreferredConfig = Bitmap.Config.ARGB_8888;
opts.inPreferQualityOverSpeed = true;
float scale = (float) previewSize / Math.max(width, height);
opts.inSampleSize = BitmapUtils.computeSampleSizeLarger(scale);
opts.inJustDecodeBounds = false;
mPreview = loadPreviewBitmap(opts);
}
mState = State.LOADED;
return true;
}
}
开发者ID:Phonemetra,项目名称:TurboLauncher,代码行数:31,代码来源:BitmapRegionTileSource.java
示例12: cropImageAndSetWallpaper
import com.android.gallery3d.common.BitmapUtils; //导入依赖的package包/类
protected void cropImageAndSetWallpaper(Resources res, int resId,
final boolean finishActivityWhenDone, final boolean shouldFadeOutOnFinish) {
// crop this image and scale it down to the default wallpaper size for
// this device
int rotation = BitmapUtils.getRotationFromExif(res, resId);
Point inSize = mCropView.getSourceDimensions();
Point outSize = WallpaperUtils.getDefaultWallpaperSize(getResources(), getWindowManager());
RectF crop = Utils.getMaxCropRect(
inSize.x, inSize.y, outSize.x, outSize.y, false);
BitmapCropTask.OnEndCropHandler onEndCrop = new BitmapCropTask.OnEndCropHandler() {
public void run(boolean cropSucceeded) {
// Passing 0, 0 will cause launcher to revert to using the
// default wallpaper size
updateWallpaperDimensions(0, 0);
if (finishActivityWhenDone) {
setResult(Activity.RESULT_OK);
finish();
if (cropSucceeded && shouldFadeOutOnFinish) {
overridePendingTransition(0, R.anim.fade_out);
}
}
}
};
BitmapCropTask cropTask = new BitmapCropTask(getContext(), res, resId,
crop, rotation, outSize.x, outSize.y, true, false, onEndCrop);
NycWallpaperUtils.executeCropTaskAfterPrompt(this, cropTask, getOnDialogCancelListener());
}
开发者ID:RunasSudo,项目名称:FLauncher,代码行数:28,代码来源:WallpaperCropActivity.java
示例13: getSupportedOperations
import com.android.gallery3d.common.BitmapUtils; //导入依赖的package包/类
@Override
public int getSupportedOperations() {
int supported = SUPPORT_PRINT | SUPPORT_SETAS;
if (isSharable()) supported |= SUPPORT_SHARE;
if (BitmapUtils.isSupportedByRegionDecoder(mContentType)) {
supported |= SUPPORT_EDIT | SUPPORT_FULL_IMAGE;
}
return supported;
}
开发者ID:asm-products,项目名称:nexus-gallery,代码行数:10,代码来源:UriImage.java
示例14: run
import com.android.gallery3d.common.BitmapUtils; //导入依赖的package包/类
@Override
public Bitmap run(JobContext jc) {
int targetSize = MediaItem.getTargetSize(mType);
Bitmap bitmap = BitmapFactory.decodeResource(mApplication.getResources(),
mResourceId);
if (mType == MediaItem.TYPE_MICROTHUMBNAIL) {
bitmap = BitmapUtils.resizeAndCropCenter(bitmap, targetSize, true);
} else {
bitmap = BitmapUtils.resizeDownBySideLength(bitmap, targetSize, true);
}
return bitmap;
}
开发者ID:asm-products,项目名称:nexus-gallery,代码行数:14,代码来源:ActionImage.java
示例15: onFutureDone
import com.android.gallery3d.common.BitmapUtils; //导入依赖的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
示例16: BitmapTileProvider
import com.android.gallery3d.common.BitmapUtils; //导入依赖的package包/类
public BitmapTileProvider(Bitmap bitmap, int maxBackupSize) {
mImageWidth = bitmap.getWidth();
mImageHeight = bitmap.getHeight();
ArrayList<Bitmap> list = new ArrayList<Bitmap>();
list.add(bitmap);
while (bitmap.getWidth() > maxBackupSize
|| bitmap.getHeight() > maxBackupSize) {
bitmap = BitmapUtils.resizeBitmapByScale(bitmap, 0.5f, false);
list.add(bitmap);
}
mScreenNail = new BitmapScreenNail(list.remove(list.size() - 1));
mMipmaps = list.toArray(new Bitmap[list.size()]);
mConfig = Config.ARGB_8888;
}
开发者ID:asm-products,项目名称:nexus-gallery,代码行数:16,代码来源:BitmapTileProvider.java
示例17: recycle
import com.android.gallery3d.common.BitmapUtils; //导入依赖的package包/类
public void recycle() {
if (mRecycled) return;
mRecycled = true;
for (Bitmap bitmap : mMipmaps) {
BitmapUtils.recycleSilently(bitmap);
}
if (mScreenNail != null) {
mScreenNail.recycle();
}
}
开发者ID:asm-products,项目名称:nexus-gallery,代码行数:11,代码来源:BitmapTileProvider.java
示例18: addTemporaryWallpaperTile
import com.android.gallery3d.common.BitmapUtils; //导入依赖的package包/类
private void addTemporaryWallpaperTile(final Uri uri, boolean fromRestore) {
mTempWallpaperTiles.add(uri);
// Add a tile for the image picked from Gallery
final FrameLayout pickedImageThumbnail = (FrameLayout) getLayoutInflater().
inflate(R.layout.wallpaper_picker_item, mWallpapersView, false);
pickedImageThumbnail.setVisibility(View.GONE);
mWallpapersView.addView(pickedImageThumbnail, 0);
// Load the thumbnail
final ImageView image = (ImageView) pickedImageThumbnail.findViewById(R.id.wallpaper_image);
final Point defaultSize = getDefaultThumbnailSize(this.getResources());
final Context context = getContext();
new AsyncTask<Void, Bitmap, Bitmap>() {
protected Bitmap doInBackground(Void...args) {
try {
int rotation = BitmapUtils.getRotationFromExif(context, uri);
return createThumbnail(defaultSize, context, uri, null, null, 0, rotation, false);
} catch (SecurityException securityException) {
if (isActivityDestroyed()) {
// Temporarily granted permissions are revoked when the activity
// finishes, potentially resulting in a SecurityException here.
// Even though {@link #isDestroyed} might also return true in different
// situations where the configuration changes, we are fine with
// catching these cases here as well.
cancel(false);
} else {
// otherwise it had a different cause and we throw it further
throw securityException;
}
return null;
}
}
protected void onPostExecute(Bitmap thumb) {
if (!isCancelled() && thumb != null) {
image.setImageBitmap(thumb);
Drawable thumbDrawable = image.getDrawable();
thumbDrawable.setDither(true);
pickedImageThumbnail.setVisibility(View.VISIBLE);
} else {
Log.e(TAG, "Error loading thumbnail for uri=" + uri);
}
}
}.execute();
UriWallpaperInfo info = new UriWallpaperInfo(uri);
pickedImageThumbnail.setTag(info);
info.setView(pickedImageThumbnail);
addLongPressHandler(pickedImageThumbnail);
updateTileIndices();
pickedImageThumbnail.setOnClickListener(mThumbnailOnClickListener);
if (!fromRestore) {
mThumbnailOnClickListener.onClick(pickedImageThumbnail);
}
}
开发者ID:Mr-lin930819,项目名称:SimplOS,代码行数:55,代码来源:WallpaperPickerActivity.java
示例19: addTemporaryWallpaperTile
import com.android.gallery3d.common.BitmapUtils; //导入依赖的package包/类
private void addTemporaryWallpaperTile(final Uri uri, boolean fromRestore) {
// Add a tile for the image picked from Gallery, reusing the existing tile if there is one.
FrameLayout existingImageThumbnail = null;
int indexOfExistingTile = 0;
for (; indexOfExistingTile < mWallpapersView.getChildCount(); indexOfExistingTile++) {
FrameLayout thumbnail = (FrameLayout) mWallpapersView.getChildAt(indexOfExistingTile);
Object tag = thumbnail.getTag();
if (tag instanceof UriWallpaperInfo && ((UriWallpaperInfo) tag).mUri.equals(uri)) {
existingImageThumbnail = thumbnail;
break;
}
}
final FrameLayout pickedImageThumbnail;
if (existingImageThumbnail != null) {
pickedImageThumbnail = existingImageThumbnail;
// Always move the existing wallpaper to the front so user can see it without scrolling.
mWallpapersView.removeViewAt(indexOfExistingTile);
mWallpapersView.addView(existingImageThumbnail, 0);
} else {
// This is the first time this temporary wallpaper has been added
pickedImageThumbnail = (FrameLayout) getLayoutInflater()
.inflate(R.layout.wallpaper_picker_item, mWallpapersView, false);
pickedImageThumbnail.setVisibility(View.GONE);
mWallpapersView.addView(pickedImageThumbnail, 0);
mTempWallpaperTiles.add(uri);
}
// Load the thumbnail
final ImageView image = (ImageView) pickedImageThumbnail.findViewById(R.id.wallpaper_image);
final Point defaultSize = getDefaultThumbnailSize(this.getResources());
final Context context = getContext();
new AsyncTask<Void, Bitmap, Bitmap>() {
protected Bitmap doInBackground(Void...args) {
try {
int rotation = BitmapUtils.getRotationFromExif(context, uri);
return createThumbnail(defaultSize, context, uri, null, null, 0, rotation,
false);
} catch (SecurityException securityException) {
if (isActivityDestroyed()) {
// Temporarily granted permissions are revoked when the activity
// finishes, potentially resulting in a SecurityException here.
// Even though {@link #isDestroyed} might also return true in different
// situations where the configuration changes, we are fine with
// catching these cases here as well.
cancel(false);
} else {
// otherwise it had a different cause and we throw it further
throw securityException;
}
return null;
}
}
protected void onPostExecute(Bitmap thumb) {
if (!isCancelled() && thumb != null) {
image.setImageBitmap(thumb);
Drawable thumbDrawable = image.getDrawable();
thumbDrawable.setDither(true);
pickedImageThumbnail.setVisibility(View.VISIBLE);
} else {
Log.e(TAG, "Error loading thumbnail for uri=" + uri);
}
}
}.execute();
UriWallpaperInfo info = new UriWallpaperInfo(uri);
pickedImageThumbnail.setTag(info);
info.setView(pickedImageThumbnail);
addLongPressHandler(pickedImageThumbnail);
updateTileIndices();
pickedImageThumbnail.setOnClickListener(mThumbnailOnClickListener);
if (!fromRestore) {
mThumbnailOnClickListener.onClick(pickedImageThumbnail);
}
}
开发者ID:RunasSudo,项目名称:FLauncher,代码行数:75,代码来源:WallpaperPickerActivity.java
示例20: onDecodeOriginal
import com.android.gallery3d.common.BitmapUtils; //导入依赖的package包/类
@Override
public Bitmap onDecodeOriginal(JobContext jc, int type) {
Bitmap bitmap = BitmapUtils.createVideoThumbnail(mLocalFilePath);
if (bitmap == null || jc.isCancelled()) return null;
return bitmap;
}
开发者ID:asm-products,项目名称:nexus-gallery,代码行数:7,代码来源:LocalVideo.java
注:本文中的com.android.gallery3d.common.BitmapUtils类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论