setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
위 타입의 영상 스트리밍 SurfaceView 가 있는데요
SurfaceView sv = (SurfaceView)findViewById(R.id.surface);
Bitmap blank = Bitmap.createBitmap(800, 480, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(blank);
sv.draw(canvas);
capture(blank);
public void capture(Bitmap source) {
try {
Matrix mat = new Matrix();
mat.postRotate(90);
Bitmap bitmap = Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(), mat, true);
File file = new File(Environment.getExternalStorageDirectory() + "/test.jpg");
Log.d("jpegCallback-----------", file.getAbsolutePath() + " " + file.isFile());
FileOutputStream fos;
fos = new FileOutputStream(file);
bitmap.compress(CompressFormat.JPEG, 70, fos);
fos.close();
} catch (IOException e) {
e.printStackTrace();
}
}위와같은 소스인데요, 비슷한 질문글은 많은데 제대로 답변이 달린 글이 없네요..
현재 뿌려주고있는 SurfaceView 화면을 Bitmap으로 저장하는건데
제대로 가져오지못하고 까만그림만 저장되네요
혹시 아시는분 있으면 조언부탁드립니다
저도 view를 캡처해서 저장이 되었는데 검은 화면만 저장이 되어서요..
View v1=mGlView.getRootView();//확인 버튼만 나옴
//View v1=mGlView; //검은 화면 만 나옴
v1.setDrawingCacheEnabled(true);
Bitmap bm = v1.getDrawingCache();
screenshot(bm);
screenshot을 호출하고 그 호출한 곳에서
FileOutputStream out = new FileOutputStream("sdcard/Gung/"+"a.jpeg");
ImageView i;
$bm.compress(CompressFormat.JPEG, 100, out);
Log.e("", "bm.compress(Bitmap.CompressFormat.JPEG, 100, out);");
sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED,
Uri.parse("file://" + Environment.getExternalStorageDirectory())));
Log.e("", "미디어 스캐닝");
이렇게 했는데 검은 화면이 됩니다..ㅜㅜ




이거 질문찾아보면 아무도 해결못한거같지만...지난달에 해냈습니다...
원리만 간단히 말씀드리면 한번에 저장못합니다.
surfaceview는 가상 메모리버퍼로 화면을 전달하기때문에 캡쳐하여도 검게 나오는데
imageview를 하나 새로 생상하면서 surfaceview의 내용을 bitmap으로 전환하여 출력한후 surfaceview를 죽여버리시고
캡쳐를 이용하여 저장하는 방법이 있습니다
자세한거 궁금하시면 쪽지보내주세요 지금 회사라서 자료가 없네요 ㅠㅠ