Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
tnylee opened this issue Jan 2, 2019 · 6 comments
Open

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

tnylee opened this issue Jan 2, 2019 · 6 comments

Comments

@tnylee
Copy link

tnylee commented Jan 2, 2019

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?

@aurasphere
Copy link

Same problem here

@ByoxCode
Copy link
Owner

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

@aurasphere
Copy link

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)
}

@ArronSingh
Copy link

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

@MFam
Copy link

MFam commented Apr 20, 2020

I have a solution.

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

@salario07
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants