1
在我的android應用程序中,我將繪圖保存爲image.I能夠保存文件,但不能完全保存100%,即某些內容缺少空格即將到來。該函數在下面是我通過onclick調用。請幫我如何保存完美繪圖 的屏幕截圖請訪問以下鏈接: http://www.flickr.com/photos/[email protected]/7066979339, http://www.flickr.com/photos/[email protected]/7066979341如何將畫布繪製保存爲圖像?
DigitalSignatureActivity.java
private DrawingSurface drawingSurface;
// To save file as Image
public void saveDrawing(View v) throws IOException {
File mediaStorageDir = new File(
Environment
.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES),
"MySignatures");
Bitmap nBitmap = drawingSurface.getBitmap();
try {
if (!mediaStorageDir.exists()) {
mediaStorageDir.mkdirs();
}
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss")
.format(new Date());
File mediaFile = new File(mediaStorageDir.getPath()
+ File.separator + "SIGN_" + timeStamp + ".png");
FileOutputStream out = new FileOutputStream(mediaFile);
nBitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
out.flush();
out.close();
Toast.makeText(this, "Signature saved to " + mediaFile,
Toast.LENGTH_LONG).show();
} catch (Exception e) {
e.printStackTrace();
Toast.makeText(getApplicationContext(), "Not saved",
Toast.LENGTH_SHORT).show();
}
}
DrawingSurface.java
public class DrawingSurface extends SurfaceView implements SurfaceHolder.Callback {
//some code
}
你是什麼意思「有些內容缺少空格即將到來」?你可以發佈一個屏幕? – waqaslam 2012-04-11 07:03:38
@Waqas請訪問follwing鏈接的屏幕:http://www.flickr.com/photos/[email protected]/7066979339, http://www.flickr.com/photos/[email protected]/7066979341 – 2012-04-11 07:27:21