Exemplo n.º 1
0
        /// <summary>
        /// Read raw data into <paramref name="buffer"/> from a file on the disk or in a .pak file, without endian conversion.
        /// </summary>
        /// <returns>The amount of bytes read.</returns>
        /// <param name="handle">Handle to the file.</param>
        /// <param name="buffer">Buffer that contains the read data.</param>
        /// <param name="length">Length of the data to be read.</param>
        public static uint Read(CryPakFile handle, byte[] buffer, uint length)
        {
            if (handle == null)
            {
                throw new ArgumentNullException(nameof(handle));
            }

            if (buffer == null)
            {
                throw new ArgumentNullException(nameof(buffer));
            }

            if (length == 0)
            {
                throw new ArgumentOutOfRangeException(nameof(length), "Buffer length has to be greater than 0.");
            }

            using (var pinner = new AutoPinner(buffer))
            {
                var cryPakHandle = GetCryPakHandle();
                var dataHandle   = new HandleRef(pinner.Handle, pinner.Handle.AddrOfPinnedObject());
                var fileHandle   = GetFileHandle(handle.NativeHandle);

                var bytesRead = GlobalPINVOKE.ICryPak_FReadRaw(cryPakHandle, dataHandle, sizeof(byte), length, fileHandle);

                return(bytesRead);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Frees the pinned buffer.
 /// </summary>
 private void CleanupPinners()
 {
     if (this.InputSessionPinner != null)
     {
         this.InputSessionPinner.Dispose();
         this.InputSessionPinner = null;
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Frees the pinned buffer
 /// </summary>
 void CleanupPinners()
 {
     if (_inputSessionPinner != null)
     {
         _inputSessionPinner.Dispose();
         _inputSessionPinner = null;
     }
 }
        /// <summary>
        /// SendImageEmbeded sends an "Image Embedded" annotation to the handler.
        /// </summary>
        /// <param name="handler">The handler.</param>
        /// <param name="oiGroup">The group.</param>
        /// <param name="oiIndex">The index.</param>
        private static void SendImageEmbeded(
            IWangAnnotationHandler handler, string oiGroup, string oiIndex, int[] bounds, bool transparent,
            WangRotation rotation, string filename, byte[] dib)
        {
            // TODO - David Ometto - 2016-11-22 - Translate to GdPicture.NET proper annotation type.
            // Please see in detail the parameters that are just ignored for the moment.

            using (AutoPinner autoPinner = new AutoPinner(dib))
            {
                handler.AddEmbeddedImageAnnot(bounds[WangAnnotationTranslation.LeftIndex],
                                              bounds[WangAnnotationTranslation.TopIndex],
                                              bounds[WangAnnotationTranslation.RightIndex] - bounds[WangAnnotationTranslation.LeftIndex],
                                              bounds[WangAnnotationTranslation.BottomIndex] - bounds[WangAnnotationTranslation.TopIndex],
                                              autoPinner);
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// Frees the pinned buffer
 /// </summary>
 void CleanupPinners()
 {
     if (_inputSessionPinner != null)
     {
         _inputSessionPinner.Dispose();
         _inputSessionPinner = null;
     }
 }
Exemplo n.º 6
0
 public ud()
 {
     _inputSessionPinner = new AutoPinner(inp_sess);
 }
Exemplo n.º 7
0
 public ud()
 {
     _inputSessionPinner = new AutoPinner(inp_sess);
 }