保存绘图画布到SD卡 [英] Saving canvas drawing to sd card
问题描述
我米目前正致力于在画布上绘画中,我HV白色彩色背景的画布(是 canvas.drawColor(Color.WHITE); )和卡通漫画的绘制图像,使油漆同一些颜色。问题是,当我去保存画布图像只有一个黑色的屏幕色彩做得到保存既不画布白色背景,也不是绘制图像时,会出现..
我米用这个code保存帆布
I m currently working on canvas drawing in which i hv a canvas with white colored background ( with canvas.drawColor(Color.WHITE);) and a sketched image of cartoons comics that allows to paint with some colors. The problem is that when i go to save the canvas image only a black screen with color done get saved neither the canvas white background nor the sketched image is appeared.. I m using this code for saving canvas
public void saveAsJpg (File f)
{
String fname = f.getAbsolutePath ();
FileOutputStream fos = null;
try
{
fos = new FileOutputStream (f);
mBitmap.compress (CompressFormat.JPEG, 95, fos);
Toast.makeText (getApplicationContext(), "Saved " + fname, Toast.LENGTH_LONG).show ();
}
catch (Throwable ex)
{
Toast.makeText (getApplicationContext(), "Error: " + ex.getMessage (), Toast.LENGTH_LONG).show ();
ex.printStackTrace ();
}
}
请帮忙,,,,
日Thnx提前
Please help,,,, Thnx in advance
推荐答案
结果
我得到了我的画得到保存。我需要在code所做的改变是通过命令来创建位图沿与画布的 mCanvas =新的Canvas(mBitmap); ,它把我的画布背景图像背景..结果
previously我才开始画有默认黑色背景画布。
I got my drawing get saved. The changes i need to made in code is to create a bitmap along-with the canvas by command mCanvas = new Canvas( mBitmap );, which turn my canvas background as the image background..
Previously i had only started to painting the canvas which has black color background by default.
这篇关于保存绘图画布到SD卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!