nvd_ai
unread,Jan 10, 2011, 6:08:40 AM1/10/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to PaintWeb discussions
Hi all,
I am having a problem to initialize paintweb while resizing an image.
here is the story:
//instantiate paintweb
var pw = new PaintWeb();
pw.config.guiPlaceholder = PWContainer;
pw.config.configFile = 'config-pw.json';
//set the default image
var pwImg = document.createElement("img");
pwImg.src = imageNode.src; //imageNode is an existing image in my
program
//non-working implementation! the image gets cropped instead of
resizing
/*pwImg.onload=function(){
pwImg.width = w;
pwImg.height = h;
}*/
pw.config.imageLoad = pwImg;
The problem is that imageNode is an image with {width:50,height=50}.
But I want that when paintWeb starts, it resizes the image to
{width:w,height:h}, which h and w are variables defined in my
program.
What happens now is that if I set the width and height of pwImg to w
and h, instead of resizing the image, it gets cropped! I tried few
different implementations, such as the one commented in the code
above, but none of them work.
I tried to find some API that resizes the canvas (not cropping). But
could not get it to work.
What's the right implementation?
Thanks,