From 82eba47c84106e286d37ecdb9fc564cc9b80e39f Mon Sep 17 00:00:00 2001
From: wei <kaede@kaededeMacBook-Air.local>
Date: 星期三, 17 十一月 2021 17:19:24 +0800
Subject: [PATCH] cct 色温调节
---
HDL_ON/Common/ImageUtlis.cs | 123 ++++++++++++++++++++++++++++++++++-------
1 files changed, 102 insertions(+), 21 deletions(-)
diff --git a/HDL_ON/Common/ImageUtlis.cs b/HDL_ON/Common/ImageUtlis.cs
index 83e55bd..918483d 100644
--- a/HDL_ON/Common/ImageUtlis.cs
+++ b/HDL_ON/Common/ImageUtlis.cs
@@ -2,6 +2,7 @@
using Shared;
using HDL_ON.DAL.Server;
using System.IO;
+using HDL_ON.Common;
namespace HDL_ON
{
@@ -162,6 +163,7 @@
/// <summary>
/// 閫氳繃鍥剧墖璺緞涓嬭浇鍥剧墖
+ /// 閽堝浣忓畢锛屼娇鐢ㄤ綇瀹呭煙鍚嶆湇鍔″櫒
/// </summary>
public byte[] GetImageDownloadUrl(string imageKey)
{
@@ -170,6 +172,31 @@
imageKey = imageKey,
});
var revertObj = HttpUtil.RequestHttpsPostFroHome(NewAPI.API_POST_GetImageUrl, requestJson);
+ if (revertObj.Code == StateCode.SUCCESS)
+ {
+ if (revertObj.Data != null)
+ {
+ if (!string.IsNullOrEmpty(revertObj.Data.ToString()))
+ {
+ var url = revertObj.Data.ToString();
+ return HttpUtil.HttpsDownload(url);
+ }
+ }
+ }
+ return null;
+ }
+
+ /// <summary>
+ /// 閫氳繃鍥剧墖璺緞涓嬭浇鍥剧墖
+ /// 閽堝鐢ㄦ埛澶村儚鎸囧畾鐢ㄦ埛璺緞绛�
+ /// </summary>
+ public byte[] GetImageDownloadUrlWithRegionUrl(string imageKey, string regionUrl)
+ {
+ var requestJson = HttpUtil.GetSignRequestJson(new GetImageUrlObj()
+ {
+ imageKey = imageKey,
+ });
+ var revertObj = HttpUtil.RequestHttpsPost(NewAPI.API_POST_GetImageUrl, requestJson, regionUrl);
if (revertObj.Code == StateCode.SUCCESS)
{
if (revertObj.Data != null)
@@ -326,40 +353,94 @@
}
}
- /// <summary>
- /// 鑾峰彇鎷兼帴鐢ㄦ埛澶村儚鐨処mageKey瑙勫垯
- /// </summary>
- /// <returns></returns>
- public string GetHeadImageKey(string userId)
- {
- return "ON" + "_" + userId + "_" + HEADIMAGE;
- }
+
/// <summary>
- /// 鐢熸垚澶村儚涓婁紶瑙勫垯鍙傛暟
+ /// 2021-01-28
+ /// 鍔犺浇绗笁鏂瑰搧鐗宨con
/// </summary>
- /// <returns></returns>
- public UploadImageObj GetHeadImageUploadKeyObj(string userId)
+ /// <param name="imageKey">鍥剧墖璺緞銆佷簯绔笅杞藉浘鐗囩殑鏍囪瘑key</param>
+ /// <param name="imageView">闇�瑕佹樉绀哄浘鐗囩殑ImageView</param>
+ /// <param name="ignoreCache">鏄惁闇�瑕佸拷鐣ョ紦瀛�</param>
+ public void Load3tyBrandIconImages(string brandName, string imageKey, ImageView imageView)
{
- return new UploadImageObj()
+ try
{
- prefix = "ON",
- uid = userId,
- fileName = HEADIMAGE,
- };
+ System.Threading.Tasks.Task.Run(() =>
+ {
+ //byte[] imageBytes = GetImageDownloadUrl(imageKey);
+ //if (imageBytes != null)
+ //{
+ // WriteFileByBytes(imageKey, imageBytes);
+ // //2.3 涓嬭浇鎴愬姛锛屾樉绀哄苟缂撳瓨鏈湴
+ // Application.RunOnMainThread(() => {
+ // if (imageView != null)
+ // {
+ // imageView.ImageBytes = imageBytes;
+ // //Utlis.WriteLine("imageKey 鍔犺浇浜戠涓嬭浇鍥剧墖鎴愬姛");
+ // }
+ // });
+ //}
+
+ //var ddd = new Common.DownLoadImageAsync(imageKey,"1","1");
+ //ddd.StartDownloadImageAsync();
+
+ Action action = () => {
+ Application.RunOnMainThread(() =>
+ {
+ imageView.ImagePath = $"{brandName}.png";
+ });
+ };
+ FileUtlis.Files.DownLoadImage($"{brandName}.png", imageKey, action);
+
+ });
+ }
+ catch (Exception ex)
+ {
+ Utlis.WriteLine("imageKey 鍔犺浇鍥剧墖寮傚父 catch");
+ }
+ finally
+ {
+ }
}
+
+
+ // /// <summary>
+ ///// 鑾峰彇鎷兼帴鐢ㄦ埛澶村儚鐨処mageKey瑙勫垯
+ ///// </summary>
+ ///// <returns></returns>
+ //public string GetHeadImageKey(string userId)
+ // {
+ // return "ON" + "_" + userId + "_" + HEADIMAGE;
+ // }
+
+ ///// <summary>
+ ///// 鐢熸垚澶村儚涓婁紶瑙勫垯鍙傛暟
+ ///// </summary>
+ ///// <returns></returns>
+ //public UploadImageObj GetHeadImageUploadKeyObj(string userId)
+ //{
+ // return new UploadImageObj()
+ // {
+ // prefix = "Icon" + Utlis.GetTimestamp(),
+ // uid = userId,
+ // fileName = HEADIMAGE,
+ // };
+ //}
/// <summary>
/// 涓嬭浇鐢ㄦ埛澶村儚
/// </summary>
- /// <param name="userId"></param>
- /// <param name="ignoreCache">鏄惁蹇界暐缂撳瓨</param>
+ /// <param name="imageKey"></param>
+ /// <param name="ignoreCache">蹇界暐缂撳瓨</param>
+ /// <param name="regionUrl">鎸囧畾鏈嶅姟鍣ㄥ煙鍚�,浼犵┖涓轰娇鐢ㄥ綋鍓嶇敤鎴峰湴鍧�</param>
/// <returns></returns>
- public byte[] DownHeadImage(string userId, bool ignoreCache = false)
+ public byte[] DownHeadImageByImageKey(string imageKey, bool ignoreCache = false, string regionUrl = "")
{
try
{
- var imageKey = GetHeadImageKey(userId);
+ if (string.IsNullOrEmpty(imageKey)) return null;
+
byte[] imageBytes;
if (!ignoreCache && Exists(imageKey))
{
@@ -369,7 +450,7 @@
else
{
//浜戠涓嬭浇
- imageBytes = GetImageDownloadUrl(imageKey);
+ imageBytes = GetImageDownloadUrlWithRegionUrl(imageKey, regionUrl);
if(imageBytes != null)
{
//淇濆瓨鍒版湰鍦�
--
Gitblit v1.8.0