내용을 저장하고 싶은 bitmapView라는 녀석이 있습니다
bitmapView.setBackgroundColor(Color.TRANSPARENT);
bitmapView.setDrawingCacheBackgroundColor(Color.TRANSPARENT);
bitmapView.setDrawingCacheEnabled(true);
// this is the important code :)
// Without it the view will have a dimension of 0,0 and the bitmap will be null
bitmapView.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED),
View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
bitmapView.layout(0, 0, bitmapView.getMeasuredWidth(), bitmapView.getMeasuredHeight());
bitmapView.buildDrawingCache(true);
Bitmap returnBitmap = Bitmap.createBitmap(bitmapView.getDrawingCache());
위와 같은 과정을 통해서 결과returnBitmap을 얻어냈습니다
그래서 이제 이걸 png 로 저장한 뒤에 카톡이나 페이스북 등으로 공유하기를 사용하려고 하는데요
저장된 파일들을 보면 뒤에 배경이 검은색입니다. png로 저장했는데도 마찬가진데요
File fileCacheItem = new File(strFilePath);
OutputStream out = null;
try {
fileCacheItem.createNewFile();
out = new FileOutputStream(fileCacheItem);
bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
이렇게 저장하는데요 jpg도 아니고 png면 배경이 투명하길 기대하는데
전혀 그렇지 않네요. 다른 방식을 사용해야하는지 bitmap create할때 Bitmap.Config.ARGB_8888
이런 옵션이 있으면 된다고 했는데 getdrawcache 할때 이미 bitmap이 생성되었기 때문에
건드릴 수가 없네요