【发布时间】:2021-06-18 17:10:17
【问题描述】:
我正在尝试图像翻转和图像过滤但是我有一个问题当我在图像上放置过滤器然后当我翻转图像时过滤器被删除
public void Flipimg(View v1){
img1.setImageBitmap(fliph(scaledBitmap));
}
public Bitmap fliph(Bitmap bms){
Matrix mat = new Matrix();
mat.setScale(-1, 1);
Bitmap bit1=Bitmap.createBitmap( bms, 0, 0, bms.getWidth(), bms.getHeight(), mat, true);
return bit;
public void Filterimg(View v2){
img1.setImageBitmap(applyGreyscaleEffect(scaledBitmap));
}
public Bitmap applyGreyscaleEffect(Bitmap src) {
final double GS_RED = 0.299;
final double GS_GREEN = 0.587;
final double GS_BLUE = 0.114;
Bitmap bmOut = Bitmap.createBitmap(src.getWidth(), src.getHeight(), src.getConfig());
int A, R, G, B;
int pixel;
int width = src.getWidth();
int height = src.getHeight();
for (int x = 0; x < width; ++x) {
for (int y = 0; y < height; ++y) {
pixel = src.getPixel(x, y);
A = Color.alpha(pixel);
R = Color.red(pixel);
G = Color.green(pixel);
B = Color.blue(pixel);
R = G = B = (int) (GS_RED * R + GS_GREEN * G + GS_BLUE * B);
bmOut.setPixel(x, y, Color.argb(A, R, G, B));}
}
return bmOut;
【问题讨论】:
标签: android image filter bitmap flip