[longomatch] Split image scaling in copy and in place
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] Split image scaling in copy and in place
- Date: Mon, 7 Jul 2014 11:33:30 +0000 (UTC)
commit a50c76eb29dced1f8f4f7db2631a515889e637fb
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Mon Jul 7 12:43:10 2014 +0200
Split image scaling in copy and in place
LongoMatch.Core/Common/Constants.cs | 3 ++
LongoMatch.Core/Common/Image.cs | 21 ++++++++++++++-----
LongoMatch.GUI.Multimedia/Gui/CapturerBin.cs | 2 +-
.../Gui/Utils/FramesCapturer.cs | 2 +-
LongoMatch.GUI/Gui/Component/TeamTemplateEditor.cs | 6 +++-
LongoMatch.GUI/Gui/Dialog/DrawingTool.cs | 4 +-
6 files changed, 26 insertions(+), 12 deletions(-)
---
diff --git a/LongoMatch.Core/Common/Constants.cs b/LongoMatch.Core/Common/Constants.cs
index af0b2cc..fbcdeff 100644
--- a/LongoMatch.Core/Common/Constants.cs
+++ b/LongoMatch.Core/Common/Constants.cs
@@ -113,6 +113,9 @@ Xavier Queralt Mateu (ca)";
public const int MAX_PLAYER_ICON_SIZE = 100;
public const int MAX_SHIELD_ICON_SIZE = 100;
public const int MAX_THUMBNAIL_SIZE = 100;
+ public const int MAX_BACKGROUND_WIDTH = 600;
+ public const int MAX_BACKGROUND_HEIGHT = 400;
+
public static Color HOME_COLOR = Color.Red1;
public static Color AWAY_COLOR = Color.Blue1;
diff --git a/LongoMatch.Core/Common/Image.cs b/LongoMatch.Core/Common/Image.cs
index 245a79b..3c3537c 100644
--- a/LongoMatch.Core/Common/Image.cs
+++ b/LongoMatch.Core/Common/Image.cs
@@ -50,8 +50,8 @@ namespace LongoMatch.Common
image.Dispose();
}
- public void Scale() {
- Scale (Constants.MAX_THUMBNAIL_SIZE, Constants.MAX_THUMBNAIL_SIZE);
+ public void ScaleInplace() {
+ ScaleInplace (Constants.MAX_THUMBNAIL_SIZE, Constants.MAX_THUMBNAIL_SIZE);
}
public void ScaleFactor (int destWidth, int destHeight,
@@ -96,12 +96,14 @@ namespace LongoMatch.Common
return new Image(new SImage(ser));
}
- public void Scale(int maxWidth, int maxHeight) {
+ public Image Scale(int maxWidth, int maxHeight) {
+ return new Image (Scale (image, maxWidth, maxHeight));
+ }
+
+ public void ScaleInplace(int maxWidth, int maxHeight) {
SImage scalled;
- int width, height;
- ComputeScale(image.Width, image.Height, maxWidth, maxHeight, out width, out height);
- scalled= image.ScaleSimple(width, height, Gdk.InterpType.Bilinear);
+ scalled = Scale (image, maxWidth, maxHeight);
image.Dispose();
image = scalled;
}
@@ -132,6 +134,13 @@ namespace LongoMatch.Common
return new Image(dest);
}
+ SImage Scale (SImage pix, int maxWidth, int maxHeight) {
+ int width, height;
+
+ ComputeScale(pix.Width, pix.Height, maxWidth, maxHeight, out width, out height);
+ return pix.ScaleSimple(width, height, Gdk.InterpType.Bilinear);
+ }
+
#else
public byte[] Serialize () {
if (image == null)
diff --git a/LongoMatch.GUI.Multimedia/Gui/CapturerBin.cs b/LongoMatch.GUI.Multimedia/Gui/CapturerBin.cs
index 55f705d..81686b9 100644
--- a/LongoMatch.GUI.Multimedia/Gui/CapturerBin.cs
+++ b/LongoMatch.GUI.Multimedia/Gui/CapturerBin.cs
@@ -232,7 +232,7 @@ namespace LongoMatch.Gui
if(image.Value == null)
return null;
- image.Scale (Constants.MAX_THUMBNAIL_SIZE, Constants.MAX_THUMBNAIL_SIZE);
+ image.ScaleInplace (Constants.MAX_THUMBNAIL_SIZE,
Constants.MAX_THUMBNAIL_SIZE);
return image;
}
}
diff --git a/LongoMatch.GUI.Multimedia/Gui/Utils/FramesCapturer.cs
b/LongoMatch.GUI.Multimedia/Gui/Utils/FramesCapturer.cs
index 389b393..5628e69 100644
--- a/LongoMatch.GUI.Multimedia/Gui/Utils/FramesCapturer.cs
+++ b/LongoMatch.GUI.Multimedia/Gui/Utils/FramesCapturer.cs
@@ -89,7 +89,7 @@ namespace LongoMatch.Video.Utils
frame = capturer.GetCurrentFrame();
if(frame != null) {
frame.Save(System.IO.Path.Combine(outputDir,seriesName+"_" +
i +".png"));
- frame.Scale(THUMBNAIL_MAX_WIDTH, THUMBNAIL_MAX_HEIGHT);
+ frame.ScaleInplace(THUMBNAIL_MAX_WIDTH, THUMBNAIL_MAX_HEIGHT);
}
if(Progress != null) {
diff --git a/LongoMatch.GUI/Gui/Component/TeamTemplateEditor.cs
b/LongoMatch.GUI/Gui/Component/TeamTemplateEditor.cs
index 6aee0ca..03258e8 100644
--- a/LongoMatch.GUI/Gui/Component/TeamTemplateEditor.cs
+++ b/LongoMatch.GUI/Gui/Component/TeamTemplateEditor.cs
@@ -254,7 +254,8 @@ namespace LongoMatch.Gui.Component
}
player = new Image (pix);
- player.Scale (Constants.MAX_PLAYER_ICON_SIZE, Constants.MAX_PLAYER_ICON_SIZE);
+ player.ScaleInplace (Constants.MAX_PLAYER_ICON_SIZE,
+ Constants.MAX_PLAYER_ICON_SIZE);
if (player != null && loadedPlayer != null) {
playerimage.Pixbuf = player.Value;
loadedPlayer.Photo = player;
@@ -273,7 +274,8 @@ namespace LongoMatch.Gui.Component
}
shield = new Image (pix);
- shield.Scale (Constants.MAX_SHIELD_ICON_SIZE, Constants.MAX_SHIELD_ICON_SIZE);
+ shield.ScaleInplace (Constants.MAX_SHIELD_ICON_SIZE,
+ Constants.MAX_SHIELD_ICON_SIZE);
if (shield != null)
{
shieldimage.Pixbuf = shield.Value;
diff --git a/LongoMatch.GUI/Gui/Dialog/DrawingTool.cs b/LongoMatch.GUI/Gui/Dialog/DrawingTool.cs
index e8ed3fc..2db1f77 100644
--- a/LongoMatch.GUI/Gui/Dialog/DrawingTool.cs
+++ b/LongoMatch.GUI/Gui/Dialog/DrawingTool.cs
@@ -303,8 +303,8 @@ namespace LongoMatch.Gui.Dialog
play.Drawings.Add (drawing);
}
play.Miniature = blackboard.Save ();
- play.Miniature.Scale (Constants.MAX_THUMBNAIL_SIZE,
- Constants.MAX_THUMBNAIL_SIZE);
+ play.Miniature.ScaleInplace (Constants.MAX_THUMBNAIL_SIZE,
+ Constants.MAX_THUMBNAIL_SIZE);
drawing = null;
Respond (ResponseType.Accept);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]