5

私が欲しいのは、テキストが画像の上に指で触れて移動していることです。ボタンをクリックすると、既存の画像が新しい画像に再描画され、テキストが貼り付けられます。

v3.1 だけでなくエミュレーターでも問題なく動作します。しかし、v2.2 デバイスでテストしようとしましたが、Forse Close が発生します。デバイスはすべてサポートされていますが、ここから抜け出すのを手伝ってもらえますか。数週間後に重要になります。よろしくお願いします。

///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);
}
4

1 に答える 1

0

テキストが描画される前にタッチするとすぐに、アプリの起動直後など、強制終了がいつ発生するかを知るのに役立ちますか?

デバイス上でのデバッグ
非常に簡単で完全に証明された手法は、実際のデバイス上でコードをデバッグ モードで実行することです。関数の先頭にブレークポイントを追加し、強制終了するまで各行をステップ オーバーします。

おそらく OOM
タッチ中のすべてのフレームのように redrawImage を繰り返し呼び出している場合、新しいビットマップの割り当てによって大量のメモリが急速に消費され、クラッシュが発生する可能性があります。

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

その後、少し後に強制終了が発生する可能性があります。bm を、一度割り当てられてファイルから読み取られるメソッド パラメーターまたはメンバー フィールドに変更してみてください。

于 2013-08-18T16:22:53.580 に答える