问题描述
- android canvas保存为图片在手机中打开是一片黑色
-
//保存
public void save()
{File sd=Environment.getExternalStorageDirectory(); String path=sd.getPath()+"/paint"; File file=new File(path); file.mkdir(); Bitmap bm = Bitmap.createBitmap(480, 800, Config.ARGB_8888); Canvas canvas = new Canvas(bm); Paint p = new Paint(); canvas.drawRect(50, 50, 200, 200, p); canvas.save(Canvas.ALL_SAVE_FLAG ); canvas.restore(); String fileName = path+"19961234.jpg"; FileOutputStream fos = null; try { fos = new FileOutputStream(fileName); bm.compress(Bitmap.CompressFormat.PNG, 100, fos); fos.flush(); fos.close(); } catch (FileNotFoundException e) { } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
解决方案
解决方案二:
怎么回事啊? 谁来帮帮我
时间: 2024-12-02 18:04:49