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
Highlighted
New Contributor
Posts: 5
Registered: ‎10-16-2012
My Device: z
My Carrier: HamRadio

Problem : JavaScript & Canvas cannot process Large Images [ > 2048pixels].

Hello,

 

I am using JavaScript & Canvas to create grayscale images.

 

I am currently having problem processing image data with dimension(s), Width or Height, greater than 2048pixels; 2048pixels is OK, 2050pixel is Not Ok.

 

3.1megapixel: 2048x1536 is fine.

 

5 megapixel: 2592 × 1944 will only get partially processed;any pixels beyond 2048 is not processed

 

I tested my codes with png, jpeg

 

The Codes tested fine on desktop’s browsers and in Ripple but NOT on DevAlpha A.

 Is there something I am overlooking?  Is it the code or something I have to put in the config.xml file.

 

 

      ......
// Assume that the canvas has the same W,H as the input image

context.drawImage(myImage,0,0,w,h);
pixels=context.getImageData(0,0,w,h); pData=pixels.data; dlength=pData.length; // dlength= 4*w*h
for (i=0; i < dlength; i += 4) {
grayscale = pData[i] * Ca + pData[i+1] * Cb + pData[i+2] * Cd;
pData[i] = grayscale; // red pData[i+1] = grayscale; // green pData[i+2] = grayscale; // blue
} context.putImageData(pixels,0,0);

 

 

Please Help.

 

Regards, Tek,

De1
New Contributor
Posts: 5
Registered: ‎12-23-2012
My Device: 9860

Re: Problem : JavaScript & Canvas cannot process Large Images [ > 2048pixels].

There seems to be a limit to the dimensions of a canvas to 2048. I have encountered similar problems where I am unable to drawImage to a canvas with any dimension greater than 2048 (though I have only tried on os6 and os7).