示例#1
0
        public Mat rotate(Mat img, RotateFlags flags)
        {
            var dst = new Mat();

            cv2_native_api.core_rotate(img.InputArray, dst.OutputArray, (int)flags);
            return(dst);
        }
示例#2
0
        // General rotation about image center
        /// <summary>
        ///      (1) This is a high-level, simple interface for rotating images
        ///          about their center.
        ///      (2) For very small rotations, just return a clone.
        ///      (3) Rotation brings either white or black pixels in
        ///          from outside the image.
        ///      (4) The rotation type is adjusted if necessary for the image
        ///          depth and size of rotation angle.For 1 bpp images, we
        /// rotate either by shear or sampling.
        ///      (5) Colormaps are removed for rotation by area mapping.
        ///      (6) The dest can be expanded so that no image pixels
        ///          are lost.To invoke expansion, input the original
        /// width and height.  For repeated rotation, use of the
        /// original width and height allows the expansion to
        /// stop at the maximum required size, which is a square
        ///          with side = sqrt(w * w + h * h).
        /// </summary>
        /// <param name="pixs">1, 2, 4, 8, 32 bpp rgb</param>
        /// <param name="angle">radians; clockwise is positive</param>
        /// <param name="type">L_ROTATE_AREA_MAP, L_ROTATE_SHEAR, L_ROTATE_SAMPLING</param>
        /// <param name="incolor">L_BRING_IN_WHITE, L_BRING_IN_BLACK</param>
        /// <param name="width">original width; use 0 to avoid embedding</param>
        /// <param name="height">original height; use 0 to avoid embedding</param>
        /// <returns>pixd, or NULL on error</returns>
        public static Pix pixRotate(this Pix pixs, float angle, RotateFlags type, BackgroundFlags incolor, int width, int height)
        {
            if (null == pixs)
            {
                throw new ArgumentNullException("pixs cannot be null.");
            }
            var pointer = Native.DllImports.pixRotate((HandleRef)pixs, angle, type, incolor, width, height);

            if (IntPtr.Zero == pointer)
            {
                return(null);
            }
            else
            {
                return(new Pix(pointer));
            }
        }