summaryrefslogtreecommitdiff
path: root/android/source/src/java/org/libreoffice/canvas/ImageUtils.java
blob: fd62444c41be8dcca36a9cc0658a20c25b009535 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package org.libreoffice.canvas;

import android.graphics.Bitmap;
import android.graphics.Color;

public class ImageUtils {
    /**
     * Convert transparent pixels to gray ones.
     */
    public static Bitmap bitmapToPressed(Bitmap input) {
        Bitmap op = Bitmap.createBitmap(input.getWidth(), input.getHeight(), input.getConfig());
        for(int i=0; i<op.getWidth(); i++){
            for(int j=0; j<op.getHeight(); j++){
                int p = input.getPixel(i, j);
                // assign gray color if the pixel in input is transparent.
                int newColor = Color.alpha(p) == 0 ? Color.argb(255, 200, 200, 200) : p;
                op.setPixel(i, j, newColor);
            }
        }

        return op;
    }
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */