画像が直線的にフェードするように、画像にアルファ グラデーションを適用するにはどうすればよいですか? 現在、単位幅の長方形を作成し、それを使用して、ループ内でアルファ値が変更されたペイント オブジェクトでビットマップを描画しています。他に思いつかなかったのでそうしました。したがって、よりきちんとした方法が良いでしょう。
Bitmap bitmap = BitmapFactory.decodeStream(is);
Bitmap bmp = Bitmap.createScaledBitmap(bitmap, 100, 151, true));
bitmap.recycle();
Rect Rect1 = new Rect(0, 0, 100, 100);
Rect Rect2 = new Rect(100, 0, 101, 100);
Paint paint = new Paint();
canvas.drawBitmap(bmp, Rect1, Rect1, null);
while (paint.getAlpha() != 0) {
paint.setAlpha(paint.getAlpha() - 5);
canvas.drawBitmap(bmp, Rect2, Rect2, paint);
Rect2.set(Rect2.left + 1, Rect2.top, Rect2.right + 1, Rect2.bottom);
}
このようなもの
PSライブ壁紙用にこれをやろうとしています。