Kam*_*ops 5 android colors bitmap
我目前正在使用Bitmap,并尝试对像素进行一些操作。我想使用Color.argb(),Color.valueOf()但是对于API Level <26而言,这些功能不起作用。
是否有任何库或类似的东西可以与任何API Level> 21一起使用?
这是我使用的部分功能:
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());
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
732 次 |
| 最近记录: |