1

我可以从图像的字节流中更改图像的对比度吗?我已经完成了复制图像的必要工作,并且需要将更改对比度部分添加到代码中。知道怎么做吗?或者甚至有可能吗?

package make.image.bw;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.RandomAccessFile;
import android.app.Activity;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;

public class MakeImageBWActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);                  // set screen view
        String imageInSD      =     Environment.getExternalStorageDirectory().getAbsolutePath() +"/earthglobe.jpg";
        RandomAccessFile file =     null;
        try {
            file = new RandomAccessFile(imageInSD, "r");
        } catch (FileNotFoundException e1) {
            e1.printStackTrace();
        }
        File myFile               =     new File(Environment.getExternalStorageDirectory(), "latestearth.jpg");
        byte[] buffer             =     new byte[1024];
        try {
            FileOutputStream out  =     new FileOutputStream(myFile);
            while(file.read(buffer)!=-1){
                out.write(buffer,0,1024);
            }
             out.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        Log.d("tag", "finished");
        finish();
        }
}

提前感谢您的宝贵建议。

4

1 回答 1

1

您应该尝试查看 Google IO 2012 会议:Doing More With Less: Being a Good Android Citizen

在 22min30 有一个很好的使用 RenderScript 进行图像处理的演示。

演示文稿的代码可以在这里找到

于 2012-07-13T12:04:53.740 回答