当前位置: 首页>>代码示例>>C#>>正文


C# Cairo.ImageSurface.WriteToPng方法代码示例

本文整理汇总了C#中Cairo.ImageSurface.WriteToPng方法的典型用法代码示例。如果您正苦于以下问题:C# Cairo.ImageSurface.WriteToPng方法的具体用法?C# Cairo.ImageSurface.WriteToPng怎么用?C# Cairo.ImageSurface.WriteToPng使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cairo.ImageSurface的用法示例。


在下文中一共展示了Cairo.ImageSurface.WriteToPng方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestDrawLine

        public void TestDrawLine()
        {
            var bytes = new byte[1024 * 4];
            var format = Cairo.Format.ARGB32;
            var image = new Cairo.ImageSurface (bytes, format, 32, 32, 32 * 4);
            var shape = new LineShape (0.0, 0.0, 32.0, 32.0);
            var look = new Look (SolidBrush.Red, SolidPen.Black);
            var op = new ShapeTree (look, shape);
            using (var context = new Cairo.Context (image)) {
                op.Draw (context);
            }

            image.WriteToPng ("testimages/line.png");
            image.Dispose ();
        }
开发者ID:bvssvni,项目名称:csharp-utils,代码行数:15,代码来源:TestDrawing.cs

示例2: TestDrawEllipse

        public void TestDrawEllipse()
        {
            var bytes = new byte[1024 * 4];
            var format = Cairo.Format.ARGB32;
            var image = new Cairo.ImageSurface (bytes, format, 32, 32, 32 * 4);
            var shape = new EllipseShape ();
            shape.Rectangle = new Rectangle () {
                X = 10.0,
                Y = 4.0,
                Width = 12.0,
                Height = 18.0
            };
            var look = new Look (SolidBrush.Red, SolidPen.Black);
            var op = new ShapeTree (look, shape);
            using (var context = new Cairo.Context (image)) {
                op.Draw (context);
            }

            image.WriteToPng ("testimages/ellipse.png");
            image.Dispose ();
        }
开发者ID:bvssvni,项目名称:csharp-utils,代码行数:21,代码来源:TestDrawing.cs

示例3: CreateImage

        // TODO: We need a parameter here because not all the views are games
        // we need to extend the concept of view to include Widgets
        public bool CreateImage(IDrawable drawable, string file)
        {
            Cairo.ImageSurface cairo_image = null;
            gbrainy.Core.Main.CairoContextEx cr = null;

            try
            {
                file = Path.GetFullPath (file);
                cairo_image = new Cairo.ImageSurface (Cairo.Format.ARGB32, IMAGE_WIDTH, IMAGE_HEIGHT);
                cr = new gbrainy.Core.Main.CairoContextEx (cairo_image, "sans 12", 96);

                // Draw Image
                drawable.Draw (cr, IMAGE_WIDTH, IMAGE_WIDTH, false);
                cairo_image.WriteToPng (file);

                if (File.Exists (file) == false)
                    Logger.Error ("Game.CreateImage. Error writting {0}", file);
                else
                    Logger.Debug ("Game.CreateImage. Wrote image {0}", file);
            }

            catch (Exception e)
            {
                Logger.Error ("Game.CreateImage. Error writting {0} {1}", file, e);
                return false;
            }

            finally
            {
                if (cr != null)
                    ((IDisposable) cr).Dispose ();

                if (cairo_image != null)
                    ((IDisposable) cairo_image).Dispose ();
            }

                return true;
        }
开发者ID:GNOME,项目名称:gbrainy,代码行数:40,代码来源:GameImage.cs

示例4: Save

        public void Save(string file)
        {
            Cairo.ImageSurface s = new Cairo.ImageSurface (Cairo.Format.Rgb24, project.Details.Width, project.Details.Height);
            Cairo.Context cr = new Cairo.Context (s);
            bool previous = asynchronous;

            asynchronous = false;
            Draw (cr, null);
            asynchronous = previous;

            s.WriteToPng (file);
            ((IDisposable)cr).Dispose ();
            s.Destroy ();
        }
开发者ID:GNOME,项目名称:mistelix,代码行数:14,代码来源:DvdMenu.cs

示例5: GenerateMenus

        string GenerateMenus()
        {
            StringBuilder sb = new StringBuilder (2048);
            Cairo.ImageSurface shigh = new Cairo.ImageSurface (Cairo.Format.ARGB32, project.Details.Width, project.Details.Height);
            Cairo.Context chight = new Cairo.Context (shigh);

            Cairo.ImageSurface snormal = new Cairo.ImageSurface (Cairo.Format.ARGB32, project.Details.Width, project.Details.Height);
            Cairo.Context cnormal = new Cairo.Context (snormal);

            for (int i = 0; i < project.Buttons.Count; i++)
            {
                Button button = (Button)project.Buttons [i];
                sb.Append ("   <button name = \"button" + i + "\"\n");
                sb.Append ("    x0 = \"" + project.Buttons[i].X + "\"\n");
                sb.Append ("    y0 = \"" + project.Buttons[i].Y + "\"\n");
                sb.Append ("    x1 = \"" + (project.Buttons[i].X + button.DrawingBoxWidth) + "\"\n");
                sb.Append ("    y1 = \"" + (project.Buttons[i].Y + button.DrawingBoxHeight) + "\"\n");

                sb.Append ("    down = \"ActionDown\"\n");
                sb.Append ("    up = \"ActionUp\"\n");
                sb.Append ("   />\n");
                DrawButtons (button, chight, cnormal);
            }

            // Quantize the images given
            {
                // See: http://www.cairographics.org/manual/bindings-surfaces.html
                byte [] pixels_normal = QuantizeSurface (snormal);
                Cairo.ImageSurface snormal_quantized =  new Cairo.ImageSurface (ref pixels_normal, snormal.Format, snormal.Width, snormal.Height, snormal.Stride);

                byte [] pixels_high = QuantizeSurface (shigh);
                Cairo.ImageSurface shigh_quantized =  new Cairo.ImageSurface (ref pixels_high, shigh.Format, shigh.Width, shigh.Height, shigh.Stride);

                snormal_quantized.WriteToPng (project.FileToFullPath (menu_normal));
                shigh_quantized.WriteToPng (project.FileToFullPath (menu_highlight));

                snormal_quantized.Destroy ();
                shigh_quantized.Destroy ();
            }

            if (Mistelix.Debugging)
            {
                snormal.WriteToPng (project.FileToFullPath ("menu_normal_unquantized.png"));
                shigh.WriteToPng (project.FileToFullPath ("menu_highlight_unquantized.png"));
            }

            ((IDisposable)cnormal).Dispose ();
            ((IDisposable)chight).Dispose ();
            shigh.Destroy ();
            snormal.Destroy ();
            return sb.ToString ();
        }
开发者ID:GNOME,项目名称:mistelix,代码行数:52,代码来源:Spumux.cs


注:本文中的Cairo.ImageSurface.WriteToPng方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。