[cairo] Creating Win32 Bitmap with cairo

Vladimir Vukicevic vladimir at pobox.com
Thu Nov 6 00:37:50 PST 2008


On 11/5/08 9:47 PM, Isenko Evgeny wrote:
> Hello!
>
> Does anyone have an experience of creating Win32 Bitmap with cairo?
>
> The below example is working just fine except one thing: the resulting
> Bitmap is not antialiased. However, if I save the surface into png,
> imgsrf.WriteToPng(fName);
> it IS antialiased.
> So, how make the graphics on the Bitmap to be antialiased?
>
> {
> Bitmap img = new Bitmap(200, 200, Imaging.PixelFormat.Format32bppArgb);
> Graphics mygr = Graphics.FromImage(img);
>
> Cairo.Win32Surface winsrf = new Cairo.Win32Surface(mygr.GetHdc());

Are you sure you don't mean transparency, and not antialiasing?

Note that if you create a cairo win32 surface from a HDC, cairo always 
assumes that that surface is just 24bpp, with no alpha.  If you want a 
bitmap with alpha, you need to have cairo create it, via 
cairo_win32_surface_create_with_dib.

     - Vlad


More information about the cairo mailing list