Relinquish() public static method

public static Relinquish ( IntPtr value ) : void
value System.IntPtr
return void
Beispiel #1
0
 public IntPtr ToShortArray(int x, int y, int width, int height, string mapping)
 {
     using (INativeInstance mappingNative = UTF8Marshaler.CreateInstance(mapping))
     {
         IntPtr exception = IntPtr.Zero;
         IntPtr result;
         #if PLATFORM_AnyCPU
         if (NativeLibrary.Is64Bit)
         #endif
         #if PLATFORM_x64 || PLATFORM_AnyCPU
         result = NativeMethods.X64.PixelCollection_ToShortArray(Instance, (UIntPtr)x, (UIntPtr)y, (UIntPtr)width, (UIntPtr)height, mappingNative.Instance, out exception);
         #endif
         #if PLATFORM_AnyCPU
         else
         #endif
         #if PLATFORM_x86 || PLATFORM_AnyCPU
         result = NativeMethods.X86.PixelCollection_ToShortArray(Instance, (UIntPtr)x, (UIntPtr)y, (UIntPtr)width, (UIntPtr)height, mappingNative.Instance, out exception);
         #endif
         var magickException = MagickExceptionHelper.Create(exception);
         if (magickException == null)
         {
             return(result);
         }
         if (magickException is MagickErrorException)
         {
             if (result != IntPtr.Zero)
             {
                 MagickMemory.Relinquish(result);
             }
             throw magickException;
         }
         RaiseWarning(magickException);
         return(result);
     }
 }
   public IntPtr ToByteArray(int x, int y, int width, int height, string mapping)
   {
       using (INativeInstance mappingNative = UTF8Marshaler.CreateInstance(mapping))
       {
           IntPtr exception = IntPtr.Zero;
           IntPtr result;
 #if ANYCPU
           if (NativeLibrary.Is64Bit)
 #endif
 #if WIN64 || ANYCPU
           result = NativeMethods.X64.PixelCollection_ToByteArray(Instance, (UIntPtr)x, (UIntPtr)y, (UIntPtr)width, (UIntPtr)height, mappingNative.Instance, out exception);
 #endif
 #if ANYCPU
           else
 #endif
 #if !WIN64 || ANYCPU
           result = NativeMethods.X86.PixelCollection_ToByteArray(Instance, (UIntPtr)x, (UIntPtr)y, (UIntPtr)width, (UIntPtr)height, mappingNative.Instance, out exception);
 #endif
           MagickException magickException = MagickExceptionHelper.Create(exception);
           if (MagickExceptionHelper.IsError(magickException))
           {
               if (result != IntPtr.Zero)
               {
                   MagickMemory.Relinquish(result);
               }
               throw magickException;
           }
           RaiseWarning(magickException);
           return(result);
       }
   }
Beispiel #3
0
 public IntPtr WriteBlob(MagickImage image, MagickSettings settings, out UIntPtr length)
 {
     using (INativeInstance settingsNative = MagickSettings.CreateInstance(settings))
     {
         IntPtr exception = IntPtr.Zero;
         IntPtr result;
         if (NativeLibrary.Is64Bit)
         {
             result = NativeMethods.X64.MagickImageCollection_WriteBlob(MagickImage.GetInstance(image), settingsNative.Instance, out length, out exception);
         }
         else
         {
             result = NativeMethods.X86.MagickImageCollection_WriteBlob(MagickImage.GetInstance(image), settingsNative.Instance, out length, out exception);
         }
         MagickException magickException = MagickExceptionHelper.Create(exception);
         if (MagickExceptionHelper.IsError(magickException))
         {
             if (result != IntPtr.Zero)
             {
                 MagickMemory.Relinquish(result);
             }
             throw magickException;
         }
         RaiseWarning(magickException);
         return(result);
     }
 }
        internal static string NativeToManagedAndRelinquish(IntPtr nativeData)
        {
            string result = NativeToManaged(nativeData);

            MagickMemory.Relinquish(nativeData);

            return(result);
        }
