我的Main2Activity
班级
public class Main2Activity extends AppCompatActivity {
Uri imageUri;
Bitmap bitmap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
imageView2 = (ImageView) findViewById(R.id.imageView2);
//It not show error.
if (getIntent().getExtras() != null) {
try {
imageUri = Uri.parse(getIntent().getStringExtra("imageUri"));
bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), imageUri);
int nh = (int) (bitmap.getHeight() * (1024.0 / bitmap.getWidth()));
// Set image
Picasso.with(this).load(imageUri).
resize(1024, nh).
into(imageView2);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
//Show trouble code.
public void ColorMake(View v) {
int width = bitmap.getWidth();
int height = bitmap.getHeight();
Bitmap bmOut = Bitmap.createBitmap(width, height, bitmap.getConfig());
int A, R, G, B;
double red = 1.3;
double green = 1.0;
double blue = 1.2;
int pixel;
for (int x = 0; x < width; ++x) {
for (int y = 0; y < height; ++y) {
pixel = bitmap.getPixel(x, y);
A = Color.alpha(pixel);
R = (int) (Color.red(pixel) * red);
G = (int) (Color.green(pixel) * green);
B = (int) (Color.blue(pixel) * blue);
bmOut.setPixel(x, y, Color.argb(A, R, G, B));
}
}
}
}
它不是显示错误,但在设备上不起作用。