示例#1
0
		public static ScaleFactor Max (ScaleFactor lhs, ScaleFactor rhs)
		{
			if (lhs > rhs) {
				return lhs;
			} else {
				return lhs;
			}
		}
示例#2
0
		public static ScaleFactor Min (ScaleFactor lhs, ScaleFactor rhs)
		{
			if (lhs < rhs) {
				return lhs;
			} else {
				return rhs;
			}
		}
示例#3
0
		public static ScaleFactor UseIfValid (int numerator, int denominator, ScaleFactor lastResort)
		{
			if (numerator <= 0 || denominator <= 0) {
				return lastResort;
			} else {
				return new ScaleFactor (numerator, denominator);
			}
		}
示例#4
0
        public void Initialize(Size sourceSize, Size destinationSize)
        {
            if (sourceSize == source_size && destinationSize == destination_size)
                return;

            source_size = sourceSize;
            destination_size = destinationSize;

            scale_factor = new ScaleFactor (source_size.Width, destination_size.Width);
            generated = false;
        }
示例#5
0
 /// <summary>
 /// Converts a point from window coordinates to canvas coordinates
 /// </summary>
 /// <param name='x'>
 /// The X coordinate of the window point
 /// </param>
 /// <param name='y'>
 /// The Y coordinate of the window point
 /// </param>
 public Cairo.PointD WindowPointToCanvas(double x, double y)
 {
     ScaleFactor sf = new ScaleFactor(PintaCore.Workspace.ImageSize.Width, PintaCore.Workspace.CanvasSize.Width);
     Cairo.PointD pt = sf.ScalePoint (new Cairo.PointD(x - Offset.X, y - Offset.Y));
     return new Cairo.PointD((int)pt.X, (int)pt.Y);
 }
示例#6
0
 /// <summary>
 /// Converts a point from canvas coordinates to window coordinates
 /// </summary>
 /// <param name='x'>
 /// The X coordinate of the canvas point
 /// </param>
 /// <param name='y'>
 /// The Y coordinate of the canvas point
 /// </param>
 public Cairo.PointD CanvasPointToWindow(double x, double y)
 {
     ScaleFactor sf = new ScaleFactor(PintaCore.Workspace.ImageSize.Width, PintaCore.Workspace.CanvasSize.Width);
     Cairo.PointD pt = sf.UnscalePoint (new Cairo.PointD(x, y));
     return new Cairo.PointD((int)(pt.X + Offset.X), (int)(pt.Y + Offset.Y));
 }
示例#7
0
        private int[] CreateS2DLookupY(int srcHeight, int dstHeight, ScaleFactor scaleFactor)
        {
            var lookup = new int[srcHeight + 1];

            for (int y = 0; y < lookup.Length; ++y) {
                Gdk.Point pt = new Gdk.Point (0, y);
                Gdk.Point clientPt = scaleFactor.UnscalePoint (pt);

                // Sometimes the scale factor is slightly different on one axis than
                // on another, simply due to accuracy. So we have to clamp this value to
                // be within bounds.
                lookup[y] = Utility.Clamp (clientPt.Y, 0, dstHeight - 1);
            }

            return lookup;
        }
示例#8
0
        private int[] CreateS2DLookupX(int srcWidth, int dstWidth, ScaleFactor scaleFactor)
        {
            var lookup = new int[srcWidth + 1];

            for (int x = 0; x < lookup.Length; ++x) {
                Gdk.Point pt = new Gdk.Point (x, 0);
                Gdk.Point clientPt = scaleFactor.UnscalePoint (pt);

                // Sometimes the scale factor is slightly different on one axis than
                // on another, simply due to accuracy. So we have to clamp this value to
                // be within bounds.
                lookup[x] = Utility.Clamp (clientPt.X, 0, dstWidth - 1);
            }

            return lookup;
        }
示例#9
0
		public static ScaleFactor Max (int n1, int d1, int n2, int d2, ScaleFactor lastResort)
		{
			ScaleFactor a = UseIfValid (n1, d1, lastResort);
			ScaleFactor b = UseIfValid (n2, d2, lastResort);
			return ScaleFactor.Max (a, b);
		}