[Date Prev][Date Next][Thread Prev][Thread Next][Thread Index]

Re: [XaraXtreme-dev] Cairo Port



Alex Bligh schrieb:
Also, the code above must certainly be able to get at the image buffer
contents somehow in order to be able to actually display them. But I'm
not sure how that happens.

The image buffer is allocated (and, I believe, blanked) in the application.
For extra bonus confusion value the bitmap bit itself needs to be in
windows DIB format. Given that it's (almost) exclusively used in 32 bit
mode these days, this is simply one 32-bit word per pixel, and row
alignment etc. aren't a problem, so we are merely talking byte ordering and "where T goes" considerations.

Well, I have added code to the GDraw_SetDIBitmap function, which I think should be the place to set up a cairo surface to draw on.

AFAIK, a cairo_t context requires a surface to be created, so I create the cairo_t here as well. Hence, a cairo_t context does not perfectly map to the GDRAW context...

So far, I ignore calls with Bitmap==NULL, I don't know if that is the expected behaviour though.

It looks like, cairo and gdraw use the same bitmap format. I could set up a surface to draw on like this:

   cairo_surface_t *surface = cairo_image_surface_create_for_data(
Bitmap, // This is the Bitmap pointer passed to GDraw_SetDIBitmap
           CAIRO_FORMAT_ARGB32,
           BitmapInfo->biWidth,
           BitmapInfo->biHeight,
           4*BitmapInfo->biWidth /*stride is 4*width bytes*/ );

I have sucessfully drawn some shapes to the "stroke shape / pressure profile" selector by just drawing something directly from GDraw_SetDIBitmap. However, I have not yet been able to draw to the main canvas (which shows the actual image)...

I know, I am moving forward in very little steps, since I am new to all this :-)

Jonas