private bool DownloadEvf()
        {
            if ((this.LiveViewDevice & EosLiveViewDevice.Host) == EosLiveViewDevice.None)
                return false;

            var memoryStream = IntPtr.Zero;
            var evfImage = IntPtr.Zero;
            try
            {
                this.Assert(Edsdk.EdsCreateMemoryStream(0, out memoryStream), "Failed to create memory stream.");
                this.Assert(Edsdk.EdsCreateEvfImageRefCdecl(memoryStream, out evfImage), "Failed to create evf image.");
                this.Assert(Edsdk.EdsDownloadEvfImageCdecl(this.Handle, evfImage), "Failed to download evf image.");

                var converter = new EosConverter();
                this.OnLiveViewUpdate(new EosMemoryImageEventArgs(converter.ConvertImageStreamToBytes(memoryStream)));
            }
            catch (EosException eosEx)
            {
                if (eosEx.EosErrorCode != EosErrorCode.DeviceBusy && eosEx.EosErrorCode != EosErrorCode.ObjectNotReady)
                    throw;
            }
            finally
            {
                if (evfImage != IntPtr.Zero)
                    Edsdk.EdsRelease(evfImage);
                if (memoryStream != IntPtr.Zero)
                    Edsdk.EdsRelease(memoryStream);
            }

            return true;
        }
 public EosImageEventArgs TransportInMemory(IntPtr directoryItem)
 {
     var directoryItemInfo = GetDirectoryItemInfo(directoryItem);
     var stream = CreateMemoryStream(directoryItemInfo.Size);
     try
     {
         Transport(directoryItem, directoryItemInfo.Size, stream, false);
         var converter = new EosConverter();
         return new EosMemoryImageEventArgs(converter.ConvertImageStreamToBytes(stream)){FileName = directoryItemInfo.szFileName};
     }
     finally
     {
         DestroyStream(ref stream);
     }
 }
        public EosImageEventArgs TransportInMemory(IntPtr directoryItem)
        {
            var directoryItemInfo = GetDirectoryItemInfo(directoryItem);
            var stream            = CreateMemoryStream(directoryItemInfo.Size);

            try
            {
                Transport(directoryItem, directoryItemInfo.Size, stream, false);
                var converter = new EosConverter();
                return(new EosMemoryImageEventArgs(converter.ConvertImageStreamToBytes(stream)));
            }
            finally
            {
                DestroyStream(ref stream);
            }
        }
 public EosMemoryImageEventArgs TransportInMemory(IntPtr directoryItem, IntPtr context)
 {
     var directoryItemInfo = GetDirectoryItemInfo(directoryItem);
     var stream = CreateMemoryStream(directoryItemInfo.Size);
     try
     {
         Edsdk.EdsSetProgressCallback(stream, progress, Edsdk.EdsProgressOption.Periodically, context);
         Transport(directoryItem, directoryItemInfo.Size, stream, false);
         var converter = new EosConverter();
         return new EosMemoryImageEventArgs(converter.ConvertImageStreamToBytes(stream)){FileName = directoryItemInfo.szFileName};
     }
     finally
     {
         DestroyStream(ref stream);
     }
 }
        private bool DownloadEvf()
        {
            // Do not download if pauseUpdate requested
            if (_pauseLiveViewRequested)
                return true;

            if ((this.LiveViewDevice & EosLiveViewDevice.Host) == EosLiveViewDevice.None || _cancelLiveViewRequested)
                return false;

            lock (_locker)
            {
                var memoryStream = IntPtr.Zero;
                try
                {
                    Util.Assert(Edsdk.EdsCreateMemoryStream(0, out memoryStream), "Failed to create memory stream.");
                    using (var image = EosLiveImage.CreateFromStream(memoryStream))
                    {
                        Util.Assert(Edsdk.EdsDownloadEvfImage(this.Handle, image.Handle),
                                    "Failed to download evf image.");

                        var converter = new EosConverter();
                        this.OnLiveViewUpdate(
                            new EosLiveImageEventArgs(converter.ConvertImageStreamToBytes(memoryStream))
                                {
                                    Zoom = image.Zoom,
                                    ZommBounds = image.ZoomBounds,
                                    ImagePosition = image.ImagePosition,
                                    ImageSize = image.Size
                                    //Histogram = image.Histogram,

                                });

                    }
                }
                catch (EosException eosEx)
                {
                    //if (eosEx.EosErrorCode != EosErrorCode.DeviceBusy && eosEx.EosErrorCode != EosErrorCode.ObjectNotReady)
                    //    throw;
                }
                finally
                {
                    if (memoryStream != IntPtr.Zero)
                        Edsdk.EdsRelease(memoryStream);
                }
            }
            return true;
        }
        public EosMemoryImageEventArgs TransportInMemory(IntPtr directoryItem, IntPtr context)
        {
            var directoryItemInfo = GetDirectoryItemInfo(directoryItem);
            var stream            = CreateMemoryStream(directoryItemInfo.Size);

            try
            {
                //Edsdk.EdsSetProgressCallback(stream, progress, Edsdk.EdsProgressOption.Periodically, context);
                Transport(directoryItem, directoryItemInfo.Size, stream, false);
                var converter = new EosConverter();
                return(new EosMemoryImageEventArgs(converter.ConvertImageStreamToBytes(stream))
                {
                    FileName = directoryItemInfo.szFileName
                });
            }
            finally
            {
                DestroyStream(ref stream);
            }
        }
        public bool DownloadEvfInternal()
        {
            var memoryStream = IntPtr.Zero;
            try
            {
                Edsdk.EdsCreateMemoryStream(0, out memoryStream);
                using (var image = EosLiveImage.CreateFromStream(memoryStream))
                {
                    Edsdk.EdsDownloadEvfImage(this.Handle, image.Handle);

                    var converter = new EosConverter();
                    this.OnLiveViewUpdate(
                        new EosLiveImageEventArgs(converter.ConvertImageStreamToBytes(memoryStream))
                        {
                            Zoom = image.Zoom,
                            ZommBounds = image.ZoomBounds,
                            ImagePosition = image.ImagePosition,
                            ImageSize = image.Size
                            //Histogram = image.Histogram,

                        });

                }
            }
            catch (EosException eosEx)
            {
                //if (eosEx.EosErrorCode != EosErrorCode.DeviceBusy && eosEx.EosErrorCode != EosErrorCode.ObjectNotReady)
                //    throw;
            }
            finally
            {
                if (memoryStream != IntPtr.Zero)
                    Edsdk.EdsRelease(memoryStream);
            }
            return true;
        }