use of android.graphics.Matrix in project fresco by facebook.
the class MainActivity method loadTranslatedBitmap.
public void loadTranslatedBitmap(int x, int y, int width, int height, int tx, int ty) {
Matrix matrix = getMatrix(tx, ty, 1, 1, 0);
CloseableReference<Bitmap> bitmapRef = mBitmapFactory.createBitmap(mOriginalBitmap, x, y, width, height, matrix, true);
setImageBitmap(bitmapRef);
checkValid(bitmapRef, Bitmap.createBitmap(mOriginalBitmap, x, y, width, height, matrix, true));
}
use of android.graphics.Matrix in project cardslib by gabrielemariotti.
the class RoundCornersDrawable method onBoundsChange.
@Override
protected void onBoundsChange(Rect bounds) {
super.onBoundsChange(bounds);
mRect.set(mMargin, mMargin, bounds.width() - mMargin, bounds.height() - mMargin);
mRectBottomR.set((bounds.width() - mMargin) / 2, (bounds.height() - mMargin) / 2, bounds.width() - mMargin, bounds.height() - mMargin);
mRectBottomL.set(0, (bounds.height() - mMargin) / 2, (bounds.width() - mMargin) / 2, bounds.height() - mMargin);
if (USE_VIGNETTE) {
RadialGradient vignette = new RadialGradient(mRect.centerX(), mRect.centerY() * 1.0f / 0.7f, mRect.centerX() * 1.3f, new int[] { 0, 0, 0x7f000000 }, new float[] { 0.0f, 0.7f, 1.0f }, Shader.TileMode.CLAMP);
Matrix oval = new Matrix();
oval.setScale(1.0f, 0.7f);
vignette.setLocalMatrix(oval);
mPaint.setShader(new ComposeShader(mBitmapShader, vignette, PorterDuff.Mode.SRC_OVER));
}
}
use of android.graphics.Matrix in project cardslib by gabrielemariotti.
the class RoundCornersDrawable method onBoundsChange.
@Override
protected void onBoundsChange(Rect bounds) {
super.onBoundsChange(bounds);
mRect.set(mMargin, mMargin, bounds.width() - mMargin, bounds.height() - mMargin);
if (USE_VIGNETTE) {
RadialGradient vignette = new RadialGradient(mRect.centerX(), mRect.centerY() * 1.0f / 0.7f, mRect.centerX() * 1.3f, new int[] { 0, 0, 0x7f000000 }, new float[] { 0.0f, 0.7f, 1.0f }, Shader.TileMode.CLAMP);
Matrix oval = new Matrix();
oval.setScale(1.0f, 0.7f);
vignette.setLocalMatrix(oval);
mPaint.setShader(new ComposeShader(mBitmapShader, vignette, PorterDuff.Mode.SRC_OVER));
}
}
use of android.graphics.Matrix in project AndroidSDK-RecipeBook by gabu.
the class Recipe048 method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LinearLayout linearLayout = new LinearLayout(this);
// 元画像をリソースから読み込む
Bitmap src = BitmapFactory.decodeResource(getResources(), R.drawable.src);
// 元画像のwidth
int srcWidth = src.getWidth();
// 元画像のheight
int srcHeight = src.getHeight();
// リサイズしたい新しい画像のサイズ
Matrix matrix = new Matrix();
// リサイズ後のwidth
float dstWidth = 50;
// リサイズ後のheight
float dstHeight = 50;
// Scaleなので、新しいサイズ / 元のサイズ の値を設定する
matrix.postScale(dstWidth / srcWidth, dstHeight / srcHeight);
// 切り取り!
Bitmap dst = // 元画像
Bitmap.createBitmap(// 元画像
src, // 開始X座標
20, // 開始Y座標
20, // 切り取るwidth
100, // 切り取るheight
100);
ImageView imageView01 = new ImageView(this);
imageView01.setImageBitmap(src);
ImageView imageView02 = new ImageView(this);
imageView02.setImageBitmap(dst);
linearLayout.addView(imageView01);
linearLayout.addView(imageView02);
setContentView(linearLayout);
}
use of android.graphics.Matrix in project fresco by facebook.
the class ScaleTypeDrawableTest method testConfigureBounds_FOCUS_CROP_HL.
/**
* Underlying drawable's aspect ratio is bigger than view's, so it has to be slided horizontally
* after scaling. Focus point is too much left, so it cannot be completely centered. Left-most
* part of the image is displayed.
*/
@Test
public void testConfigureBounds_FOCUS_CROP_HL() {
Rect bounds = new Rect(10, 10, 410, 310);
int width = 400;
int height = 200;
PointF focusPoint = new PointF(0.1f, 0.5f);
Matrix expectedMatrix = new Matrix();
expectedMatrix.setScale(1.5f, 1.5f);
expectedMatrix.postTranslate(10, 10);
testConfigureBounds(bounds, width, height, ScaleType.FOCUS_CROP, focusPoint, expectedMatrix);
}
Aggregations