Skip to content

WPF bitmap conversion code may need improvement #350

@swharden

Description

@swharden

Issue to be solved: I'm concerned about the code the WPF control uses to convert System.Drawing.Bitmap (the output of ScottPlot) to a System.Windows.Media.Imaging.BitmapImage (which a WPF Image control displays).

Current Implementation

https://github.com/swharden/ScottPlot/blob/608958d561931fa3134f3679ca139c4fed577246/src/ScottPlot.WPF/WpfPlot.xaml.cs#L129

https://github.com/swharden/ScottPlot/blob/608958d561931fa3134f3679ca139c4fed577246/src/ScottPlot.WPF/WpfPlot.xaml.cs#L103-L113

Concerns

  • The MemoryStream is not properly disposed
    • Should a single class-level memory stream be used (and reused?)
  • The old imagePlot.Source is not properly disposed
  • Is this function the best it can be otherwise, or is there a better way to do this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions