view = (MovableLinearLayout) inflater.inflate(R.layout.filtershow_imagestate_row, null);
}
FilterRepresentation filter = getItem(position);
- filter.synchronizeRepresentation();
view.setFilterRepresentation(filter);
ImageView markView = (ImageView) view.findViewById(R.id.selectedMark);
if (filter == MasterImage.getImage().getCurrentFilterRepresentation()) {
return bitmap;
}
- /**
- * Called on small bitmaps to create button icons for each filter. Override
- * this to provide filter-specific button icons.
- */
- public Bitmap iconApply(Bitmap bitmap, float scaleFactor, int quality) {
- return apply(bitmap, scaleFactor, quality);
- }
-
public ImagePreset getImagePreset() {
return getEnvironment().getImagePreset();
}
return applyHelper(bitmap, scale1, scale2);
}
- @Override
- public Bitmap iconApply(Bitmap bitmap, float scaleFactor, int quality) {
- if (getParameters() == null || getParameters().getDrawableResource() == 0) {
- return bitmap;
- }
- float scale1 = NINEPATCH_ICON_SCALING;
- float scale2 = BITMAP_ICON_SCALING;
- return applyHelper(bitmap, scale1, scale2);
- }
-
public void setResources(Resources resources) {
if (mResources != resources) {
mResources = resources;
}
return bitmap;
}
-
- @Override
- public Bitmap iconApply(Bitmap bitmap, float scaleFactor, int quality) {
- int w = bitmap.getWidth();
- int h = bitmap.getHeight();
- Bitmap ret = Bitmap.createScaledBitmap(bitmap, w / ICON_DOWNSAMPLE_FRACTION, h
- / ICON_DOWNSAMPLE_FRACTION, false);
- Rect dst = new Rect(0, 0, w, h);
- Rect src = new Rect(0, 0, w / ICON_DOWNSAMPLE_FRACTION, h / ICON_DOWNSAMPLE_FRACTION);
- Canvas c = new Canvas(bitmap);
- c.drawBitmap(ret, src, dst, null);
- return bitmap;
- }
}
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.RectF;
+import android.util.Log;
import com.android.gallery3d.filtershow.CropExtras;
import com.android.gallery3d.filtershow.imageshow.GeometryMath;
// TODO: implement bilinear or bicubic here... for now, just use
// canvas to do a simple implementation...
// TODO: and be more memory efficient! (do it in native?)
-
+ RectF cb = mGeometry.getPreviewCropBounds();
+ RectF pb = mGeometry.getPhotoBounds();
+ if (cb.width() == 0 || cb.height() == 0 || pb.width() == 0 || pb.height() == 0) {
+ Log.w(LOGTAG, "Cannot apply geometry: geometry metadata has not been initialized");
+ return bitmap;
+ }
CropExtras extras = mGeometry.getCropExtras();
boolean useExtras = mGeometry.getUseCropExtrasFlag();
int outputX = 0;
return bitmap;
}
- @Override
- public Bitmap iconApply(Bitmap bitmap, float scaleFactor, int quality) {
- Canvas canvas = new Canvas(bitmap);
- applyHelper(canvas, bitmap.getWidth() * 4, bitmap.getHeight() * 4);
- return bitmap;
- }
-
}
package com.android.gallery3d.filtershow.filters;
-import android.graphics.Bitmap;
-
public class SimpleImageFilter extends ImageFilter {
private FilterBasicRepresentation mParameters;
public FilterBasicRepresentation getParameters() {
return mParameters;
}
-
- @Override
- public Bitmap iconApply(Bitmap bitmap, float scaleFactor, int quality) {
- FilterRepresentation representation = getDefaultRepresentation();
- this.useRepresentation(representation);
- return apply(bitmap, scaleFactor, quality);
- }
}
private Bitmap mGeometryOnlyBitmap = null;
private Bitmap mFiltersOnlyBitmap = null;
private Bitmap mPartialBitmap = null;
- private Bitmap mThumbnailBitmap = null;
private ImageLoader mLoader = null;
private HistoryAdapter mHistory = null;
public void hasNewGeometry() {
updatePresets(true);
- computeThumbnailBitmap();
for (GeometryListener listener : mGeometryListeners) {
listener.geometryChanged();
}
}
- private Bitmap createSquareImage(Bitmap dst, Bitmap image, Rect destination) {
- if (image != null) {
- Canvas canvas = new Canvas(dst);
- int iw = image.getWidth();
- int ih = image.getHeight();
- int x = 0;
- int y = 0;
- int size = 0;
- Rect source = null;
- if (iw > ih) {
- size = ih;
- x = (int) ((iw - size) / 2.0f);
- y = 0;
- } else {
- size = iw;
- x = 0;
- y = (int) ((ih - size) / 2.0f);
- }
- source = new Rect(x, y, x + size, y + size);
- canvas.drawBitmap(image, source, destination, new Paint());
- }
- return dst;
- }
-
- public void computeThumbnailBitmap() {
- Bitmap bmap = mLoader.getOriginalBitmapSmall();
- if (bmap == null) {
- return;
- }
- ImagePreset geoPreset = new ImagePreset(MasterImage.getImage().getGeometryPreset());
- geoPreset.setupEnvironment();
- bmap = geoPreset.applyGeometry(bmap);
- float w = bmap.getWidth();
- float h = bmap.getHeight();
- float s = Math.min(w, h);
- float f = sIconSeedSize / s;
- w = w * f;
- h = h * f;
- s = Math.min(w, h);
- Bitmap bmap2 = Bitmap.createScaledBitmap(bmap, (int) s, (int) s, true);
- bmap = createSquareImage(bmap2, bmap, new Rect(0, 0, (int) s, (int) s));
- if (DEBUG) {
- Log.v(LOGTAG, "Create thumbnail of size " + bmap.getWidth() + " x " + bmap.getHeight()
- + " seed size: " + sIconSeedSize);
- }
- mThumbnailBitmap = bmap;
- }
public float getScaleFactor() {
return mScaleFactor;
}
public Bitmap getThumbnailBitmap() {
- return mThumbnailBitmap;
+ return mLoader.getOriginalBitmapSmall();
}
public float getMaxScaleFactor() {
if (dst != null) {
ImagePreset mPreset = new ImagePreset();
mPreset.addFilter(mFilterRepresentation);
- mPreset.setDoApplyGeometry(false);
RenderingRequest.post(dst.copy(Bitmap.Config.ARGB_8888, true),
mPreset, RenderingRequest.ICON_RENDERING, this);
}