Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- enum ColorComponent {RED, GREEN, BLUE};
- private Bitmap boostImpl(Bitmap bitmap, ColorComponent comp, float percent) {
- int width = bitmap.getWidth();
- int height = bitmap.getHeight();
- Bitmap bitmapDest = Bitmap.createBitmap(width, height, bitmap.getConfig());
- int alpha, red, green, blue;
- int pixel;
- for (int i = 0; i < width; ++i) {
- for (int j = 0; j < height; ++j) {
- pixel = bitmap.getPixel(i, j);
- alpha = Color.alpha(pixel);
- red = Color.red(pixel);
- green = Color.green(pixel);
- blue = Color.blue(pixel);
- if (comp == ColorComponent.RED) {
- red = (int) (red * (1 + percent));
- if (red > 255) {
- red = 255;
- }
- } else if (comp == ColorComponent.GREEN) {
- green = (int) (green * (1 + percent));
- if (green > 255) {
- green = 255;
- }
- } else if (comp == ColorComponent.BLUE) {
- blue = (int) (blue * (1 + percent));
- if (blue > 255) {
- blue = 255;
- }
- }
- bitmapDest.setPixel(i, j, Color.argb(alpha, red, green, blue));
- }
- }
- return bitmapDest;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement