use of com.android.gallery3d.filtershow.pipeline.ImagePreset in project android_packages_apps_Gallery2 by LineageOS.
the class MasterImage method onHistoryItemClick.
public void onHistoryItemClick(int position, boolean updateCategory) {
HistoryItem historyItem = mHistory.getItem(position);
// We need a copy from the history
if (historyItem == null) {
return;
}
ImagePreset newPreset = new ImagePreset(historyItem.getImagePreset());
// don't need to add it to the history
setPreset(newPreset, historyItem.getFilterRepresentation(), false, updateCategory);
mHistory.setCurrentPreset(position);
}
use of com.android.gallery3d.filtershow.pipeline.ImagePreset in project android_packages_apps_Gallery2 by LineageOS.
the class SaveWaterMark method saveImage.
public void saveImage(Context context, final Bitmap bitmap, Uri selectedUri, Handler handler, int quality, float scaleFactor, boolean isScale) {
mContext = context;
WaterMarkView mWaterMarkView = waterMarkRp.getWaterMarkView();
mWaterMarkView.clearEditTextCursor();
Bitmap markBitmap = mWaterMarkView.creatNewPhoto();
new AsyncTask<Bitmap, Void, Uri>() {
@Override
protected Uri doInBackground(Bitmap... bitmaps) {
ImagePreset ip = MasterImage.getImage().getPreset();
FilterFusionRepresentation fusionRep = findFusionRepresentation(ip);
boolean hasFusion = (fusionRep != null && fusionRep.hasUnderlay());
Bitmap destinationBitmap = createBitmap(bitmap, bitmaps[0]);
Bitmap fusionBmp = null;
// sampleSize is 1 for fusion bitmap of 1:1 size,
// sizeConstraint is 0 for fusion without width or height constraint.
final int sampleSize = 1, sizeConstraint = 0;
if (hasFusion) {
fusionBmp = SaveImage.flattenFusion(mContext, Uri.parse(fusionRep.getUnderlay()), destinationBitmap, sizeConstraint, sampleSize);
if (fusionBmp != null) {
destinationBitmap.recycle();
destinationBitmap = fusionBmp;
}
}
File destinationFile = SaveImage.getNewFile(context, selectedUri);
// ExifInterface exif = getExifData(context, selectedUri);
long time = System.currentTimeMillis();
Uri saveUri = selectedUri;
if (scaleFactor != 1f) {
// if we have a valid size
int w = (int) (destinationBitmap.getWidth() * scaleFactor);
int h = (int) (destinationBitmap.getHeight() * scaleFactor);
if (w == 0 || h == 0) {
w = 1;
h = 1;
}
destinationBitmap = Bitmap.createScaledBitmap(destinationBitmap, w, h, true);
}
if (SaveImage.putExifData(destinationFile, mExif, destinationBitmap, quality)) {
saveUri = SaveImage.linkNewFileToUri(context, selectedUri, destinationFile, time, false);
}
destinationBitmap.recycle();
if (saveUri != selectedUri) {
Log.d(GalleryActivity.QSST, "watermark saved successfully" + waterMarkRp.getSerializationName());
}
return saveUri;
}
@Override
protected void onPostExecute(Uri uri) {
if (isScale)
return;
Message message = new Message();
message.what = MARK_SAVE_COMPLETE;
message.obj = uri;
handler.sendMessage(message);
}
}.execute(markBitmap);
}
use of com.android.gallery3d.filtershow.pipeline.ImagePreset in project android_packages_apps_Gallery2 by LineageOS.
the class ImageFilterTinyPlanet method apply.
@Override
public Bitmap apply(Bitmap bitmapIn, float scaleFactor, int quality) {
int w = bitmapIn.getWidth();
int h = bitmapIn.getHeight();
int outputSize = (int) (w / 2f);
ImagePreset preset = getEnvironment().getImagePreset();
Bitmap mBitmapOut = null;
if (preset != null) {
XMPMeta xmp = ImageLoader.getXmpObject(MasterImage.getImage().getActivity());
// Do nothing, just use bitmapIn as is if we don't have XMP.
if (xmp != null) {
bitmapIn = applyXmp(bitmapIn, xmp, w);
}
}
if (mBitmapOut != null) {
if (outputSize != mBitmapOut.getHeight()) {
mBitmapOut = null;
}
}
while (mBitmapOut == null) {
try {
mBitmapOut = getEnvironment().getBitmap(outputSize, outputSize, BitmapCache.TINY_PLANET);
} catch (java.lang.OutOfMemoryError e) {
System.gc();
outputSize /= 2;
Log.v(LOGTAG, "No memory to create Full Tiny Planet create half");
}
}
nativeApplyFilter(bitmapIn, bitmapIn.getWidth(), bitmapIn.getHeight(), mBitmapOut, outputSize, mParameters.getZoom() / 100f, mParameters.getAngle());
return mBitmapOut;
}
Aggregations