12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- using System;
- using System.Collections.Generic;
- using Avalonia.Data.Converters;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Globalization;
- using System.IO;
- using Avalonia.Media.Imaging;
- using SixLabors.ImageSharp.Memory;
- using SixLabors.ImageSharp.Formats;
- using System.Collections;
- using System.IO.Compression;
- using SkiaSharp;
- namespace AvaloniaApplicationTestNew.Resources
- {
- internal class ImageConverter : IValueConverter
- {
- public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
- {
- if (value is byte[]) return new Bitmap(new MemoryStream((byte[])value));
- return null;
- }
- public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
- {
- if (value is Bitmap)
- {
- byte[] byteArray;
- Bitmap bitmap = (Bitmap)value;
- using (MemoryStream stream = new MemoryStream())
- {
- bitmap.Save(stream);
- byteArray = stream.ToArray();
- return byteArray;
- }
- }
- return null;
- }
- }
- }
|