DrawView icon indicating copy to clipboard operation
DrawView copied to clipboard

java.lang.IllegalArgumentException: width and height must be > 0

Open tnylee opened this issue 6 years ago • 6 comments

Thank you for such an awesome library! Its helping me. However, an error occured while using it and I'd like to know if you can help me. Thanks!

java.lang.IllegalArgumentException: width and height must be > 0

Crashes on line drawingView.setBackgroundImage(editingImage, BackgroundType.FILE, BackgroundScale.CENTER_INSIDE);

If removed, no error occurs.

My XML:

<com.byox.drawview.views.DrawView
            android:id="@+id/drawingView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:dv_draw_corners="round"
            app:dv_draw_tool="pen"
            app:dv_draw_enable_zoom="true"
            app:dv_draw_max_zoom_factor="15"
            app:dv_draw_alpha="255"
            app:dv_draw_width="10"/>

configuration code:

drawingView = (DrawView) findViewById(R.id.drawingView);
drawingView.setBackgroundImage(editingImage, BackgroundType.FILE, BackgroundScale.CENTER_CROP);
drawingView.setDrawColor(getResources().getColor(R.color.colorPickerDefault))
                .setZoomEnabled(true)
                .setMaxZoomFactor(15)
                .setDrawAlpha(255)
                .setDrawWidth(maxPenSize);
drawingView.setBackgroundImage(editingImage, BackgroundType.FILE, BackgroundScale.CENTER_INSIDE);

What am I doing wrong?

tnylee avatar Jan 02 '19 08:01 tnylee

Same problem here

aurasphere avatar Mar 01 '19 18:03 aurasphere

I recently update snapshot version, please use it and tell me if the problem persists

ByoxCode avatar Aug 10 '19 02:08 ByoxCode

Tried with the 1.0.2. The error is gone but the background image is not set. This is my code (Kotlin):

override fun onCreate(savedInstanceState: Bundle?) {
  super.onCreate(savedInstanceState)
  setContentView(R.layout.activity_edit_picture)

  val imagePath = intent.getStringExtra("imagePath")
  edit_picture_view.backgroundImage(File(imagePath), BackgroundType.FILE, BackgroundScale.CENTER_INSIDE, 50)
}

aurasphere avatar Sep 14 '19 17:09 aurasphere

Hi,

Just an fyi the same error manifests on line with code: "mZoomRegionView.drawZoomRegion(mContentBitmap, mCanvasClipBounds, 4);"

  • in class Drawview.java when using an Android Device with OS 10. (Works fine on previous OS devices).

If you add a delay there is no error and it prevents the crash: new Handler().postDelayed(new Runnable() { @Override public void run() { mZoomRegionView.drawZoomRegion(mContentBitmap, mCanvasClipBounds, 4); } }, 1000);

Could you add this to the next version please?

Best wishes,

Arron

ArronSingh avatar Sep 25 '19 16:09 ArronSingh

I have a solution.

drawingView.post { drawingView.setBackgroundImage(File(uri.path), BackgroundType.FILE, BackgroundScale.CENTER_INSIDE) }

MFam avatar Apr 20 '20 10:04 MFam

thanks to byox great project, I cloned the project and fixed this bug. feel free to use it. implementation 'com.github.salario07:DrawView:1.0.4'

also see latest version from here: https://jitpack.io/#salario07/DrawView

salario07 avatar Dec 21 '20 08:12 salario07