Android图像编辑器

时间:2012-11-14 06:10:01

标签: android image-editor

我想创建一个Android应用程序,我可以从SD卡或相机拍照。拍摄照片后,我必须对其进行编辑,例如在图片中添加文字,裁剪图片,将.gif类型文件添加到图片中。拍照不是问题,但我无法理解如何编写代码来编辑图片。我需要知道是否必须使用OpenGL。想要的建议和有用的链接。

2 个答案:

答案 0 :(得分:55)

你的问题太模糊了。我提供了一些指导。

  1. 现在使用Aviary SDK成为Creative SDK。它还支持iOS和WindowPhone7。 Aviary提供大部分功能,如方向,裁剪和清晰度,红眼,美白和瑕疵,贴纸,绘图,文本和Meme(测试版),亮度,饱和度和对比度以及自定义选项。 SS
  2. Fotor SDK
  3. Adob​​e的Creative SDK
  4. 直接处理位图。

    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;
    }
    }
    

    用法:处理靛蓝色:TintThePicture(180, myBitmap);    处理绿色:TintThePicture(300, myBitmap);

  5. API14
  6. 中提供了使用android.media.effect
  7. Effect Pro
  8. Android-Image-Edit
  9. android-image-editor
  10. smartcrop-android(此库将通过计算一些特征来分析最佳裁剪位置和大小;边缘,肤色,雕像和面部。)

答案 1 :(得分:0)

首先回答您的问题,不,您不必使用openGL。至于例子,这里有一些开源的例子:

iQuePhoto:https://github.com/iQueSoft/iQuePhoto

LeafPic:https://github.com/HoraApps/LeafPic

相关问题