Esempio n. 1
0
        public static IImageProcessingContext Rotate(this IImageProcessingContext source, float degrees, Vector2 origin)
        {
            var affineBuilder = new AffineTransformBuilder();

            affineBuilder.AppendRotationDegrees(degrees, origin);

            source.Transform(affineBuilder);

            return(source);
        }
Esempio n. 2
0
        /// <summary>
        /// Performs an affine transform of an image using the specified sampling algorithm.
        /// </summary>
        /// <param name="ctx">The <see cref="IImageProcessingContext"/>.</param>
        /// <param name="sourceRectangle">The source rectangle</param>
        /// <param name="builder">The affine transform builder.</param>
        /// <param name="sampler">The <see cref="IResampler"/> to perform the resampling.</param>
        /// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
        public static IImageProcessingContext Transform(
            this IImageProcessingContext ctx,
            Rectangle sourceRectangle,
            AffineTransformBuilder builder,
            IResampler sampler)
        {
            Matrix3x2 transform        = builder.BuildMatrix(sourceRectangle);
            Size      targetDimensions = TransformUtilities.GetTransformedSize(sourceRectangle.Size, transform);

            return(ctx.Transform(sourceRectangle, transform, targetDimensions, sampler));
        }
Esempio n. 3
0
        /// <summary>
        /// Performs an affine transform of an image using the specified sampling algorithm.
        /// </summary>
        /// <typeparam name="TPixel">The pixel format.</typeparam>
        /// <param name="ctx">The <see cref="IImageProcessingContext{TPixel}"/>.</param>
        /// <param name="sourceRectangle">The source rectangle</param>
        /// <param name="builder">The affine transform builder.</param>
        /// <param name="sampler">The <see cref="IResampler"/> to perform the resampling.</param>
        /// <returns>The <see cref="Image{TPixel}"/></returns>
        public static IImageProcessingContext <TPixel> Transform <TPixel>(
            this IImageProcessingContext <TPixel> ctx,
            Rectangle sourceRectangle,
            AffineTransformBuilder builder,
            IResampler sampler)
            where TPixel : struct, IPixel <TPixel>
        {
            Matrix3x2 transform        = builder.BuildMatrix(sourceRectangle);
            Size      targetDimensions = TransformUtils.GetTransformedSize(sourceRectangle.Size, transform);

            return(ctx.Transform(sourceRectangle, transform, targetDimensions, sampler));
        }
Esempio n. 4
0
        protected void ProjectLayerOntoSurface(IImageProcessingContext <Rgba32> context, Matrix <float> transformMatrix)
        {
            var matrix4x4 = new System.Numerics.Matrix4x4(
                transformMatrix[0, 0], transformMatrix[1, 0], 0, transformMatrix[2, 0],
                transformMatrix[0, 1], transformMatrix[1, 1], 0, transformMatrix[2, 1],
                0, 0, 1, 0,
                transformMatrix[0, 2], transformMatrix[1, 2], 0, transformMatrix[2, 2]
                );

            context.Transform(matrix4x4, KnownResamplers.Lanczos3);
            foreach (var mask in Masks)
            {
                context.Opacity(0, mask);
            }
        }
Esempio n. 5
0
 /// <summary>
 /// Performs a projective transform of an image using the specified sampling algorithm.
 /// </summary>
 /// <param name="ctx">The <see cref="IImageProcessingContext"/>.</param>
 /// <param name="builder">The projective transform builder.</param>
 /// <param name="sampler">The <see cref="IResampler"/> to perform the resampling.</param>
 /// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
 public static IImageProcessingContext Transform(
     this IImageProcessingContext ctx,
     ProjectiveTransformBuilder builder,
     IResampler sampler) =>
 ctx.Transform(new Rectangle(Point.Empty, ctx.GetCurrentSize()), builder, sampler);
Esempio n. 6
0
 /// <summary>
 /// Performs an affine transform of an image using the specified sampling algorithm.
 /// </summary>
 /// <typeparam name="TPixel">The pixel format.</typeparam>
 /// <param name="ctx">The <see cref="IImageProcessingContext{TPixel}"/>.</param>
 /// <param name="builder">The affine transform builder.</param>
 /// <param name="sampler">The <see cref="IResampler"/> to perform the resampling.</param>
 /// <returns>The <see cref="Image{TPixel}"/></returns>
 public static IImageProcessingContext <TPixel> Transform <TPixel>(
     this IImageProcessingContext <TPixel> ctx,
     AffineTransformBuilder builder,
     IResampler sampler)
     where TPixel : struct, IPixel <TPixel>
 => ctx.Transform(new Rectangle(Point.Empty, ctx.GetCurrentSize()), builder, sampler);