Merge MKDT_0002
This commit is contained in:
32
MarketData/MarketDataLib/CNNProcessing/BitmapExtensions.cs
Executable file
32
MarketData/MarketDataLib/CNNProcessing/BitmapExtensions.cs
Executable file
@@ -0,0 +1,32 @@
|
||||
using System.IO;
|
||||
//using System.Linq;
|
||||
// using MarketData.Utils;
|
||||
//using System.Drawing.Imaging;
|
||||
//using System.Runtime.InteropServices;
|
||||
//using System.Drawing;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace MarketData.CNNProcessing
|
||||
{
|
||||
public static class BitmapExtensions
|
||||
{
|
||||
// This call is used to generate the training, test, and validation bitmaps..
|
||||
// I noticed a large difference in the accuracy or the model when the quality parameter is 100.
|
||||
// I therefore intentionally not using EncoderParameters to specify quality but instead taking the default quality.
|
||||
public static void SaveJPG100(this SKBitmap bitmap, string filename)
|
||||
{
|
||||
if(File.Exists(filename))File.Delete(filename);
|
||||
using FileStream stream = new FileStream(filename, FileMode.Create, FileAccess.Write);
|
||||
using SKImage image = SKImage.FromBitmap(bitmap);
|
||||
using SKData encodedImage = image.Encode(SKEncodedImageFormat.Jpeg,100);
|
||||
encodedImage.SaveTo(stream);
|
||||
}
|
||||
|
||||
public static void SaveJPG100(this SKBitmap bitmap, Stream stream)
|
||||
{
|
||||
using SKImage image = SKImage.FromBitmap(bitmap);
|
||||
using SKData encodedImage = image.Encode(SKEncodedImageFormat.Jpeg,100);
|
||||
encodedImage.SaveTo(stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user