mCategoryBordersAdapter.reflectImagePreset(preset);
}
+ private class LoadHighresBitmapTask extends AsyncTask<Void, Void, Boolean> {
+ @Override
+ protected Boolean doInBackground(Void... params) {
+ mImageLoader.loadHighResBitmap();
+ return true;
+ }
+
+ @Override
+ protected void onPostExecute(Boolean result) {
+ Bitmap highresBitmap = mImageLoader.getOriginalBitmapHighres();
+ if (highresBitmap != null) {
+ FilteringPipeline pipeline = FilteringPipeline.getPipeline();
+ float highResPreviewScale = (float) highresBitmap.getWidth() / (float) mImageLoader.getOriginalBounds().width();
+ pipeline.setHighResPreviewScaleFactor(highResPreviewScale);
+ }
+ }
+ }
+
private class LoadBitmapTask extends AsyncTask<Uri, Boolean, Boolean> {
int mBitmapSize;
pipeline.setOriginal(largeBitmap);
float previewScale = (float) largeBitmap.getWidth() / (float) mImageLoader.getOriginalBounds().width();
pipeline.setPreviewScaleFactor(previewScale);
- Bitmap highresBitmap = mImageLoader.getOriginalBitmapHighres();
- if (highresBitmap != null) {
- float highResPreviewScale = (float) highresBitmap.getWidth() / (float) mImageLoader.getOriginalBounds().width();
- pipeline.setHighResPreviewScaleFactor(highResPreviewScale);
- }
if (!mShowingTinyPlanet) {
mCategoryFiltersAdapter.removeTinyPlanet();
}
}
mLoading = false;
MasterImage.getImage().notifyGeometryChange();
+ LoadHighresBitmapTask highresLoad = new LoadHighresBitmapTask();
+ highresLoad.execute();
super.onPostExecute(result);
}
private static int mZoomOrientation = ORI_NORMAL;
static final int MAX_BITMAP_DIM = 900;
+ static final int SMALL_BITMAP_DIM = 160;
private ReentrantLock mLoadingLock = new ReentrantLock();
return mActivity;
}
+ public void loadHighResBitmap() {
+ if (MasterImage.getImage().supportsHighRes()) {
+ int highresPreviewSize = mOriginalBitmapLarge.getWidth() * 2;
+ if (highresPreviewSize > mOriginalBounds.width()) {
+ highresPreviewSize = mOriginalBounds.width();
+ }
+ mOriginalBitmapHighres = loadScaledBitmap(mUri, highresPreviewSize, false);
+ if (mOrientation > 1 && mOriginalBitmapHighres != null) {
+ mOriginalBitmapHighres = rotateToPortrait(mOriginalBitmapHighres, mOrientation);
+ }
+ warnListeners();
+ }
+ }
+
public boolean loadBitmap(Uri uri, int size) {
mLoadingLock.lock();
mUri = uri;
mOrientation = getOrientation(mContext, uri);
- mOriginalBitmapSmall = loadScaledBitmap(uri, 160);
- if (mOriginalBitmapSmall == null) {
- // Couldn't read the bitmap, let's exit
- mLoadingLock.unlock();
- return false;
- }
mOriginalBitmapLarge = loadScaledBitmap(uri, size);
if (mOriginalBitmapLarge == null) {
mLoadingLock.unlock();
return false;
}
- if (MasterImage.getImage().supportsHighRes()) {
- int highresPreviewSize = mOriginalBitmapLarge.getWidth() * 2;
- if (highresPreviewSize > mOriginalBounds.width()) {
- highresPreviewSize = mOriginalBounds.width();
- }
- mOriginalBitmapHighres = loadScaledBitmap(uri, highresPreviewSize, false);
- }
updateBitmaps();
mLoadingLock.unlock();
return true;
private void updateBitmaps() {
if (mOrientation > 1) {
- mOriginalBitmapSmall = rotateToPortrait(mOriginalBitmapSmall, mOrientation);
mOriginalBitmapLarge = rotateToPortrait(mOriginalBitmapLarge, mOrientation);
- if (mOriginalBitmapHighres != null) {
- mOriginalBitmapHighres = rotateToPortrait(mOriginalBitmapHighres, mOrientation);
- }
}
+ int sw = SMALL_BITMAP_DIM;
+ int sh = (int) (sw * (float) mOriginalBitmapLarge.getHeight() / (float) mOriginalBitmapLarge.getWidth());
+ mOriginalBitmapSmall = Bitmap.createScaledBitmap(mOriginalBitmapLarge, sw, sh, true);
mZoomOrientation = mOrientation;
warnListeners();
}
ImageShow imageShow = mListeners.elementAt(i);
imageShow.imageLoaded();
}
+ MasterImage.getImage().invalidatePreview();
}
};