[cairo] Load a Bitmap in ImageSurface

Saeed shahbazi saeed.shahbazi at gmail.com
Mon Oct 14 05:40:46 CEST 2013


Thanks but it did not work. I used the code as follows:

           Bitmap clone = new Bitmap(image.Width, image.Height,
System.Drawing.Imaging.PixelFormat.Format32bppArgb);
            using (System.Drawing.Graphics gr =
System.Drawing.Graphics.FromImage(clone))
            {
                gr.DrawImage(image, new Rectangle(0, 0, clone.Width,
clone.Height));
            }

            var ms = new MemoryStream();
            image.Save(ms, ImageFormat.Bmp);
            var imageSurface = new ImageSurface(ms.ToArray(),
Format.ARGB32, image.Width, image.Height, image.Width * 4);
            this.m_internalContext.Antialias = Antialias.None;
            imageSurface.Show(this.m_internalContext, destRect.X,
destRect.Y);
            imageSurface.Destroy();
            ms.Dispose();

I think the problem is related to the formatting. my black pictures with
white letters inside become green pictures, cut in half which are rotated.

Cheers,


On Mon, Oct 14, 2013 at 1:02 PM, Mike Gran <spk121 at yahoo.com> wrote:

>
>
> > Hi all,
> >
> >
> >I'm using Mono and .Net 2 and I want to load a System.Drawing.Image image
> to ImageSurface. All my efforts led to fuzzy images but the one as follows:
>
> Don't know much about C#, but, maybe you just need to request no
> antialiasing
> explicitly before you paint to a context.  Something like
>
>
> cairo_set_antialias (context, CAIRO_ANTIALIAS_NONE);
>
> -Mike Gran
>
>


-- 
-
Best Regards,
Saeed
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo/attachments/20131014/0df47179/attachment.html>


More information about the cairo mailing list