My shipping application is written in GWT and uses HTML5 Canvas object and getContext2d() method to use context2d image manipulation methods to calculate RGB values and display them using context.drawImage() method on the screen. I can easily accomplish many refreshes per second this way. Here's an example of some of the GWT objects I use:
ImageData m_Image;
Canvas m_OffscreenCanvas;
CanvasElement m_OffscreenCanvasElement;
void ManipulateAndDrawImage( Context2d context, int columns, int rows )
{
m_Image = context.createImageData(columns,rows) ;
CanvasPixelArray pixels = m_Image.getData();
for( int r=0; r<rows; r++ )
for( int c=0; c<columns; c++ )
{
RGB rgb = calculatePixelRGB( r, c );
int linearIndex = r*columns+c;
pixels.set( linearIndex+0, rgb.red );
pixels.set( linearIndex+1, rgb.green );
pixels.set( linearIndex+2, rgb.blue );
pixels.set( linearIndex+3,255 ); /* alpha at full opacity */
}
m_OffscreenCanvas = Canvas.createIfSupported();
m_OffscreenCanvasElement = m_OffscreenCanvas.getCanvasElement();
m_OffscreenCanvasElement.setWidth(columns);
m_OffscreenCanvasElement.setHeight(rows);
m_OffscreenCanvasElement.getContext2d().putImageData( m_Image, 0, 0 );
context.drawImage( m_OffscreenCanvasElement, 0,0,columns, rows );
}
Now I'm porting to Smartgwt and looking for what to use to accomplish same functionality there. So far, much of my other requirements have been satisfied by using DrawPane and associated DrawItems. I expected to be able to accomplish the above with DrawImage object, however now that I've gotten there, I see it only allows setting an image URL and no means to access contents of image matrix of pixels.
Any suggestions or pointers towards other ways to accomplish this will be greatly appreciated, and if nothing comes to mind, then any comments about how I might find a way to integrate the GWT implementation together with the Smartgwt everything-else would also be greatly appreciated. I understand not to mix the two, generally, but technically, is it possible?
Thank you.
Jim Waschura
ImageData m_Image;
Canvas m_OffscreenCanvas;
CanvasElement m_OffscreenCanvasElement;
void ManipulateAndDrawImage( Context2d context, int columns, int rows )
{
m_Image = context.createImageData(columns,rows) ;
CanvasPixelArray pixels = m_Image.getData();
for( int r=0; r<rows; r++ )
for( int c=0; c<columns; c++ )
{
RGB rgb = calculatePixelRGB( r, c );
int linearIndex = r*columns+c;
pixels.set( linearIndex+0, rgb.red );
pixels.set( linearIndex+1, rgb.green );
pixels.set( linearIndex+2, rgb.blue );
pixels.set( linearIndex+3,255 ); /* alpha at full opacity */
}
m_OffscreenCanvas = Canvas.createIfSupported();
m_OffscreenCanvasElement = m_OffscreenCanvas.getCanvasElement();
m_OffscreenCanvasElement.setWidth(columns);
m_OffscreenCanvasElement.setHeight(rows);
m_OffscreenCanvasElement.getContext2d().putImageData( m_Image, 0, 0 );
context.drawImage( m_OffscreenCanvasElement, 0,0,columns, rows );
}
Now I'm porting to Smartgwt and looking for what to use to accomplish same functionality there. So far, much of my other requirements have been satisfied by using DrawPane and associated DrawItems. I expected to be able to accomplish the above with DrawImage object, however now that I've gotten there, I see it only allows setting an image URL and no means to access contents of image matrix of pixels.
Any suggestions or pointers towards other ways to accomplish this will be greatly appreciated, and if nothing comes to mind, then any comments about how I might find a way to integrate the GWT implementation together with the Smartgwt everything-else would also be greatly appreciated. I understand not to mix the two, generally, but technically, is it possible?
Thank you.
Jim Waschura
Comment