예제 #1
0
 /// <summary>
 /// Copies the specified BoxPadding instance
 /// </summary>
 /// <param name="original"></param>
 public BoxPadding(BoxPadding original)
 {
     this.top    = original.top;
     this.bottom = original.bottom;
     this.right  = original.right;
     this.left   = original.left;
 }
예제 #2
0
 /// <summary>
 /// Copies the specified BoxPadding instance
 /// </summary>
 /// <param name="original"></param>
 public BoxPadding(BoxPadding original)
 {
     this.top = original.top;
     this.bottom = original.bottom;
     this.right = original.right;
     this.left = original.left;
 }
예제 #3
0
        public static BoxPadding Parse(string text, BoxPadding fallbackValue)
        {
            double[] coords = ParseUtils.ParseList <double>(text, 0, 1, 4);
            if (coords == null)
            {
                return(fallbackValue);                //Failed to parse, or was empty
            }
            if (coords.Length == 1)
            {
                return(new BoxPadding(coords[0]));
            }
            if (coords.Length == 4)
            {
                return(new BoxPadding(coords[0], coords[1], coords[2], coords[3]));
            }

            return(fallbackValue);
        }
예제 #4
0
 public BoxPadding SetTop(double top)
 {
     BoxPadding b = new BoxPadding(this); b.top = top;
     return b;
 }
예제 #5
0
 public BoxPadding SetRight(double right)
 {
     BoxPadding b = new BoxPadding(this); b.right = right;
     return b;
 }
예제 #6
0
 public BoxPadding SetLeft(double left)
 {
     BoxPadding b = new BoxPadding(this); b.left = left;
     return b;
 }
예제 #7
0
 public BoxPadding SetBottom(double bottom)
 {
     BoxPadding b = new BoxPadding(this); b.bottom = bottom;
     return b;
 }
예제 #8
0
 /// <summary>
 /// Sets the width of all edges, returning a new instance
 /// </summary>
 /// <param name="all"></param>
 /// <returns></returns>
 public BoxPadding SetAll(double all)
 {
     BoxPadding b = new BoxPadding(this); b.all = all;
     return b;
 }
예제 #9
0
        public BoxPadding SetRight(double right)
        {
            BoxPadding b = new BoxPadding(this); b.right = right;

            return(b);
        }
예제 #10
0
 /// <summary>
 /// Inflates the last ring using the specified padding options. Returns the resulting ring object
 /// </summary>
 /// <param name="name"></param>
 /// <param name="padding"></param>
 /// <returns></returns>
 public PointSet AddRing(string name, BoxPadding padding)
 {
     return AddRing(name, PolygonMath.InflatePoly(LastRing.points, padding.GetEdgeOffsets()));
 }
예제 #11
0
        public BoxPadding SetTop(double top)
        {
            BoxPadding b = new BoxPadding(this); b.top = top;

            return(b);
        }
예제 #12
0
        /// <summary>
        /// Sets the width of all edges, returning a new instance
        /// </summary>
        /// <param name="all"></param>
        /// <returns></returns>
        public BoxPadding SetAll(double all)
        {
            BoxPadding b = new BoxPadding(this); b.all = all;

            return(b);
        }
예제 #13
0
        public BoxPadding SetBottom(double bottom)
        {
            BoxPadding b = new BoxPadding(this); b.bottom = bottom;

            return(b);
        }
예제 #14
0
        /// <summary>
        /// Builds an FIBitmap from the stream and job.Settings 
        /// </summary>
        /// <param name="s"></param>
        /// <param name="job"></param>
        /// <returns></returns>
        protected FIBITMAP buildFiBitmap(ref FIBITMAP original, ImageJob job, bool supportsTransparency, bool mayUnloadOriginal)
        {
            ResizeSettings settings = job.Settings;
            if (original.IsNull) return FIBITMAP.Zero;
            FIBITMAP final = FIBITMAP.Zero;

            //Find the image size
            Size orig = new Size((int)FreeImage.GetWidth(original), (int)FreeImage.GetHeight(original));

            //Calculate the new size of the image and the canvas.
            ImageState state = new ImageState(settings, orig, true);
            c.CurrentImageBuilder.Process(state);
            RectangleF imageDest = PolygonMath.GetBoundingBox(state.layout["image"]);

            if (imageDest.Width != orig.Width || imageDest.Height != orig.Height) {
                //Rescale
                bool temp;
                final = FreeImage.Rescale(original, (int)imageDest.Width, (int)imageDest.Height, FreeImageScalingPlugin.ParseResizeAlgorithm(settings["fi.scale"], FREE_IMAGE_FILTER.FILTER_BOX, out temp));
                if (mayUnloadOriginal) FreeImage.UnloadEx(ref original);
                if (final.IsNull) return FIBITMAP.Zero;
            } else {
                final = original;
            }

            RGBQUAD bgcolor = default(RGBQUAD);
            bgcolor.Color = settings.BackgroundColor;
            if (settings.BackgroundColor == Color.Transparent && !supportsTransparency)
                bgcolor.Color = Color.White;

            //If we need to leave padding, do so.
            BoxPadding outsideImage = new BoxPadding(imageDest.Left, imageDest.Top, state.destSize.Width - imageDest.Right, state.destSize.Height - imageDest.Bottom);

            if (outsideImage.All != 0) {
                var old = final;
                //Extend canvas
                final = FreeImage.EnlargeCanvas<RGBQUAD>(old,
                            (int)outsideImage.Left, (int)outsideImage.Top, (int)outsideImage.Right, (int)outsideImage.Bottom,
                            bgcolor.Color != Color.Transparent ? new Nullable<RGBQUAD>(bgcolor) : null,
                            FREE_IMAGE_COLOR_OPTIONS.FICO_RGBA);
                if (old == original) {
                    if (mayUnloadOriginal) {
                        FreeImage.UnloadEx(ref original);
                        old = original;
                    }
                } else {
                    FreeImage.UnloadEx(ref old); //'old' has the original value of 'final', which we allocated.
                }
                if (final.IsNull) return FIBITMAP.Zero;
            }

            return final;
        }
예제 #15
0
        public static BoxPadding Parse(string text, BoxPadding fallbackValue)
        {
            double[] coords = ParseUtils.ParseList<double>(text, 0, 1, 4);
            if (coords == null) return fallbackValue; //Failed to parse, or was empty

            if (coords.Length == 1) return new BoxPadding(coords[0]);
            if (coords.Length == 4) return new BoxPadding(coords[0], coords[1], coords[2], coords[3]);

            return fallbackValue;
        }
예제 #16
0
 /// <summary>
 /// Inflates the last ring using the specified padding options. Returns the resulting ring object
 /// </summary>
 /// <param name="name"></param>
 /// <param name="padding"></param>
 /// <returns></returns>
 public PointSet AddRing(string name, BoxPadding padding)
 {
     return(AddRing(name, PolygonMath.InflatePoly(LastRing.points, padding.GetEdgeOffsets())));
 }
예제 #17
0
        public BoxPadding SetLeft(double left)
        {
            BoxPadding b = new BoxPadding(this); b.left = left;

            return(b);
        }