Picture editor in Android
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.
Any开发者_运维问答one can help me?
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.
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.
精彩评论