package img_combine.img_combine;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.os.Bundle;
import android.widget.ImageView;
public class MainActivity extends Activity {
private ImageView imageView;
Bitmap me1 = null;
Bitmap me2 = null;
Bitmap result1 = null;
Bitmap result2 = null;
Bitmap bitmap = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
me1 = BitmapFactory.decodeResource(getResources(), R.drawable.kiyeuk);
me2 = BitmapFactory.decodeResource(getResources(), R.drawable.ah);
result1 = combineImage(me1, me2, false);
result2 = combineImage(result1, me1, false);
imageView = (ImageView)findViewById(R.id.image);
imageView.setImageBitmap(result2);
}
private Bitmap combineImage(Bitmap me1, Bitmap me2, boolean isVerticalMode){
BitmapFactory.Options option = new BitmapFactory.Options();
option.inDither = true;
option.inPurgeable = true;
if(isVerticalMode)
bitmap = Bitmap.createScaledBitmap(me1, me1.getWidth(), me1.getHeight()+me2.getHeight(), true);
else
bitmap = Bitmap.createScaledBitmap(me1, me1.getWidth()+me2.getWidth(), me1.getHeight(), true);
Paint p = new Paint();
p.setDither(true);
p.setFlags(Paint.ANTI_ALIAS_FLAG);
Canvas c = new Canvas(bitmap);
c.drawBitmap(me1, 0, 0, p);
if(isVerticalMode)
c.drawBitmap(me2, 0, me1.getHeight(), p);
else
c.drawBitmap(me2, me1.getWidth(), 0, p);
me1.recycle();
me2.recycle();
return bitmap;
}
}
위의 소스로 이미지를 합성하여
두 개의 이미지 me1, me2 를 합성하였고 그 결과를 result1 라고 하였습니다
이 result1를 다시 me1와 합성하려고 하니 어플이 강제종료가 되어버렸습니다.
합성된 이미지를 안드로이드 내에 저장하였다가 다시 불러서 합성소스에 넣어야 하는건가요?
왜 오류가 나는 것인지 알고싶습니다.