签名板发送空
我使用的是签名板和 SkiaSharp 的画布,但是当我在用户绘制后发送并编码到 base 64 时,服务器上只显示一个空画布
async void OnSaveButtonClicked(object sender, EventArgs args)
{
using (SKImage image = SKImage.FromBitmap(saveBitmap))
{
try
{
SKData data = image.Encode(SKEncodedImageFormat.Png, 100);
var bytesImg = data.ToArray();
string imageBase64 = Convert.ToBase64String(bytesImg);
var respuesta = await this.ApiService.PostSignature(
this.url,
this.Id,
imageBase64
);
在服务上发送的方法... public async Task PostSignature(string urlBase, string folio, string imageBase64) { try { var client = new HttpClient(); var response = await client.PostAsync(urlBase, new StringContent(string.Format("idReporte={0}&imgFirma={1}", folio, imageEncoded), Encoding.UTF8, "application/x-www-form-urlencoded" ));
if (!response.IsSuccessStatusCode)
{
return response.ToString();
}
else
{
var result = await response.Content.ReadAsStringAsync();
return result;
}
}
catch
{
return null;
}
}
结束请求...
catch (Exception ex)
{
await Application.Current.MainPage.DisplayAlert(
"Error",
"Image Is not Send, error: " + ex.Message,
"OK"
);
}
finally
{
completedPaths.Clear();
inProgressPaths.Clear();
UpdateBitmap();
canvasView.InvalidateSurface();
}
图像为空,解码正常并加载到文件夹路径中。