[longomatch] Add support for exporting canvases with a roi defined
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] Add support for exporting canvases with a roi defined
- Date: Thu, 23 Apr 2015 15:20:33 +0000 (UTC)
commit 2f2d93d03f78f1ffe274c13f46bee17af214be4e
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Tue Apr 21 11:48:31 2015 +0200
Add support for exporting canvases with a roi defined
.../Interfaces/Drawing/IDrawingToolkit.cs | 2 +-
LongoMatch.Drawing.Cairo/CairoBackend.cs | 15 +++++++++------
LongoMatch.Drawing/Widgets/Blackboard.cs | 8 +++++++-
3 files changed, 17 insertions(+), 8 deletions(-)
---
diff --git a/LongoMatch.Core/Interfaces/Drawing/IDrawingToolkit.cs
b/LongoMatch.Core/Interfaces/Drawing/IDrawingToolkit.cs
index 3214770..cb76f3a 100644
--- a/LongoMatch.Core/Interfaces/Drawing/IDrawingToolkit.cs
+++ b/LongoMatch.Core/Interfaces/Drawing/IDrawingToolkit.cs
@@ -105,7 +105,7 @@ namespace LongoMatch.Core.Interfaces.Drawing
void DrawArrow (Point start, Point stop, int lenght, double degrees, bool closed);
- void Save (ICanvas canvas, double width, double height, string filename);
+ void Save (ICanvas canvas, Area area, string filename);
Image Copy (ICanvas canvas, double width, double height);
diff --git a/LongoMatch.Drawing.Cairo/CairoBackend.cs b/LongoMatch.Drawing.Cairo/CairoBackend.cs
index 68f7d70..1696b3f 100644
--- a/LongoMatch.Drawing.Cairo/CairoBackend.cs
+++ b/LongoMatch.Drawing.Cairo/CairoBackend.cs
@@ -190,9 +190,11 @@ namespace LongoMatch.Drawing.Cairo
public void Clip (Area area)
{
- CContext.Rectangle (area.Start.X, area.Start.Y,
- area.Width, area.Height);
- CContext.Clip ();
+ if (!disableScalling) {
+ CContext.Rectangle (area.Start.X, area.Start.Y,
+ area.Width, area.Height);
+ CContext.Clip ();
+ }
}
public Area UserToDevice (Area a)
@@ -490,12 +492,13 @@ namespace LongoMatch.Drawing.Cairo
return img;
}
- public void Save (ICanvas canvas, double width, double height, string filename)
+ public void Save (ICanvas canvas, Area area, string filename)
{
- ImageSurface pngSurface = new ImageSurface (Format.ARGB32, (int)width, (int)height);
+ ImageSurface pngSurface = new ImageSurface (Format.ARGB32, (int)area.Width,
(int)area.Height);
disableScalling = true;
using (CairoContext c = new CairoContext (new global::Cairo.Context (pngSurface))) {
- canvas.Draw (c, new Area (new Point (0, 0), width, height));
+ (c.Value as global::Cairo.Context).Translate (-area.Start.X, -area.Start.Y);
+ canvas.Draw (c, null);
}
pngSurface.WriteToPng (filename);
disableScalling = false;
diff --git a/LongoMatch.Drawing/Widgets/Blackboard.cs b/LongoMatch.Drawing/Widgets/Blackboard.cs
index 8b4f35c..afb3b76 100644
--- a/LongoMatch.Drawing/Widgets/Blackboard.cs
+++ b/LongoMatch.Drawing/Widgets/Blackboard.cs
@@ -171,8 +171,14 @@ namespace LongoMatch.Drawing.Widgets
public void Save (string filename)
{
+ Area area;
+
ClearSelection ();
- tk.Save (this, Background.Width, Background.Height, filename);
+ area = RegionOfInterest;
+ if (area == null) {
+ area = new Area (0, 0, Background.Width, Background.Height);
+ }
+ tk.Save (this, area, filename);
}
public void Zoom (double zoom, Point center = null)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]