List of usage examples for android.graphics Matrix postTranslate
public boolean postTranslate(float dx, float dy)
From source file:com.android.volley.ui.PhotoView.java
/** * Gets a bitmap of the cropped region. If cropping is not enabled, returns {@code null}. *//* ww w. j a va 2s .co m*/ public Bitmap getCroppedPhoto() { if (!mAllowCrop) { return null; } final Bitmap croppedBitmap = Bitmap.createBitmap((int) CROPPED_SIZE, (int) CROPPED_SIZE, Bitmap.Config.ARGB_8888); final Canvas croppedCanvas = new Canvas(croppedBitmap); // scale for the final dimensions final int cropWidth = mCropRect.right - mCropRect.left; final float scaleWidth = CROPPED_SIZE / cropWidth; final float scaleHeight = CROPPED_SIZE / cropWidth; // translate to the origin & scale final Matrix matrix = new Matrix(mDrawMatrix); matrix.postTranslate(-mCropRect.left, -mCropRect.top); matrix.postScale(scaleWidth, scaleHeight); // draw the photo if (mDrawable != null) { croppedCanvas.concat(matrix); mDrawable.draw(croppedCanvas); } return croppedBitmap; }
From source file:com.juce.JuceAppActivity.java
public final int[] renderGlyph (char glyph, Paint paint, android.graphics.Matrix matrix, Rect bounds) { Path p = new Path(); paint.getTextPath (String.valueOf (glyph), 0, 1, 0.0f, 0.0f, p); RectF boundsF = new RectF(); p.computeBounds (boundsF, true);// w w w. ja v a2 s . c o m matrix.mapRect (boundsF); boundsF.roundOut (bounds); bounds.left--; bounds.right++; final int w = bounds.width(); final int h = Math.max (1, bounds.height()); Bitmap bm = Bitmap.createBitmap (w, h, Bitmap.Config.ARGB_8888); Canvas c = new Canvas (bm); matrix.postTranslate (-bounds.left, -bounds.top); c.setMatrix (matrix); c.drawPath (p, paint); final int sizeNeeded = w * h; if (cachedRenderArray.length < sizeNeeded) cachedRenderArray = new int [sizeNeeded]; bm.getPixels (cachedRenderArray, 0, w, 0, 0, w, h); bm.recycle(); return cachedRenderArray; }
From source file:im.ene.lab.design.widget.coverflow.FeatureCoverFlow.java
private void addChildAdjustPosition(View child, Matrix m) { final int c = getChildsCenter(child); final float crp = getClampedRelativePosition(getRelativePosition(c), mAdjustPositionThreshold * getWidgetSizeMultiplier()); final float d = mCoverWidth * mAdjustPositionMultiplier * mSpacing * crp * getSpacingMultiplierOnCirlce(c); m.postTranslate(d, 0f); }
From source file:im.ene.lab.design.widget.coverflow.FeatureCoverFlow.java
private void setChildTransformation(View child, Matrix m) { m.reset();/*from w w w . j a v a 2s .com*/ // TODO FIXME // addChildRotation(child, m); addChildScale(child, m); addChildCircularPathZOffset(child, m); addChildAdjustPosition(child, m); //set coordinate system origin to center of child m.preTranslate(-child.getWidth() / 2f, -child.getHeight() / 2f); //move back m.postTranslate(child.getWidth() / 2f, child.getHeight() / 2f); }