2012-07-13 48 views
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(); 
     } 
} 

感谢您提前提出宝贵建议。

回答