이미지 위에 페인팅을 하고 나서 변경된 이미지를 저장하려고 하는데요..
저장을 하고 나면 원본 이미지만 그대로 저장이 되더라고요...
변경된 이미지를 저장하고 싶은데 어떻게 해야 하는가를 모르겠습니다.
createBitmap을 하고 나서 단순 Canvas로 그 위에서 색칠만 하고 실질적으로는 반영이
되질 않는것 같습니다.
도움을 요청합니다.... 아래에는 부분 소스코드 입니다..
전체 소스 코드는 파일로 첨부했습니다.
--------------------------------------------------------------------
<비트맵 생성부분>
public class MyView extends View {
private static final float MINP = 0.25f;
private static final float MAXP = 0.75f;
//private Bitmap mBitmap;
private Canvas mCanvas;
private Path mPath;
private Paint mBitmapPaint;
public MyView(Context c) {
super(c);
Bitmap bmp = null;
Resources res;
res = getResources();
Intent parent_Intent = getIntent();
uriTarget = parent_Intent.getData();
/*
bmp = Media.getBitmap(getContentResolver(), uriTarget);
String sPath = uriTarget.getPath();
String sNum = sPath.substring(sPath.lastIndexOf("/") + 1);
String sFileName = sNum + ".jpg";
bmp = BitmapFactory.decodeFile(sPath);
*/
try
{
bmp = Images.Media.getBitmap(getContentResolver(), uriTarget);
mBitmap = Bitmap.createBitmap(bmp);
}catch (FileNotFoundException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
// mBitmap = Bitmap.createBitmap(320, 480, Bitmap.Config.ARGB_8888);
mCanvas = new Canvas();
mPath = new Path();
mBitmapPaint = new Paint(Paint.DITHER_FLAG);
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
}
@Override
protected void onDraw(Canvas canvas) {
//canvas.drawColor(0xFFAAAAAA);
canvas.drawBitmap(mBitmap, 0, 0, mBitmapPaint);
canvas.drawPath(mPath, mPaint);
}
<저장하는 함수 부분>
public static void writeBitmap( Bitmap bitmap, String saveName, int page )
{
//File f = new File( "sdcard" + "/" + saveName + ".png");
//File f = new File( "/sdcard" + "/" + saveName + ".png");
File f = new File( "/sdcard/gil.PNG");
//File f = new File( DEFAULT_SAVE + "/" + saveName + ".png");
FileOutputStream out = null;
try
{
out = new FileOutputStream(f);
bitmap.compress(CompressFormat.PNG, 80, out);
}catch (Exception e)
{
// TODO Auto-generated catch block
// e.printStackTrace();
}finally
{
try
{
out.close();
}catch ( Exception e)
{}
}
}