Ejemplo n.º 1
0
        /// <summary>
        ///     Add the specified pix to the end of the pix array.
        /// </summary>
        /// <remarks>
        ///     PixArrayAccessType.Insert is not supported as the managed Pix object will attempt to release the pix when
        ///     it goes out of scope creating an access exception.
        /// </remarks>
        /// <param name="pix">The pix to add.</param>
        /// <param name="copyflag">Determines if a clone or copy of the pix is inserted into the array.</param>
        /// <returns></returns>
        public bool Add(Pix pix, PixArrayAccessType copyflag = PixArrayAccessType.Clone)
        {
            Guard.RequireNotNull("pix", pix);
            Guard.Require("copyflag", copyflag == PixArrayAccessType.Clone || copyflag == PixArrayAccessType.Copy,
                          "Copy flag must be either copy or clone but was {0}.", copyflag);

            var result = LeptonicaApi.Native.pixaAddPix(_handle, pix.Handle, copyflag);

            if (result == 0)
            {
                _count = LeptonicaApi.Native.pixaGetCount(_handle);
            }
            return(result == 0);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets the <see cref="Pix"/> located at <paramref name="index"/> using the specified <paramref name="accessType"/>.
        /// </summary>
        /// <param name="index">The index of the pix (zero based).</param>
        /// <param name="accessType">The <see cref="PixArrayAccessType" /> used to retrieve the <see cref="Pix"/>, only Clone or Copy are allowed.</param>
        /// <returns>The retrieved <see cref="Pix"/>.</returns>
        public Pix GetPix(int index, PixArrayAccessType accessType = PixArrayAccessType.Clone)
        {
            Guard.Require("accessType", accessType == PixArrayAccessType.Clone || accessType == PixArrayAccessType.Copy, "Access type must be either copy or clone but was {0}.", accessType);
            Guard.Require("index", index >= 0 && index < Count, "The index {0} must be between 0 and {1}.", index, Count);

            VerifyNotDisposed();

            var pixHandle = Interop.LeptonicaApi.Native.pixaGetPix(_handle, index, accessType);

            if (pixHandle == IntPtr.Zero)
            {
                throw new InvalidOperationException(String.Format("Failed to retrieve pix {0}.", pixHandle));
            }
            return(Pix.Create(pixHandle));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets the <see cref="Pix"/> located at <paramref name="index"/> using the specified <paramref name="accessType"/>.
        /// </summary>
        /// <param name="index">The index of the pix (zero based).</param>
        /// <param name="accessType">The <see cref="PixArrayAccessType" /> used to retrieve the <see cref="Pix"/>, only Clone or Copy are allowed.</param>
        /// <returns>The retrieved <see cref="Pix"/>.</returns>
        public Pix GetPix(int index, PixArrayAccessType accessType = PixArrayAccessType.Clone)
        {
            Guard.Require(nameof(accessType), accessType == PixArrayAccessType.Clone || accessType == PixArrayAccessType.Copy, "Access type must be either copy or clone but was {0}.", accessType);
            Guard.Require(nameof(index), index >= 0 && index < Count, "The index {0} must be between 0 and {1}.", index, Count);

            VerifyNotDisposed();

            var pixHandle = Interop.LeptonicaApiSignatures.pixaGetPix(_handle, index, accessType);

            if (pixHandle == IntPtr.Zero)
            {
                throw new InvalidOperationException(string.Format("Failed to retrieve pix {0}.", pixHandle));
            }
            var result = Pix.Create(pixHandle);

            result.ImageName = this.Filename;
            return(result);
        }
Ejemplo n.º 4
0
 public static extern IntPtr pixaGetPix(IntPtr pixa, int index, PixArrayAccessType accesstype);
Ejemplo n.º 5
0
 internal static extern IntPtr boxaGetBox(HandleRef boxa, int index, PixArrayAccessType accesstype);
Ejemplo n.º 6
0
 internal static extern IntPtr pixaGetPix(HandleRef pixa, int index, PixArrayAccessType accesstype);
Ejemplo n.º 7
0
 internal static extern int pixaAddPix(HandleRef pixa, HandleRef pix, PixArrayAccessType copyflag);