MemoryStream.CopyTo Not working

后端 未结 3 657
独厮守ぢ
独厮守ぢ 2021-01-08 00:38
TiffBitmapDecoder decoder = new TiffBitmapDecoder(imageStreamSource, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);

using (MemoryStream allFra         


        
相关标签:
3条回答
  • 2021-01-08 01:06

    After writing to ms, the position of ms is at its end. You have to seek to the beginning of the stream, e.g. with:

    ms.Seek(0,System.IO.SeekOrigin.Begin);
    

    After that ms.CopyTo is working correctly.

    0 讨论(0)
  • 2021-01-08 01:14

    Reset Position of ms to 0 after you fill it:

    enc.Save(ms);
    ms.Position = 0;
    ms.CopyTo(allFrameStream);
    

    From Stream.CopyTo

    Copying begins at the current position in the current stream

    0 讨论(0)
  • 2021-01-08 01:19

    Try executing allFrameStream.Position = 0; just before writing to the PDF.

    0 讨论(0)
提交回复
热议问题