Android Image Editor

Hasan picture Hasan · Nov 14, 2012 · Viewed 51.9k times · Source

I want to create an Android app where I can take a picture from the SD card or from the camera. After taking the picture, I have to edit it, like adding text in the picture, cropping the picture, add .gif type file to the picture. Taking a picture isn't the problem, but I can't understand how to write code to edit the picture. I need to know whether I have to use OpenGL for this. Suggestions and helpful links wanted.

Answer

Trung Nguyen picture Trung Nguyen · Nov 14, 2012

Your question is too vague. I provide some guide.

UPDATE 2020: You can browser all image processing library listed in Android Asernal https://android-arsenal.com/tag/47

  1. Using Aviary SDK now become Creative SDK . It also supports iOS and WindowPhone7. Aviary provide most of function such as Orientation, Crop, and Sharpness,Red-Eye, Whiten, and Blemish,Stickers, Drawing, Text, and Meme (beta),Brightness, Saturation, and Contrast and custom Options. SS.
  2. Fotor SDK
  3. Creative SDK by Adobe
  4. Directly process bitmap.
import android.graphics.Bitmap;

    public class ProcessingImage {
    private Bitmap defaultImg;
    private int idBitmap;

    public int getIdBitmap() {
        return idBitmap;
    }

    public void setIdBitmap(int idBitmap) {
        this.idBitmap = idBitmap;
    }

    public Bitmap getDefaultImg() {
        return defaultImg;
    }

    public void setDefaultImg(Bitmap defaultImg) {
        this.defaultImg = defaultImg;
    }

    public ProcessingImage() {
    }

    public Bitmap processingI(Bitmap myBitmap) {
        return myBitmap;
    }

    public Bitmap TintThePicture(int deg, Bitmap defaultBitmap) {
        int w = defaultBitmap.getWidth();
        int h = defaultBitmap.getHeight();

        int[] pix = new int[w * h];
        defaultBitmap.getPixels(pix, 0, w, 0, 0, w, h);

        double angle = (3.14159d * (double) deg) / 180.0d;
        int S = (int) (256.0d * Math.sin(angle));
        int C = (int) (256.0d * Math.cos(angle));

        int r, g, b, index;
        int RY, BY, RYY, GYY, BYY, R, G, B, Y;

        for (int y = 0; y < h; y++) {
            for (int x = 0; x < w; x++) {
                index = y * w + x;
                r = (pix[index] >> 16) & 0xff;
                g = (pix[index] >> 8) & 0xff;
                b = pix[index] & 0xff;
                RY = (70 * r - 59 * g - 11 * b) / 100;
                BY = (-30 * r - 59 * g + 89 * b) / 100;
                Y = (30 * r + 59 * g + 11 * b) / 100;
                RYY = (S * BY + C * RY) / 256;
                BYY = (C * BY - S * RY) / 256;
                GYY = (-51 * RYY - 19 * BYY) / 100;
                R = Y + RYY;
                R = (R < 0) ? 0 : ((R > 255) ? 255 : R);
                G = Y + GYY;
                G = (G < 0) ? 0 : ((G > 255) ? 255 : G);
                B = Y + BYY;
                B = (B < 0) ? 0 : ((B > 255) ? 255 : B);
                pix[index] = 0xff000000 | (R << 16) | (G << 8) | B;
            }
        }

        Bitmap bm = Bitmap.createBitmap(w, h, defaultBitmap.getConfig());
        bm.setPixels(pix, 0, w, 0, 0, w, h);

        pix = null;
        return bm;
     }
     }

Usage: Process Indigo color: TintThePicture(180, myBitmap); Process Green color: TintThePicture(300, myBitmap);

  1. Use android.media.effect is provided in API14

  2. Effect Pro

  3. Android-Image-Edit

  4. android-image-editor

  5. smartcrop-android (This library will analyze best crop position and size by calculating some features; edge, skin tone, staturation and face.)