mBitmap = Bitmap.createBitmap(480, 800, Bitmap.Config.ARGB_8888);
위에 처럼 비트맵 변수에 로드한것 혹은 크리에이트 한걸 저장한후에
캔버스로 보내고 그 캔버스를 출력을 하는데요
크리에이트 한것을 출력할땐 잘 나오는데 비트맵 팩토리를 사용해서 불러온 파일을 배경으로 깔떄는 죽어 버리네요 혹시 이유가 있나요?
소스가..
public class FingerPaint extends GraphicsActivity
implements ColorPickerDialog.OnColorChangedListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(new MyView(this));
mPaint = new Paint();
mPaint.setAntiAlias(true);
mPaint.setDither(true);
mPaint.setColor(0xFFFF0000);
mPaint.setStyle(Paint.Style.STROKE);
mPaint.setStrokeJoin(Paint.Join.ROUND);
mPaint.setStrokeCap(Paint.Cap.ROUND);
mPaint.setStrokeWidth(12);
mEmboss = new EmbossMaskFilter(new float[] { 1, 1, 1 },
0.4f, 6, 3.5f);
mBlur = new BlurMaskFilter(8, BlurMaskFilter.Blur.NORMAL);
}
private Paint mPaint;
private MaskFilter mEmboss;
private MaskFilter mBlur;
public void colorChanged(int color) {
mPaint.setColor(color);
}
public class MyView extends View {
private static final float MINP = 0.25f;
private static final float MAXP = 0.75f;
private Bitmap mBitmap,mImgBack;
private Drawable BackGround;
private Canvas mCanvas;
private Path mPath;
private Paint mBitmapPaint;
public MyView(Context c) {
super(c);
Resources res = c.getResources();
mImgBack = BitmapFactory.decodeResource(res,R.drawable.dragback);
mBitmap = Bitmap.createBitmap(480, 800, Bitmap.Config.ARGB_8888);
// BackGround = res.getDrawable(R.drawable.dragback);
mCanvas = new Canvas(mImgBack);
mPath = new Path();
mBitmapPaint = new Paint(Paint.DITHER_FLAG);
}
혹시 'res' 가 해당 view 의 resources 객체가 아닌지요?
아니라면 this.getResources() 로 한번..