Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Contributor
Posts: 33
Registered: ‎01-17-2013
My Device: BB10 Dev Alpha Sim
My Carrier: Verizon

Re: toDataURL("image/jpeg") Producing distorted images

[ Edited ]

Ok, here is the code i am using:

 

(i am using enyo 2, but it is just a wrapper around a normal canvas)

 

 var img = new Image();
var can = this.$.canvasOrig.hasNode();
		img.onload = enyo.bind(this, function() {
			if (can) {
				var ratio = [600 / img.width, 600 / img.height ];
			    ratio = Math.min(ratio[0], ratio[1]);
			    var w = img.width * ratio;
			    var h = img.height * ratio;
			    
				can.width = w;
				can.height = h;
				var c = can.getContext('2d');
				c.drawImage(img,0 ,0 ,w,h);
				this.photos[index-1].origsrc=can.toDataURL("image/jpeg", 0.8);
				this.photos[index-1].src=this.photos[index-1].origSrc;
				this.$.photoPost.hide();
				this.$.cropPic.setSrc(this.photos[index-1].origSrc);
				
				
			}
		});
		img.src=this.photos[index-1].origSrc;

 

This worked on 10.2 fine, but on 10.1 and 10.2.1 i am getting the same results.

 

I have a free demo version of my app up that is using this code.

http://appworld.blackberry.com/webstore/content/24375878

 

If you (or anyone) with a production device updated to 10.2.1 could try it out.

You do need a tumblr account. Just sign into your dashboard, click the menu button in the bottom right corner and select "Post", and try to post a picture.

If it looks normal with no distortion, then I shouldn't have any problems.

 

Thanks,

Chris.

Contributor
Posts: 33
Registered: ‎01-17-2013
My Device: BB10 Dev Alpha Sim
My Carrier: Verizon

Re: toDataURL("image/jpeg") Producing distorted images

Can anyone verify this for me on a production device?

 

Thanks

BlackBerry Development Advisor
Posts: 762
Registered: ‎10-01-2009
My Device: All
My Carrier: N/A

Re: toDataURL("image/jpeg") Producing distorted images

Works great for me, the photo looks fine.

 

 

Contributor
Posts: 33
Registered: ‎01-17-2013
My Device: BB10 Dev Alpha Sim
My Carrier: Verizon

Re: toDataURL("image/jpeg") Producing distorted images

Cool, thats great!

 

Hopefully I don't have an issue here anymore.