簡體   English   中英

在將圖像作為Base64 Xamarin表單發送到API之前將其翻轉

[英]flip image in before send it to API as Base64 Xamarin forms

我從設備中選擇了一個圖像並且鏡像了這是正常的但是我想在將其發送到API之前將其水平翻轉,以便在該鏡像未經鏡像之后進行預覽,並在base64字符串圖像上執行此操作。

但是,您尚未發布所有信息。 在Xamarin Forms Platform中,您可以使用FFImageLoading插件來支持您正在尋找的轉換。 IT支持:

  • FlipTransformation
  • RotateTransformation

點擊鏈接在這里找到他們的實現: https//github.com/luberda-molinet/FFImageLoading/blob/master/samples/ImageLoading.Forms.Sample/Shared/Pages/Transformations/FlipTransformationPage.xaml

你的問題沒有清楚地解釋你想做什么。你可以用更多細節更新它,你想把什么類型轉換成什么類型​​First.Whatever,我展示了一個可能的答案。

base64字符串的圖像路徑

// provide read access to the file
FileStream fs = new FileStream(media.Path, FileMode.Open,FileAccess.Read);
// Create a byte array of file stream length
byte[] ImageData = new byte[fs.Length];
//Read block of bytes from stream into the byte array
fs.Read(ImageData,0,System.Convert.ToInt32(fs.Length));
//Close the File Stream
fs.Close();
string _base64String = Convert.ToBase64String (ImageData);

base64字符串到byte []

byte[] data = Convert.FromBase64String (FileRespone);

我過去常常將圖像翻轉為位圖而不是Android中的Base64 https://acomputerengineer.wordpress.com/2016/06/07/flip-imagebitmap-horizo​​ntally-and-vertically-in-android/

在IOS中:
如何水平翻轉UIImage?

UIImage sourceImage = uiImage;//[UIImage imageNamed: @"whatever.png"];

           UIImage flippedImage = sourceImage.GetImageFlippedForRightToLeftLayoutDirection();
               //[UIImage imageWithCGImage: sourceImage.CGImage    scale: sourceImage.scale  orientation: UIImageOrientationUpMirrored];

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM