Reputation: 41
I am quite new to Android development and I wish like to develop my first app which is a picture editor.
Basically it can let the user adjust the brightness, contrast, black and white effects.
I would like to ask which package should I look for? I have roughly go through the Android API and I couldn't found any related packages.
Anyone can help me?
Upvotes: 4
Views: 2162
Reputation: 28823
Check this:
Android - Bitmap set contrast and brightness
You can set Contrast on bitmap using this:
private static void setContrastScaleOnly(ColorMatrix cm, float contrast) {
float scale = contrast + 1.f;
float translate = (-.5f * scale + .5f) * 255.f;
cm.set(new float[] {
scale, 0, 0, 0, 0,
0, scale, 0, 0, 0,
0, 0, scale, 0, 0,
0, 0, 0, 1, 0 });
}
private static void setContrast(ColorMatrix cm, float contrast) {
float scale = contrast + 1.f;
float translate = (-.5f * scale + .5f) * 255.f;
cm.set(new float[] {
scale, 0, 0, 0, translate,
0, scale, 0, 0, translate,
0, 0, scale, 0, translate,
0, 0, 0, 1, 0 });
}
private static void setContrastTranslateOnly(ColorMatrix cm, float contrast) {
float scale = contrast + 1.f;
float translate = (-.5f * scale + .5f) * 255.f;
cm.set(new float[] {
1, 0, 0, 0, translate,
0, 1, 0, 0, translate,
0, 0, 1, 0, translate,
0, 0, 0, 1, 0 });
}
In your onDraw
call this methods with your params to set contrast and brightness.
Hope ti helps.
Upvotes: 1
Reputation: 12028
The place to start looking in the android doc would be the 2D Graphics section in particular the BitmapDrawable or PictureDrawable which display Bitmap and Picture. It will be up to you (or other 3rd party image manipulation libraries) to build up either a Picture or a Bitmap in memory, modify it, then use the *Drawable to write to the screen.
Upvotes: 0