[longomatch] Image: make public ComputeScale and static ScaleFactor



commit fd8cfd894d5d7be9b91c51bd7d51843012dc21b4
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Fri Aug 1 20:52:11 2014 +0200

    Image: make public ComputeScale and static ScaleFactor

 LongoMatch.Core/Common/Image.cs |   45 ++++++++++++++++++++++----------------
 1 files changed, 26 insertions(+), 19 deletions(-)
---
diff --git a/LongoMatch.Core/Common/Image.cs b/LongoMatch.Core/Common/Image.cs
index 3c3537c..efbbed6 100644
--- a/LongoMatch.Core/Common/Image.cs
+++ b/LongoMatch.Core/Common/Image.cs
@@ -55,17 +55,38 @@ namespace LongoMatch.Common
                }
                
                public void ScaleFactor (int destWidth, int destHeight,
-                                        out double scaleX, out double scaleY,
-                                        out Point offset) {
+                                        out double scaleX, out double scaleY, out Point offset) {
+                       ScaleFactor (Width, Height, destWidth, destHeight, out scaleX, out scaleY, out 
offset);
+               }
+               
+               public static void ScaleFactor (int imgWidth, int imgHeight, int destWidth, int destHeight,
+                                               out double scaleX, out double scaleY, out Point offset)
+               {
                        int oWidth = 0;
                        int oHeight = 0;
                        
-                       ComputeScale (Width, Height, destWidth, destHeight, out oWidth, out oHeight);
-                       scaleX = (double) oWidth / Width;
-                       scaleY = (double) oHeight / Height;
+                       ComputeScale (imgWidth, imgHeight, destWidth, destHeight, out oWidth, out oHeight);
+                       scaleX = (double) oWidth / imgWidth;
+                       scaleY = (double) oHeight / imgHeight;
                        offset = new Point ((destWidth - oWidth) / 2, (destHeight - oHeight) / 2);
                }
                
+               public static void ComputeScale (int inWidth, int inHeight, int maxOutWidth, int maxOutHeight,
+                                                out int outWidth, out int outHeight)
+               {
+                       outWidth = maxOutWidth;
+                       outHeight = maxOutHeight;
+
+                       double par = (double)inWidth /(double)inHeight;
+                       double outPar = (double)maxOutWidth /(double)maxOutHeight;
+                               
+                       if (outPar > par) {
+                               outWidth = Math.Min (maxOutWidth, (int)(outHeight * par));
+                       } else {
+                               outHeight = Math.Min (maxOutHeight, (int)(outWidth / par));
+                       }
+               } 
+               
                // this constructor is automatically called during deserialization
                public Image (SerializationInfo info, StreamingContext context) {
                        try {
@@ -181,20 +202,6 @@ namespace LongoMatch.Common
                }
 #endif
 
-               private void ComputeScale (int inWidth, int inHeight, int maxOutWidth, int maxOutHeight, out 
int outWidth, out int outHeight)
-               {
-                       outWidth = maxOutWidth;
-                       outHeight = maxOutHeight;
-
-                       double par = (double)inWidth /(double)inHeight;
-                       double outPar = (double)maxOutWidth /(double)maxOutHeight;
-                               
-                       if (outPar > par) {
-                               outWidth = Math.Min (maxOutWidth, (int)(outHeight * par));
-                       } else {
-                               outHeight = Math.Min (maxOutHeight, (int)(outWidth / par));
-                       }
-               } 
        }
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]