wulfsolter / angular2-signaturepad

Angular2 Component for szimek / signature_pad
MIT License
176 stars 157 forks source link

fromDataURL only takes 1/4 of the canvas dimension #35

Closed akz92 closed 7 years ago

akz92 commented 7 years ago

When applying an image using the fromDataURL function, the image doesn't take the entire canvas dimension. To make sure the problem wasn't in my code I used the example project from the README and the problem persisted:

screenshot 2017-06-02 11 59 49
lathonez commented 7 years ago

Thanks Lucas, will let you know when I've had some time to look into this

akz92 commented 7 years ago

I investigated a little further and found that the problem is actually in szimek/signature_pad. The ratio used when calculating the width and height to use in drawImage for some reason is 2 and that causes both width and height to be half of the actual values.

Removing the ratio and using the values of this._canvas.width and this._canvas.height fixed both the issue in my application and in the angular2-signaturepad-demo.

I didn't raise an issue there because I'm not able to test their latest release now, but since this issue isn't from this component I'm closing it.

lathonez commented 7 years ago

Thanks a lot for the update and investigation

alan345 commented 7 years ago

Hello @akz92 ! I am having the same issue and could not solve it. Can you please give us more details regarding the resolution? Where did you remove the Ratio as you said "Removing the ratio"

Thanks for your help I have opened a new issue just in case. https://github.com/wulfsolter/angular2-signaturepad/issues/46

lathonez commented 7 years ago

No need for another issue. Closed #46 as a duplicate of this.

lathonez commented 7 years ago

If there is an issue here at all, it seems to be upstream.

Can't comment further than the excellent summary made by @akz92

akz92 commented 6 years ago

@alan345 I didn't touch this code since I created the issue, so I'm not really sure, but I believe it had to do with these lines from the fromDataURL method:

  var ratio = options.ratio || window.devicePixelRatio || 1;
  var width = options.width || this._canvas.width / ratio;
  var height = options.height || this._canvas.height / ratio;

These are the actual lines I'm using in my app, so if this is where the problem is they should help you :smiley:

alan345 commented 6 years ago

thanks @akz92 !

DexterHaslem commented 6 years ago

@lathonez can you bump signaturepad to 2.3 in deps so ratio is available in options (and other fixes)? See https://github.com/szimek/signature_pad/blob/master/src/signature_pad.js#L101 docs seem outdated

DexterHaslem commented 6 years ago

oh wait, it was actually there in 2.2.0 :( it would be nice to update regardless

lathonez commented 6 years ago

@DexterHaslem - commenting on closed issues is a great way of getting your comments ignored.

https://github.com/wulfsolter/angular2-signaturepad/issues/55

No idea when we'll have time to action this. The repo is FOSS and PRs are accepted.

Cheers

akvaliya commented 5 years ago

I am still facing the same issue in version 2.8.0. Can anyone tell me what is the status of this issue.

Why is it closed? Issue is still exist.

akvaliya commented 5 years ago

This should be reopened