티스토리 뷰
Xamarin.Forms Essentials Camera Stream To Byte then Using SkiaSharp Image Size Down
NicSub 2021. 2. 14. 23:24Xamarin.Forms Essentials Camera Stream To BMP >> SkiaSharp Use FileFormat Jpg or Png then Reduce File Size Down
카메라 이미지(Raw) Stream(15~18Mb) ->SkiaSharp BMP 파일 변환 -> SkiaSharp Jpg Encoding image (254Kb~1Mb)
SkiaSharp 2.80.3 Bug: SKBitmap.Decode() == always null error
// SKData encodedData = Simage.Encode(SKEncodedImageFormat.Jpeg, 100);
async Task TakePhotoAsync()
{
try
{
if (!MediaPicker.IsCaptureSupported)
{
return;
}
var file = await MediaPicker.CapturePhotoAsync(new MediaPickerOptions
{
Title = DateTime.Now.ToString("yyyyMMddhhmmsss"),
}).ConfigureAwait(true);
await LoadPhotoAsync(file);
}
catch (Exception ex)
{
Console.WriteLine($"CapturePhotoAsync THREW: {ex.Message}");
}
}
async Task LoadPhotoAsync(FileResult photo)
{
try
{
if (photo == null)
{
return;
}
var newFile = Path.Combine(FileSystem.CacheDirectory, photo.FileName);
byte[] imageByte = null;
using (var stream = await photo.OpenReadAsync())
{
using (var newStream = File.OpenWrite(newFile))//newFile))
{
await stream.CopyToAsync(newStream);
}
using (FileStream newStream2 = File.Open(newFile, FileMode.Open, FileAccess.ReadWrite))
{
try
{
using var imgStream = new SKManagedStream(newStream2);
using var skData = SKData.Create(newStream2);
using var codec = SKCodec.Create(skData);
SKImage _Skimage = SKImage.FromEncodedData(skData);
using (SKData p = _Skimage.Encode(SKEncodedImageFormat.Jpeg, 25))
{
imageByte = p.ToArray();
}
}
catch (Exception Ex)
{
Console.WriteLine($"CapturePhotoAsync Err:" + Ex.Message);
return;
}
}
}
// Photo File image view
image2.Source = FileImageSource.FromFile(newFile);
string Essential_file_name = DateTime.Now.ToString("yyyyMMddhhmmsss") + ".jpg";
if (imageByte is null)
{
}
else
{
// 사진 저장.
Xamarin.Essentials.Preferences.Set(Essential_file_name, Convert.ToBase64String(imageByte));
}
}
catch (Exception Ex)
{
Console.WriteLine("Load Image ERROR:" + Ex.Message);
}
}
_________________________
ASP.NET Example code for core to implement captcha with skiashrpdeveloppaper.com/asp-net-example-code-for-core-to-implement-captcha-with-skiashrp/
ASP.NET Example code for core to implement captcha with skiashrp - Develop Paper
preface This paper does not implement a completed captcha sample, but provides another idea of using the drawing API under the current. Net core 2.0, and shows it in the form of a simple demo. Skia Skia is an open source 2D graphics library, which provides
developpaper.com
](https://developpaper.com/asp-net-example-code-for-core-to-implement-captcha-with-skiashrp/)
'Xamarin' 카테고리의 다른 글
Grid Chidren.Add (0) | 2021.03.15 |
---|---|
2021.03.03 8.9.1651 update Apple SDK 를 찾지 못하는 현상 (0) | 2021.03.04 |
CarouselView CurrentItem Entry Item Text Approach (0) | 2021.01.24 |
미친짓을 3주간 했구나. (0) | 2021.01.05 |
DatePicker Format String = 2020-12-29(화) (0) | 2020.12.29 |
- Total
- Today
- Yesterday
- Xamarin.Ios Firebase Phone Auth
- Embeded 한글Font적용
- 서버 수준의 URN 필터
- Windows IIS FTP 디렉토리 목록 오류
- Xamarin.Ios Firebase Phone User Add
- ClickOnce 인증서 인증기간 변경
- 암호 마스터키
- WPF Scrollviewer in ScrollViwer
- c# Encrypt / Decrypt
- Xamarin Firebase Phone User Add
- GetCellContent CheckBox Value
- WPF Datagrid Cell Value Change
- Label Text LineBreak in Xaml
- Xamarin Firebase Phone Auth
- Microcharts
- Entry '' has empty native path
- Xamarin SMS OTP Send
- Xamarin.Ios Firebase Phone SMS OTP Send
- FileStream Add Byte
- SkiaSharp
- 연산자 뒤에 피연산자가 없습니다.
- Linux SSH Multi Computer Join
- Xamarin reCAPTCHA
- Xamarin.Forms
- WPF Excel Export Microsoft.Office.Interop 성능향상(열 기준으로 복사)
- WPF Textbox
- C# LINQ Left join
- ssl_client_socket_impl.cc
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |