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 (); }
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 (); }