안녕하세요. CaptureActivity에서 그려진 customview인 dView를 다른 액티비티에게 화면을 넘길때 dView에 그려진 것을 비트맵에 저장하고 넘기고 싶습니다. 하지만 뻘짓을 다했지만 비트맵의 객체는 계속 null입니다.
어떤것이 문제인지 모르겠습니다. 고수님들의 조언을 듣고싶습니다.
public class CaptureActivity extends Activity {
private static final String TAG = null;
//이미지뷰에 꼭지점에 좌표를 넣기 위해
int imageLeft;
int imageRight;
int imageBottom;
int imageTop;
LayoutInflater controlInflater = null;
DrawView mDraw;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_capture);
image1 = (ImageView) findViewById(R.id.backimage);
//image2 = (ImageView) findViewById(R.id.dView);
Bundle b = getIntent().getExtras();
photo = BitmapFactory.decodeFile(b.getString("path"));
image1.setImageBitmap(photo);
mFrameLayout = (RelativeLayout) findViewById(R.id.frame);
Button crop = (Button) findViewById(R.id.crop);
crop.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.d("리소스값", ""+bit);
Log.d("리소스값", ""+mDraw.getResources());
Log.d("id 값", ""+R.id.cropImage);
if(bit !=null) {
Intent intent = new Intent(getBaseContext(), ClipActivity.class);
intent.putExtra("Bitmap", bit);
startActivity(intent);
}
}
});
}
public void onWindowFocusChanged(boolean hasFocus) {
if(mDraw == null) {
mDraw = new DrawView(this);
mFrameLayout.addView(mDraw);
}
else{
mFrameLayout.setDrawingCacheEnabled(true);
mFrameLayout.buildDrawingCache();
bit =BitmapFactory.decodeResource(mFrameLayout.getResources(), R.id.backimage) ;
}
}
}
----------------------------------------------------------
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RelativeLayout
android:id="@+id/frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="80dp" >
<ImageView
android:id="@+id/backimage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY" />
<com.slee.customview.DrawView
android:id="@+id/dView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY" />
</RelativeLayout>
</RelativeLayout>
----------------------------------------------------------------------------
고수님의 조언을 듣고싶습니다.
if(mDraw == null) {
mDraw = new DrawView(this);
mFrameLayout.addView(mDraw);
}
else{
mFrameLayout.setDrawingCacheEnabled(true);
mFrameLayout.buildDrawingCache();
-----> bit =BitmapFactory.decodeResource(mFrameLayout.getResources(), R.id.backimage) ;
}
로그를 다찍어 보았지만 여기서 값이 들어가지 않는걸 알았습니다.
혹시 제가 멀 빠뜨리고 있는건가여? 다음액티비티에서 넘어온 비트맵을 가지고 작업을 하고 싶은데 지금 이것으로 3일을 허비하게 되었네요.
고수님의 조언을 진심으로 부탁드립니다.