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

336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.
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();
}
}
}



블로그 이미지

By훈트

,