2012-11-14 142 views
23

我想创建一个Android应用程序在那里我可以从SD卡,或从相机拍摄照片。拍摄照片后,我来编辑它,就像图片中添加文本,对照片进行裁切,.GIF类型的文件添加到图片。拍照不是问题,但我无法理解如何编写代码来编辑图片。我需要知道我是否必须为此使用OpenGL。建议和有用的链接通缉。Android的图像编辑器

+0

你是否能找到任何其他类型的开放源码的例子吗? –

回答

52

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

  1. 使用Aviary SDK现在变成Creative SDK。它还支持iOS和WindowPhone7。百鸟提供了大部分的功能,如方向,作物和清晰度,红眼,美白,淡斑和,贴纸,绘图,文字,和模因(测试版),亮度,饱和度和对比度和自定义选项。 SS
  2. Fotor SDK
  3. Creative SDK由Adobe
  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. 使用android.media.effect在API14
  6. Effect Pro
  7. Android-Image-Edit
  8. android-image-editor
  9. smartcrop-android提供(该库将全日空通过计算某些特征来解析最佳作物位置和大小;边缘,肤色,staturation和脸。)
+0

真正惊人的答案。谢谢 –

+0

我下载了android-image-edit,它不起作用。错误是:Android需要编译器合规性级别5.0或6.0。取而代之的是“1.7”。请使用Android工具>修复项目属性。 – MMakati

+1

android-> proerties->的Java compiler_.check使项目setti ....选择1.6 @MMakati – MGDroid