Alternative to Color.valueOf for API Level < 26?

Viewed 2794

I'm currently working with Bitmap and trying to make some operation on pixels. I wanted to use Color.argb() and Color.valueOf() but those doesn't work for API Level < 26.

Is there any library or something similar that could work with any API Level > 21 ?

Here is the part of the function I use :

int width =  myBitmap.getWidth();
int height = myBitmap.getHeight();
Bitmap bmp = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
int [] allpixels = new int [ bmp.getHeight()*bmp.getWidth()];
myBitmap.getPixels(allpixels, 0, bmp.getWidth(), 0, 0, bmp.getWidth(),bmp.getHeight());
bmp.setPixels(allpixels, 0, width, 0, 0, width, height);

for(int i =0; i<bmp.getHeight()*bmp.getWidth();i++) {
    allpixels[i] = Color.argb(
        Color.valueOf(allpixels[i]).red(),
        Color.valueOf(allpixels[i]).red(),
        Color.valueOf(allpixels[i]).green(),
        Color.valueOf(allpixels[i]).blue());
}
1 Answers
Related