コード例 #1
0
        private static RectangleF GetSourceRect(D2DImageStrip2D imageStrip, int index)
        {
            if (index < 0 || index >= imageStrip.Count)
            {
                throw new ArgumentOutOfRangeException(nameof(index));
            }

            int   xIndex, yIndex;
            float w, h;

            switch (imageStrip.Orientation)
            {
            case ImageStripOrientation.Horizontal:
                w      = imageStrip.UnitWidth;
                h      = imageStrip.UnitHeight;
                xIndex = index % imageStrip.ArrayCount;
                yIndex = index / imageStrip.ArrayCount;
                break;

            case ImageStripOrientation.Vertical:
                w      = imageStrip.UnitWidth;
                h      = imageStrip.UnitHeight;
                xIndex = index / imageStrip.ArrayCount;
                yIndex = index % imageStrip.ArrayCount;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            var x = xIndex * w;
            var y = yIndex * h;

            return(new RectangleF(x, y, w, h));
        }
コード例 #2
0
        public static void DrawImageStripUnit(this RenderContext context, D2DImageStrip2D imageStrip, int index, float destX, float destY, float destWidth, float destHeight, float opacity)
        {
            if (index < 0 || index >= imageStrip.Count)
            {
                throw new ArgumentOutOfRangeException(nameof(index), index, null);
            }
            var srcRect = GetSourceRect(imageStrip, index);

            context.DrawBitmap(imageStrip, destX, destY, destWidth, destHeight, srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height, opacity);
        }
コード例 #3
0
        public static void DrawImageStripUnit(this RenderContext context, D2DImageStrip2D imageStrip, int index, float destX, float destY, InterpolationMode interpolationMode, CompositeMode compositeMode)
        {
            if (index < 0 || index >= imageStrip.Count)
            {
                throw new ArgumentOutOfRangeException(nameof(index), index, null);
            }
            var srcRect = GetSourceRect(imageStrip, index);

            context.DrawImage(imageStrip, destX, destY, srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height, interpolationMode, compositeMode);
        }