wpf - XPS from FlowDocument Rendering bug in Images -


This will be a long post

target

current scenario

  1. The image is properly added (keeps the format), but only the first one cache, while keeping the original images (no change)

    Broken, only 1 image is embedded in XPS and used for all images

  2. All images have been added and correct, but in PNG Are Riwartit.

  3. At least showcase / problem entertainment code

Import System.Windows.Documents Import System.Windows.Documents.Serialization Import System.Windows.Xps.Packaging Import System.Windows.Xps Import System.IO Import System.IO.Packaging Import System.Windows.Markup Import System.Windows.Media.Imaging Import System.Windows.Media Import System.Windows.Controls Module Module1 Sub Main () Presented () End Sub Sub Submission () Using Image1 = IO.File.OpenRead ("Image1.jpg"), Image2 = IO.File.OpenRead ("image2.png"), file = IO.File.Create ("asdf.xps"), pack = Package.Open (File, FileMode.Create) New XpsDocument (Pack) as D, Writer as XpsDocumentWriter = XpsDocument.CreateXpsDocumentW As riter (d) Dim xpsVisWriter as SerializerWriterCollator = writer.CreateVisualsCollator () Dim x New Flow document x.PageWidth = 100 x.ColumnWidth = x.PageWidth new section as DIM DirectCast (x, IAddChild). addChild (s) s.BreakPageBefore = true dim P new paragraph (as) DirectCast (s, IAddChild) .AddChild (P) I dimmed new image DirectCast (P, IAddChild) .AddChild (i) i.Source = GetImage (Image1) dim i2 new image DirectCast (P, IAddChild) .AddChild (as i2) i2.Source = GetImage (Image2) dim Paginator = DirectCast (x, IDocumentPaginatorSource) = as .DocumentPaginator dim pageIndex integer 0 While not the paginator.IsPageCountValid OrElse paginator PageCount & gt; pageIndex dim page as DocumentPage = paginator.GetPage (pageIndex) xpsVisWriter.Write (page.Visual) pageIndex + = 1 end while xpsVisWriter.EndBatchWrite () end-use End Sub function GetImage (Section as) ImageSource dim results as as ImageSource = BitmapFrame .Create (stream, BitmapCreateOptions.PreservePixelFormat or BitmapCreateOptionskIgnoreImageCache, BitmapCacheOptionkNone) "runs the line, scenario 2 occures, otherwise scenario 1" results = BitmapFrame.Create (results) return Result ending function termination module

I no longer know that What to do with the truth. Tried to enable / disable all possible caches.

I have not made any visible original, but I have a similar problem with C # my GetImage Try returning to a bitmap image instead of ImageSource in the method


Comments