Home > Net >  The problem of high CPU usage, the great god
The problem of high CPU usage, the great god

Time:09-21




///& lt; summary>
///byte [] to a BitmapImage
///& lt;/summary>
///& lt; Param name="byteArray containing" & gt;
///& lt; Returns>
Public static BitmapImage ToBitmapImage (byte [] byteArray containing)
{
BitmapImage BMP=null;
Try
{
BMP=new BitmapImage ();
BMP. BeginInit ();
BMP. CacheOption=BitmapCacheOption. onl oad;
BMP. StreamSource=new MemoryStream (byteArray containing);
BMP. EndInit ();
BMP. Freeze ();
}
Catch
{
BMP=null;
}

Return BMP.

}

CodePudding user response:

Top

CodePudding user response:

Solution to see [WPF use unsafe code fast transfer from an array of WriteableBitmap] (https://blog.lindexi.com/post/WPF-%E4%BD%BF%E7%94%A8%E4%B8%8D%E5%AE%89%E5%85%A8%E4%BB%A3%E7%A0%81%E5%BF%AB%E9%80%9F%E4%BB%8E%E6%95%B0%E7%BB%84%E8%BD%AC-WriteableBitmap.html)

CodePudding user response:

The other image processing can be in a background thread processing

Task. Run (()=& gt;
{
//add your code here
});

CodePudding user response:

Ok, thank you bosses try me
  •  Tags:  
  • C #
  • Related