Re: nsIDOMCanvasRenderingContext2d embedding in 1.9.2 ?

"[email protected]" <[email protected]>
Newsgroups gmane.comp.mozilla.devel.embedding
Organization NovaDSP
Message-ID <[email protected]>
On 08/11/2010 13:45, Benjamin Smedberg wrote:
> This really doesn't make any sense. The way to get a canvas rendering 
> context is to create a <canvas> element and then call 
> .getContext('2d') on it. Otherwise your rendering context isn't 
> actually backed by a drawing buffer.
>
> --BDS

I may well be mistaken :).  The full sequence I've actually coded is 
below. Still not quite sure how to get bitmap data from the context but 
this should associate a canvas with the context?

// create context
nsCOMPtr<nsICanvasRenderingContextInternal> context;
     context = 
do_CreateInstance("@mozilla.org/content/canvas-rendering-context;1?id=2d", 
&rv);
     if (!(NS_SUCCEEDED(rv) && context))
     {
         return 0;
     }

     context->SetDimensions(widthIn,heightIn);
     context->SetCanvasElement(nsnull);

// create canvas
     nsCOMPtr<nsIDOMCanvasRenderingContext2D> canvas;
     canvas = do_QueryInterface(context, &rv);
     if (!(NS_SUCCEEDED(rv) && canvas))
     {
         return 0;
     }

// get canvas to draw
     PRUint32 flags = 0;
     nsString bg(L"rgb(0,0,0)");
     rv = canvas->DrawWindow(domWindow,xIn,yIn,widthIn,heightIn,bg,flags);
     if (!(NS_SUCCEEDED(rv)))
     {
         return 0;
     }
// recover bitmap ...

Thx.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.