Ejemplo n.º 1
0
 public D2DImageStrip2D(Bitmap bitmap, float unitWidth, float unitHeight, int count, int arrayCount, ImageStripOrientation orientation)
     : base(bitmap)
 {
     Count       = count;
     Orientation = orientation;
     UnitWidth   = unitWidth;
     UnitHeight  = unitHeight;
     ArrayCount  = arrayCount;
 }
Ejemplo n.º 2
0
        /// <summary>Initializes a new instance of the <see cref="T:Luminous.Drawing.ImageStrip"/> class.</summary>
        /// <param name="imageStrip">The image strip.</param>
        /// <param name="orientation">The orientation of the image strip.</param>
        /// <param name="subImagesCount">Number of sub-images in the image strip.</param>
        /// <param name="subImageBorderThickness">Default border thickness of each sub-image in the image strip.</param>
        /// <exception cref="T:System.ArgumentNullException"><paramref name="imageStrip" /> is null.</exception>
        /// <exception cref="T:System.ArgumentOutOfRangeException"><paramref name="subImagesCount"/> is less than one.
        /// -- or --
        /// <paramref name="subImageBorderThickness" /> is less than zero.</exception>
        /// <exception cref="T:System.ArgumentException">Height (or width, depends on orientation) of imageStrip isn't divisible by subImagesCount.</exception>
        public ImageStrip(Image imageStrip, ImageStripOrientation orientation, int subImagesCount, int subImageBorderThickness)
        {
            if (imageStrip == null)
            {
                throw new ArgumentNullException("imageStrip");
            }
            if (subImagesCount < 1)
            {
                throw new ArgumentOutOfRangeException();
            }
            switch (orientation)
            {
            case ImageStripOrientation.Horizontal:
                if (imageStrip.Width % subImagesCount != 0)
                {
                    throw new ArgumentException();
                }
                break;

            case ImageStripOrientation.Vertical:
                if (imageStrip.Height % subImagesCount != 0)
                {
                    throw new ArgumentException();
                }
                break;

            default:
                throw new ArgumentException("orientation");
            }
            if (subImageBorderThickness < 0)
            {
                throw new ArgumentOutOfRangeException();
            }
            this.imageStripBitmap = new Bitmap(imageStrip);
            this.orientation      = orientation;
            this.subImagesCount   = subImagesCount;
            this.subImageSize     = orientation == ImageStripOrientation.Horizontal ?
                                    new Size(imageStrip.Width / subImagesCount, imageStrip.Height) :
                                    new Size(imageStrip.Width, imageStrip.Height / subImagesCount);
            this.defaultBorderThickness = subImageBorderThickness;

            bitmapList       = new List <Pair>();
            bitmapDictionary = new Dictionary <DrawingParameters, Bitmap>();
        }
Ejemplo n.º 3
0
        public D2DImageStrip(Bitmap bitmap, int count, ImageStripOrientation orientation)
            : base(bitmap)
        {
            Count       = count;
            Orientation = orientation;

            var size = bitmap.PixelSize;

            switch (orientation)
            {
            case ImageStripOrientation.Horizontal:
                UnitWidth  = (float)size.Width / count;
                UnitHeight = size.Height;
                break;

            case ImageStripOrientation.Vertical:
                UnitWidth  = size.Width;
                UnitHeight = (float)size.Height / count;
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(orientation), orientation, null);
            }
        }
Ejemplo n.º 4
0
        public static D2DImageStrip2D LoadImageStrip2D(RenderContext context, System.Drawing.Bitmap bitmap, float unitWidth, float unitHeight, int count, int arrayCount, ImageStripOrientation orientation)
        {
            var bmp = LoadBitmap(context.RenderTarget.DeviceContext2D, bitmap);

            return(new D2DImageStrip2D(bmp, unitWidth, unitHeight, count, arrayCount, orientation));
        }
Ejemplo n.º 5
0
        public static D2DImageStrip LoadImageStrip(RenderContext context, System.Drawing.Bitmap bitmap, int count, ImageStripOrientation orientation)
        {
            var bmp = LoadBitmap(context.RenderTarget.DeviceContext2D, bitmap);

            return(new D2DImageStrip(bmp, count, orientation));
        }
Ejemplo n.º 6
0
        public static D2DImageStrip2D LoadImageStrip2D(RenderContext context, string fileName, float unitWidth, float unitHeight, int count, int arrayCount, ImageStripOrientation orientation)
        {
            var bitmap = LoadBitmap(context.RenderTarget.DeviceContext2D, fileName);

            return(new D2DImageStrip2D(bitmap, unitWidth, unitHeight, count, arrayCount, orientation));
        }
Ejemplo n.º 7
0
        public static D2DImageStrip LoadImageStrip(RenderContext context, string fileName, int count, ImageStripOrientation orientation)
        {
            var bitmap = LoadBitmap(context.RenderTarget.DeviceContext2D, fileName);

            return(new D2DImageStrip(bitmap, count, orientation));
        }
Ejemplo n.º 8
0
        /// <summary>Initializes a new instance of the <see cref="T:Luminous.Drawing.ImageStrip"/> class.</summary>
        /// <param name="imageStrip">The image strip.</param>
        /// <param name="orientation">The orientation of the image strip.</param>
        /// <param name="subImagesCount">Number of sub-images in the image strip.</param>
        /// <param name="subImageBorderThickness">Default border thickness of each sub-image in the image strip.</param>
        /// <exception cref="T:System.ArgumentNullException"><paramref name="imageStrip" /> is null.</exception>
        /// <exception cref="T:System.ArgumentOutOfRangeException"><paramref name="subImagesCount"/> is less than one.
        /// -- or --
        /// <paramref name="subImageBorderThickness" /> is less than zero.</exception>
        /// <exception cref="T:System.ArgumentException">Height (or width, depends on orientation) of imageStrip isn't divisible by subImagesCount.</exception>
        public ImageStrip(Image imageStrip, ImageStripOrientation orientation, int subImagesCount, int subImageBorderThickness)
        {
            if (imageStrip == null)
            {
                throw new ArgumentNullException("imageStrip");
            }
            if (subImagesCount < 1)
            {
                throw new ArgumentOutOfRangeException();
            }
            switch (orientation)
            {
                case ImageStripOrientation.Horizontal:
                    if (imageStrip.Width % subImagesCount != 0)
                    {
                        throw new ArgumentException();
                    }
                    break;
                case ImageStripOrientation.Vertical:
                    if (imageStrip.Height % subImagesCount != 0)
                    {
                        throw new ArgumentException();
                    }
                    break;
                default:
                    throw new ArgumentException("orientation");
            }
            if (subImageBorderThickness < 0)
            {
                throw new ArgumentOutOfRangeException();
            }
            this.imageStripBitmap = new Bitmap(imageStrip);
            this.orientation = orientation;
            this.subImagesCount = subImagesCount;
            this.subImageSize = orientation == ImageStripOrientation.Horizontal ?
                new Size(imageStrip.Width / subImagesCount, imageStrip.Height) :
                new Size(imageStrip.Width, imageStrip.Height / subImagesCount);
            this.defaultBorderThickness = subImageBorderThickness;

            bitmapList = new List<Pair>();
            bitmapDictionary = new Dictionary<DrawingParameters, Bitmap>();
        }