public static void saveAsImage(int x,int y,int width,int height,String path,CompressFormat compressFormat,int quality) throws FileNotFoundException {
  Bitmap bmp=getPixelsFromBuffer(x,y,width,height);
  try {
    File file=new File(path);
    try {
      file.createNewFile();
    }
 catch (    IOException e1) {
      e1.printStackTrace();
    }
    FileOutputStream fos=new FileOutputStream(file);
    bmp.compress(compressFormat,quality,fos);
    try {
      fos.flush();
    }
 catch (    IOException e) {
      e.printStackTrace();
    }
    try {
      fos.close();
    }
 catch (    IOException e) {
      e.printStackTrace();
    }
  }
 catch (  FileNotFoundException e) {
    throw (e);
  }
}

public static void saveAsImage ( int x , int y , int width , int height , String path , CompressFormat compressFormat , int quality ) throws FileNotFoundException { Bitmap bmp = getPixelsFromBuffer ( x , y , width , height ) ; try { File file = new File ( path ) ; try { file . createNewFile ( ) ; } catch ( IOException e1 ) { e1 . printStackTrace ( ) ; } FileOutputStream fos = new FileOutputStream ( file ) ; bmp . compress ( compressFormat , quality , fos ) ; try { fos . flush ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } try { fos . close ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } catch ( FileNotFoundException e ) { throw ( e ) ; } }
saves the pixels from the buffer on the sd card .
