'화면캡쳐'에 해당되는 글 1건

  1. 2010.08.14 [Android] 화면 캡쳐하기 (1)
posted by By훈트 2010.08.14 17:40
public class ScreenCapture extends Activity {
LinearLayout view;

@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

view = (LinearLayout) findViewById(R.id.screen);
Button myBtn = (Button) findViewById(R.id.myBtn);

myBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
View v1 = view.getRootView();
System.out.println("Root View : " + v1);
v1.setDrawingCacheEnabled(true);
Bitmap bm = v1.getDrawingCache();

System.out.println("Bitmap : " + bm);
saveScreen(bm);
}
});

}

public void saveScreen(Bitmap bm) {
try {
FileOutputStream out = new FileOutputStream(filename);
bmp.compress(Bitmap.CompressFormat.PNG, 90, out);
} catch (Exception e) {
e.printStackTrace();
}
}
}



신고
크리에이티브 커먼즈 라이선스
Creative Commons License

티스토리 툴바