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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


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: 769
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.

 

 

Highlighted
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.