Beispiel #5
0
        /// <summary>
        /// Returns the values of the pixels as an array.
        /// </summary>
        ///<param name="x">The X coordinate of the area.</param>
        ///<param name="y">The Y coordinate of the area.</param>
        ///<param name="width">The width of the area.</param>
        ///<param name="height">The height of the area.</param>
        ///<param name="mapping">The mapping of the pixels (e.g. RGB/RGBA/ARGB).</param>
        public byte[] ToByteArray(int x, int y, int width, int height, string mapping)
        {
            Throw.IfNullOrEmpty("mapping", mapping);

            CheckArea(x, y, width, height);
            IntPtr nativeResult = _NativeInstance.ToByteArray(x, y, width, height, mapping);

            byte[] result = ByteConverter.ToArray(nativeResult, width * height * mapping.Length);
            MagickMemory.Relinquish(nativeResult);
            return(result);
        }
Beispiel #6
0
        public ushort[] ToShortArray(int x, int y, int width, int height, string mapping)
        {
            Throw.IfNullOrEmpty(nameof(mapping), mapping);

            CheckArea(x, y, width, height);
            IntPtr nativeResult = _NativeInstance.ToShortArray(x, y, width, height, mapping);

            ushort[] result = ShortConverter.ToArray(nativeResult, width * height * mapping.Length);
            MagickMemory.Relinquish(nativeResult);
            return(result);
        }
        public virtual ushort[]? ToShortArray(int x, int y, int width, int height, string mapping)
        {
            var nativeResult = IntPtr.Zero;

            try
            {
                nativeResult = _nativeInstance.ToShortArray(x, y, width, height, mapping);
                return(ShortConverter.ToArray(nativeResult, width * height * mapping.Length));
            }
            finally
            {
                MagickMemory.Relinquish(nativeResult);
            }
        }
Beispiel #8
0
        public virtual byte[] ToByteArray(int x, int y, int width, int height, string mapping)
        {
            var nativeResult = IntPtr.Zero;

            byte[] result = null;

            try
            {
                nativeResult = _nativeInstance.ToByteArray(x, y, width, height, mapping);
                result       = ByteConverter.ToArray(nativeResult, width * height * mapping.Length);
            }
            finally
            {
                MagickMemory.Relinquish(nativeResult);
            }

            return(result);
        }
Beispiel #9
0
        public virtual ushort[] ToShortArray(int x, int y, int width, int height, string mapping)
        {
            Throw.IfNullOrEmpty(nameof(mapping), mapping);

            IntPtr nativeResult = IntPtr.Zero;

            ushort[] result = null;

            try
            {
                nativeResult = _nativeInstance.ToShortArray(x, y, width, height, mapping);
                result       = ShortConverter.ToArray(nativeResult, width * height * mapping.Length);
            }
            finally
            {
                MagickMemory.Relinquish(nativeResult);
            }

            return(result);
        }
Beispiel #10
0
        /// <summary>
        /// Returns the values of the pixels as an array.
        /// </summary>
        /// <param name="x">The X coordinate of the area.</param>
        /// <param name="y">The Y coordinate of the area.</param>
        /// <param name="width">The width of the area.</param>
        /// <param name="height">The height of the area.</param>
        /// <param name="mapping">The mapping of the pixels (e.g. RGB/RGBA/ARGB).</param>
        /// <returns>A <see cref="byte"/> array.</returns>
        public byte[] ToByteArray(int x, int y, int width, int height, string mapping)
        {
            Throw.IfNullOrEmpty(nameof(mapping), mapping);

            CheckArea(x, y, width, height);
            IntPtr nativeResult = IntPtr.Zero;

            byte[] result = null;

            try
            {
                nativeResult = _nativeInstance.ToByteArray(x, y, width, height, mapping);
                result       = ByteConverter.ToArray(nativeResult, width * height * mapping.Length);
            }
            finally
            {
                MagickMemory.Relinquish(nativeResult);
            }

            return(result);
        }