C# 中写得很不错的一段代码摘出来
2021-05-12 07:28
标签:idt image wan eid 一段 ted file bin ffline C# 中写得很不错的一段代码摘出来 标签:idt image wan eid 一段 ted file bin ffline 原文地址:http://www.cnblogs.com/qianxinxu/p/7577525.htmlprivate void LikeMyworkEvent(EditedImg img, bool islike) //点赞自己的作品
{
if (ApplicationModel.userInfo != null)
{
OffLineController.Instance.OffLine();
return;
}
if(img.workId == null || img.workId == "") //这个作品还没有自己的作品id,需要先上传
{
UploadUserEditedFileCo(img , image => { LikeMyworkEvent(image, islike);});
}
else
{
NetLoadcontroller.Instance.RequestUrlWidthMethodGet(
ApplicationModel.HOST + "/image/like?uid=" + ApplicationModel.userInfo.Uid +
"&authorUid=" + ApplicationModel.userInfo.Uid + "&workId=" + img.workId + "&action=" + GetActionStrByBool(islike) + "&sessionId=" + ApplicationModel.userInfo.SessionId,
(json, isSuccess) => { LikeRequestCallback(json, isSuccess); }
);
}
}
public IEnumerator UploadUserEditedFileCo(EditedImg img, Action
private WWWForm GetPostFormByEditedImg(EditedImg img)
{
WWWForm postForm = new WWWForm();
postForm.AddField("imageId", img.imageId);
postForm.AddBinaryData("clickPos", GetClickPosFromImg(img.imageId).EncodeToPNG(), img.imageId + "_pos");
postForm.AddBinaryData("palette", GetPaletteFromImg(img.imageId).EncodeToPNG(), img.imageId + "_ed");
postForm.AddField("deviceId", ApplicationModel.device_id);
postForm.AddField("uid", ApplicationModel.userInfo.Uid);
postForm.AddBinaryData("finalImg", GetTex2dFromImg(img.imageId).EncodeToPNG(), img.imageId);
postForm.AddField("sessionId", ApplicationModel.userInfo.SessionId);
return postForm;
}
private void UploadUserEditedFileCallback(string json, bool isSuccess, EditedImg img, Action