ImageGlass.Library.Image.ExifThumbReader.convertFromMemory C# (CSharp) Method

convertFromMemory() private static method

Converts the IntPtr buffer to a property item and then converts its value to a Drawing.Image item
private static convertFromMemory ( IntPtr thumbData ) : System.Drawing.Image
thumbData System.IntPtr
return System.Drawing.Image
        private static System.Drawing.Image convertFromMemory(IntPtr thumbData)
        {
            propertyItemInternal prop =
                (propertyItemInternal)Marshal.PtrToStructure
                (thumbData, typeof(propertyItemInternal));

            // The image data is in the form of a byte array. Write all
            // the bytes to a stream and create a new image from that stream
            byte[] imageBytes = prop.Value;
            MemoryStream stream = new MemoryStream(imageBytes.Length);
            stream.Write(imageBytes, 0, imageBytes.Length);

            return System.Drawing.Image.FromStream(stream);
        }