[longomatch] Add support for roi in copying surfaces
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] Add support for roi in copying surfaces
- Date: Thu, 23 Apr 2015 15:22:09 +0000 (UTC)
commit eff196a0fa175e916ceeb7ef617443b46ee519a8
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Thu Apr 23 13:36:19 2015 +0200
Add support for roi in copying surfaces
.../Interfaces/Drawing/IDrawingToolkit.cs | 2 +-
LongoMatch.Drawing.Cairo/CairoBackend.cs | 28 ++++++++-----------
2 files changed, 13 insertions(+), 17 deletions(-)
---
diff --git a/LongoMatch.Core/Interfaces/Drawing/IDrawingToolkit.cs
b/LongoMatch.Core/Interfaces/Drawing/IDrawingToolkit.cs
index cb76f3a..81c218f 100644
--- a/LongoMatch.Core/Interfaces/Drawing/IDrawingToolkit.cs
+++ b/LongoMatch.Core/Interfaces/Drawing/IDrawingToolkit.cs
@@ -107,7 +107,7 @@ namespace LongoMatch.Core.Interfaces.Drawing
void Save (ICanvas canvas, Area area, string filename);
- Image Copy (ICanvas canvas, double width, double height);
+ Image Copy (ICanvas canvas, Area area);
Area UserToDevice (Area area);
diff --git a/LongoMatch.Drawing.Cairo/CairoBackend.cs b/LongoMatch.Drawing.Cairo/CairoBackend.cs
index 1696b3f..a5d0965 100644
--- a/LongoMatch.Drawing.Cairo/CairoBackend.cs
+++ b/LongoMatch.Drawing.Cairo/CairoBackend.cs
@@ -475,34 +475,30 @@ namespace LongoMatch.Drawing.Cairo
}
}
- public Image Copy (ICanvas canvas, double width, double height)
+ public Image Copy (ICanvas canvas, Area area)
{
Image img;
Pixmap pm;
+ global::Cairo.Context ctx;
- pm = new Pixmap (null, (int)width, (int)height, 24);
+ pm = new Pixmap (null, (int)area.Width, (int)area.Height, 24);
+ ctx = Gdk.CairoHelper.Create (pm);
disableScalling = true;
- using (CairoContext c = new CairoContext (Gdk.CairoHelper.Create (pm))) {
- canvas.Draw (c, new Area (new Point (0, 0), width, height));
+ using (CairoContext c = new CairoContext (ctx)) {
+ ctx.Translate (-area.Start.X, -area.Start.Y);
+ canvas.Draw (c, null);
}
- img = new Image (Gdk.Pixbuf.FromDrawable (pm, Colormap.System, 0, 0, 0, 0,
- (int)width, (int)height));
disableScalling = false;
- Context = null;
+ img = new Image (Pixbuf.FromDrawable (pm, Colormap.System, 0, 0, 0, 0,
+ (int)area.Width, (int)area.Height));
return img;
}
public void Save (ICanvas canvas, Area area, string filename)
{
- ImageSurface pngSurface = new ImageSurface (Format.ARGB32, (int)area.Width,
(int)area.Height);
- disableScalling = true;
- using (CairoContext c = new CairoContext (new global::Cairo.Context (pngSurface))) {
- (c.Value as global::Cairo.Context).Translate (-area.Start.X, -area.Start.Y);
- canvas.Draw (c, null);
- }
- pngSurface.WriteToPng (filename);
- disableScalling = false;
- pngSurface.Dispose ();
+ Image img = Copy (canvas, area);
+ img.Save (filename);
+ img.Dispose ();
}
global::Cairo.Context CContext {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]