2012-06-08 15 views
5

我想要什么,文本正在被移动以与手指触摸在图像上,点击按钮重绘现有的图像转换成一个新的这是贴在它的文本。移动文本和重绘影像设备发出

它工作得很好V3.1以及对模拟器。 但我试图V2.2设备上测试时它对于Devices.Can大家帮我出here.Its的会是在几个关键weeks.Thanks事先都支持ForSE召开前夕Close.While。

///Redrawing the image & touchin Move of the Canvas with text 
public void redrawImage(String path,float sizeValue,String textValue,int colorValue) { 
     BitmapFactory.Options options = new BitmapFactory.Options(); 
     try { 
      options.inMutable = true; 
     } catch (Exception e) { 
      // TODO: handle exception 
      System.out.println("#############Error is======"+e.getMessage()); 
     } 

     Bitmap bm = BitmapFactory.decodeFile(path,options); 

     proxy = Bitmap.createBitmap(bm.getWidth(), bm.getHeight(), Config.ARGB_8888); 
     Canvas c = new Canvas(proxy); 

     //Here, we draw the background image. 
     c.drawBitmap(bm, new Matrix(), null); 

     Paint paint = new Paint(); 
     paint.setColor(colorValue); // Text Color 
     paint.setStrokeWidth(30); // Text Size 
     paint.setTextSize(sizeValue); 

     System.out.println("Values passing=========="+someGlobalXvariable+", "+someGlobalYvariable+", " 
             +sizeValue+", "+textValue); 

     //Here, we draw the text where the user last touched. 
     c.drawText(textValue, someGlobalXvariable, someGlobalYvariable, paint); 

     popImgae.setImageBitmap(proxy); 
} 
+0

您可以发布从logcat的错误日志? – Zelleriation

+1

options.inMutable = true;支持从以下版本开始:API级别11,并且不需要将位图bm加载为可变。只有位图代理应该是可变的 –

回答

0

这将有助于了解当力闭合情况,像右边的应用程序启动后,只要您触摸文本曾经吸引过吗?

调试设备
甲很容易和fullproof技术上是运行在实际设备上在调试模式下的代码。在函数的开始处添加一个断点,并逐步遍历每一行,直到强制关闭。

可能OOM
如果你在触摸时一边喊redrawImage,像每一个帧,然后分配一个新的位图可以快速地吃了很多的内存并导致崩溃:

Bitmap bm = BitmapFactory.decodeFile(path,options); 

然后关闭的力量可能会在一段时间后发生。尝试将bm更改为一次分​​配并从文件读取的方法参数或成员字段。