when i load image from gallery to the imageview, it can't recognize the height and width of the image, but i load the image from drawable , it recognize the height and width of the image. please tell where i made a mistake?
here i attached the code below,
Blockquote
source = BitmapFactory.decodeResource(getResources(),R.id.image);
mRed = findViewById(R.id.red);
mRed.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
bitmap = applyColorFilterEffect(source, 255, 0, 0);
imageView.setImageBitmap(bitmap);
}
});
Blockquote
public Bitmap applyColorFilterEffect(Bitmap src, double red, double green, double blue) {
// image size
int width = src.getWidth();
int height = src.getHeight();
// create output bitmap
Bitmap bmOut = Bitmap.createBitmap(width, height, src.getConfig());
// color information
int A, R, G, B;
int pixel;
// scan through all pixels
for (int x = 0; x < width; ++x) {
for (int y = 0; y < height; ++y) {
//get pixel color
pixel = src.getPixel(x, y);
// apply filtering on each channel R, G, B
A = Color.alpha(pixel);
R = (int) (Color.red(pixel) * red);
G = (int) (Color.green(pixel) * green);
B = (int) (Color.blue(pixel) * blue);
// set new color pixel to output bitmap
bmOut.setPixel(x, y, Color.argb(A, R, G, B));
}
}
return bmOut;
}