public void Update(AuthorDto item, IFormFile file) { var oldImageName = Get(item.Id).ImagePath; if (file != null && file.Length > 0) { var cropped = ImageTool.CropMaxSquare(Image.FromStream(file.OpenReadStream())); var resized = ImageTool.Resize(cropped, 500, 500); var uploads = Path.Combine(_configuration.WebRootPath, "pics\\Authors"); if (!string.IsNullOrEmpty(oldImageName)) { var oldPath = Path.Combine(uploads, oldImageName); if (File.Exists(oldPath)) { File.Delete(oldPath); } } var fileName = Guid.NewGuid() + Path.GetExtension(file.FileName); var filePath = Path.Combine(uploads, fileName); resized.Save(filePath); item.ImagePath = fileName; } else { item.ImagePath = oldImageName; } var author = _mapper.Map <AuthorDto, Author>(item); _repository.Update(author); _repository.Save(); }
private async void WindowLoaded(object sender, RoutedEventArgs e) { var songInfo = NowPlaying.PipeListener.staticpipelistener.LastPlayedSong; _songcache = songInfo?.Clone() as SongInfo; if (songInfo == null) { await this.ShowMessageAsync("メッセージ", "現在何も再生されていません。\n(注:アプリケーションがする前に再生されていた曲は取得できません)"); this.Close(); return; } var isource = new Func <BitmapSource>(() => { try { if (!songInfo.IsAlbumArtAvaliable()) { return(null); } return(ImageTool.ToImageSource(songInfo.GetAlbumArt())); } catch { return(null); } })(); AlbumArtImage.Source = isource; TweetTextBox.Text = Tsumugi.TweetConverter.SongInfoToString(ConfigStore.StaticConfig.TweetFormat, songInfo); }
public virtual void testSameSizeDiff() { ImageDiff diff = IMAGE_DIFFER.makeDiff(IMAGE_A_SMALL, IMAGE_B_SMALL); Matcher <Bitmap> matcher = ImageTool.equalImage(loadImage("img/expected/same_size_diff.png")); Assert.IsTrue(matcher.Matches(diff.getMarkedImage())); }
private void AnalyzeAll() { var tsk = Task.Factory.StartNew(() => { try { for (int cnt = 0; cnt < aligns.Count; cnt++) { if (cnt == 0) { continue; } cvm.Status = $"Analyzing file {cnt}/{aligns.Count}"; Diffs.Add(cnt, new List <int>()); for (int i = 1; i <= Math.Min(3, cnt + 1); i++) { Diffs[cnt].Add((int)(100.0 * ImageTool.GetPercentageDifference(System.IO.Path.Combine(path, aligns[cnt - 1]), System.IO.Path.Combine(path, aligns[cnt])))); } } } catch (Exception e) { MessageBox.Show($"Problem doing analysis {e.Message}", "Problem", MessageBoxButton.OK, MessageBoxImage.Exclamation); } finally { analysis_complete = true; } return; }); }
protected void Button1_Click(object sender, EventArgs e) { if (anh.Length < 0 || anh.Equals("")) { lbDisplay.Text = "Xin hãy upload ảnh rồi mới tìm kiếm!"; return; } Image1.ImageUrl = anh; String strPathImg = Server.MapPath("~/" + anh); DataTable dt = admin.dao.anh_caythuoc.getAllAnh(); DataTable dtNew = new DataTable(); dtNew.Columns.Add("Ma_Anh"); dtNew.Columns.Add("Ma_Cay"); dtNew.Columns.Add("Ten_Anh"); dtNew.Columns.Add("URL"); dtNew.Columns.Add("Percent"); foreach (DataRow r in dt.Rows) { String p = Server.MapPath("~/admin/" + r[3].ToString()); float difference = ImageTool.GetPercentageDifference(strPathImg, p); if ((difference * 100) < 50) { dtNew.Rows.Add(r[0], r[1], r[2], r[3], (difference * 100).ToString()); } } GridView1.DataSource = dtNew; GridView1.DataBind(); }
protected void btnCropAndSave_OnClick(object sender, EventArgs e) { var aImageTool = new ImageTool(); Stream fileLogo = null; string title = txtText.Value; if (fileUpload.HasFile) { fileLogo = fileUpload.PostedFile.InputStream; } Image image = aImageTool.DownloadImageFromUrl(imgContent.ImageUrl); int x = X.Value.Trim() != "" ? int.Parse(X.Value) : 0; X.Value = "0"; int y = Y.Value.Trim() != "" ? int.Parse(Y.Value) : 0; Y.Value = "0"; int w = W.Value.Trim() != "" ? int.Parse(W.Value) : image.Width; W.Value = "0"; int h = H.Value.Trim() != "" ? int.Parse(H.Value) : image.Height; H.Value = "0"; //string s = aImageTool.CropAndAddTitle(image, "test", Server.MapPath("~/Upload"), new Rectangle(x, y, w, h), // title, fileLogo); //imgResult.Text += ""; }
/// <summary> /// 注册所有工具的相应部分上下文 /// </summary> private void Init() { _cursor = new Dictionary <string, Cursor>(); _cursor["Tool_Drag"] = Cursors.Arrow; _cursor["Tool_Rectangle"] = Cursors.Cross; _cursor["Tool_Triangle"] = Cursors.Cross; _cursor["Tool_Image"] = Cursors.Cross; _cursor["Tool_QRCode"] = Cursors.Cross; _cursor["Tool_Circle"] = Cursors.Cross; _cursor["Tool_Text"] = Cursors.IBeam; _cursor["Tool_Line"] = Cursors.Cross; _toolType = new Dictionary <string, ToolType>(); _toolType["Tool_Drag"] = ToolType.Drag; _toolType["Tool_Rectangle"] = ToolType.Rectangle; _toolType["Tool_Triangle"] = ToolType.Triangle; _toolType["Tool_Image"] = ToolType.Image; _toolType["Tool_QRCode"] = ToolType.QRCode; _toolType["Tool_Circle"] = ToolType.Circle; _toolType["Tool_Text"] = ToolType.Text; _toolType["Tool_Line"] = ToolType.Line; _paintTool = new Dictionary <string, PaintToolBase>(); _paintTool["Tool_Line"] = new LineTool(); _paintTool["Tool_Drag"] = new DragTool(); _paintTool["Tool_Triangle"] = new TriangleTool(); _paintTool["Tool_Circle"] = new CircleTool(); _paintTool["Tool_Rectangle"] = new RectangleTool(); _paintTool["Tool_Image"] = new ImageTool(); _paintTool["Tool_Text"] = new TextTool(); }
public virtual ImageDiff makeDiff(Screenshot expected, Screenshot actual) { var diff = new ImageDiff(expected.getImage(), actual.getImage()); for (int i = 0; i < diff.getDiffImage().Width; i++) { for (int j = 0; j < diff.getDiffImage().Height; j++) { if (this.insideBothImages(i, j, expected.getImage(), actual.getImage())) { if (this.shouldCompare(i, j, expected, actual) && !ImageTool.rgbCompare(expected.getImage().GetPixel(i, j), actual.getImage().GetPixel(i, j), this.colorDistortion)) { diff.addDiffPoint(i, j); } else { diff.getDiffImage().SetPixel(i, j, expected.getImage().GetPixel(i, j)); } } else { this.setSharedPoint(i, j, expected, actual, diff); } } } return(diff); }
private void UpdatePlayingSongView(NowPlaying.SongInfo songInfo) { Dispatcher.Invoke(() => { var isource = new Func <BitmapSource>(() => { try { if (!songInfo.IsAlbumArtAvaliable()) { return(null); } return(ImageTool.ToImageSource(songInfo.GetAlbumArt())); } catch { return(null); } })(); SongImage.Source = isource; SongTitleLabel.Content = songInfo.Title; SongArtistLabel.Content = songInfo.Artist; SongAlbumLabel.Content = songInfo.Album; NothingPlayingGrid.Visibility = Visibility.Hidden; }); }
private void RefreshMemberInformation() { lblMemberCodeName.Content = string.Format("{0} - {1}", _viewModel.Member.MemberCode, _viewModel.Member.MemberName); imgPhoto.Source = ImageTool.CreateImageSourceFromBytes(_viewModel.Member.ContactInformation.Picture); var infoBuilder = new StringBuilder(); bool isMemberCanLoan = false; if (!string.IsNullOrEmpty(_viewModel.Member.MembershipType)) { infoBuilder.AppendFormat("{0} Member\n", _viewModel.Member.MembershipType); switch (_viewModel.Member.MembershipType) { case "Associate (Loaning)": case "Regular": isMemberCanLoan = true; break; } } if (_viewModel.Member.IsDamayanMember) { infoBuilder.AppendFormat("PTTK Member\n"); } blkMemberInformationSummary.Content = infoBuilder.ToString(); //borrower's buttons btnLoanApplication.IsEnabled = isMemberCanLoan; btnSpecialLoanApplication.IsEnabled = isMemberCanLoan; btnMakers.IsEnabled = isMemberCanLoan; btnSavingsDepositEntry.IsEnabled = true; btnTimeDepositEntry.IsEnabled = true; }
public IEnumerator screenshotAndCompare(String fileName) { string baseImageCompletePath = baseImageDirectory + fileName; string newImageCompletePath = refactorImageDirectory + fileName; if (isCreateBaseImages) { //Creating base image yield return(new WaitForSeconds(waitingTime)); ScreenCapture.CaptureScreenshot(baseImageCompletePath); yield return(new WaitForSeconds(waitingTime)); Assert.IsTrue(File.Exists(baseImageCompletePath), "Base Image should exist"); } else { yield return(new WaitForSeconds(waitingTime)); ScreenCapture.CaptureScreenshot(newImageCompletePath); yield return(new WaitForSeconds(waitingTime)); float difference = ImageTool.GetPercentageDifference(baseImageCompletePath, newImageCompletePath) * 100; // We don't require image if it is a mtach, so delete it if (difference == 0) { if (File.Exists(newImageCompletePath)) { File.Delete(newImageCompletePath); } } Assert.IsTrue(difference == 0, "Difference of " + difference + " % found in " + baseImageCompletePath + " vs " + newImageCompletePath); } }
private void RefreshDisplay() { DataContext = _member; TabItemContactInformation.DataContext = _member.ContactInformation; imgPhoto.Source = ImageTool.CreateImageSourceFromBytes(_member.ContactInformation.Picture); imgSignature.Source = ImageTool.CreateImageSourceFromBytes(_member.ContactInformation.Signature); }
public virtual void TestElementOutsideImageIndentCropper() { Screenshot screenshot = new IndentCropper(10).cropScreenshot(DifferTest.IMAGE_A_SMALL, new HashSet <Coords>(OUTSIDE_IMAGE)); var matcher = ImageTool.equalImage(DifferTest.loadImage("img/expected/outside_ic.png")); Assert.IsTrue(matcher.Matches(screenshot.getImage())); }
public static Bitmap generateLongBitmap(List <Bitmap> bitmaps, Rectangle selectRect) { if (bitmaps.Count == 0) { return(new Bitmap(10, 10)); } else if (bitmaps.Count == 1) { return(bitmaps[0]); } Bitmap longBitmap = new Bitmap(selectRect.Width, selectRect.Height * bitmaps.Count); Graphics g = Graphics.FromImage(longBitmap); // 将画布涂为白色(底部颜色可自行设置) g.FillRectangle(Brushes.White, new Rectangle(0, 0, longBitmap.Width, longBitmap.Height)); List <int> bitmapRowCRCList1, bitmapRowCRCList2, bitmapColmunCRCList, lastBitmapColmunCRCList; Bitmap bitmap = bitmaps[0]; bitmapColmunCRCList = ImageTool.GetBitmapCRCCode(bitmap, false); g.DrawImage(bitmap, 0, 0, bitmap.Width, bitmap.Height); int edgeIndex1 = 0, edgeIndex2 = 0, height = 0, img1Index = 0, img2Index = 0; for (int i = 1; i < bitmaps.Count; i++) { bitmap = bitmaps[i]; lastBitmapColmunCRCList = bitmapColmunCRCList; bitmapColmunCRCList = ImageTool.GetBitmapCRCCode(bitmap, false); ImageTool.FindMaxCommonEdge(bitmapColmunCRCList, lastBitmapColmunCRCList, ref edgeIndex1, ref edgeIndex2); bitmapRowCRCList1 = ImageTool.GetBitmapCRCCode(bitmaps[i - 1], true, edgeIndex1, edgeIndex2); bitmapRowCRCList2 = ImageTool.GetBitmapCRCCode(bitmap, true, edgeIndex1, edgeIndex2); if (ImageTool.FindMaxCommonList(bitmapRowCRCList1, bitmapRowCRCList2, ref img1Index, ref img2Index)) { height += img1Index; } else { height += bitmap.Height; img2Index = 0; } //g.DrawImage(bitmap, i*selectRect.Width, index, bitmap.Width, bitmap.Height); g.DrawImage(bitmap, new Rectangle(0, height, bitmap.Width, bitmap.Height - img2Index), new Rectangle(0, img2Index, bitmap.Width, bitmap.Height - img2Index), GraphicsUnit.Pixel); Console.WriteLine(string.Format("合并,i:{0},h:{1},i1:{2},i2:{3},e1;{4},e2:{5}", i, height, img1Index, img2Index, edgeIndex1, edgeIndex2)); } g.Dispose(); height += bitmap.Height; bitmap = new Bitmap(selectRect.Width, height); g = Graphics.FromImage(bitmap); g.FillRectangle(Brushes.White, new Rectangle(0, 0, bitmap.Width, bitmap.Height)); g.DrawImage(longBitmap, new Rectangle(0, 0, bitmap.Width, height), new Rectangle(0, 0, bitmap.Width, height), GraphicsUnit.Pixel); g.Dispose(); return(bitmap); }
//图片的融合 public void fuseImages(int index) { System.Drawing.Bitmap bitmapSource = new System.Drawing.Bitmap(keyFrames[index].ImageName); BitmapData data = bitmapSource.LockBits(new System.Drawing.Rectangle(0, 0, bitmapSource.Width, bitmapSource.Height), System.Drawing.Imaging.ImageLockMode.ReadWrite, System.Drawing.Imaging.PixelFormat.Format32bppArgb); int w = bitmapSource.Width, h = bitmapSource.Height; int bytes = w * h * 4; byte[] ArgbValues = new byte[bytes]; IntPtr ptr = data.Scan0; // Copy the RGB values into the array. System.Runtime.InteropServices.Marshal.Copy(ptr, ArgbValues, 0, bytes); for (int i = 0; i < fusePixel; i++) { for (int j = 0; j < h; j++) { int indexBmp = 4 * (data.Width * j + i); double rate = (double)i / (fusePixel - 1); ArgbValues[indexBmp + 3] = (byte)(ArgbValues[indexBmp + 3] * rate); } } System.Runtime.InteropServices.Marshal.Copy(ArgbValues, 0, ptr, bytes); System.Drawing.Bitmap bitmapTarget = new System.Drawing.Bitmap(bitmapSource.Width, bitmapSource.Height, bitmapSource.Width * 4, System.Drawing.Imaging.PixelFormat.Format32bppArgb, ptr); BitmapImage bitmapImage = ImageTool.getInstance().BitmapToImageSource(bitmapTarget); keyFrames[index].Image.Source = bitmapImage; if (isShowHalf) { keyFrames[index].CounterPartImage.Source = bitmapImage.Clone(); } bitmapSource.UnlockBits(data); //System.Drawing.Bitmap bitmapCounterPartSource = new System.Drawing.Bitmap(keyFrames[index].ImageName); //BitmapData dataCounterPart = bitmapCounterPartSource.LockBits(new System.Drawing.Rectangle(0, 0, bitmapCounterPartSource.Width, bitmapCounterPartSource.Height), // System.Drawing.Imaging.ImageLockMode.ReadWrite, System.Drawing.Imaging.PixelFormat.Format32bppArgb); ////int w = bitmapSource.Width, h = bitmapSource.Height; //int bytesCounterPart = w * h * 4; //byte[] ArgbValuesCounterPart = new byte[bytes]; //IntPtr ptrCounterPart = dataCounterPart.Scan0; //// Copy the RGB values into the array. //System.Runtime.InteropServices.Marshal.Copy(ptr, ArgbValues, 0, bytes); //for (int i = 0; i < fusePixel; i++) //{ // for (int j = 0; j < h; j++) // { // int indexBmp = 4 * (data.Width * j + i); // double rate = (double)i / (fusePixel - 1); // ArgbValues[indexBmp + 3] = (byte)(ArgbValues[indexBmp + 3] * rate); // } //} //System.Runtime.InteropServices.Marshal.Copy(ArgbValues, 0, ptr, bytes); //System.Drawing.Bitmap bitmapTarget = new System.Drawing.Bitmap(bitmapSource.Width, bitmapSource.Height, bitmapSource.Width * 4, System.Drawing.Imaging.PixelFormat.Format32bppArgb, ptr); //BitmapImage bitmapImage = ImageTool.getInstance().BitmapToImageSource(bitmapTarget); //keyFrames[index].Image.Source = bitmapImage; //bitmapSource.UnlockBits(data); }
/// <summary> /// 隐藏折线 /// </summary> private void HideLines() { Image[] images = GetImageArr(); for (int i = 0; i < images.Length; i++) { ImageTool.SetImageAlpha(images[i], 0); } }
public void Update(ImageTool imageTool) { if (imageTool != null && m_VideoController != null) { m_VideoController.DisplayCursorPositionDetails(new Point(imageTool.MouseX, imageTool.MouseY)); } }
protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e) { if (e.Property == SourceProperty) { ContentImage = ImageTool.GetByteImage(Source); } base.OnPropertyChanged(e); }
public virtual void testSetDiffColor() { ImageDiff diff = IMAGE_DIFFER.makeDiff(IMAGE_A_SMALL, IMAGE_B_SMALL); Matcher <Bitmap> matcher = ImageTool.equalImage(loadImage("img/expected/green_diff.png")); Assert.IsTrue(matcher.Matches(diff.withDiffColor(Color.Green).getMarkedImage())); }
public virtual void testIgnoredCoordsSame() { Screenshot a = this.createScreenshotWithSameIgnoredAreas(IMAGE_A_SMALL); Screenshot b = this.createScreenshotWithSameIgnoredAreas(IMAGE_B_SMALL); ImageDiff diff = IMAGE_DIFFER.makeDiff(a, b); Matcher <Bitmap> matcher = ImageTool.equalImage(loadImage("img/expected/ignore_coords_same.png")); Assert.IsTrue(matcher.Matches(diff.getMarkedImage())); }
public byte[] GetEnvironmentImageBytes() { Texture2D tex = ImageTool.RenderToTex(_envCamera, _envImageWidth, _envImageHeight); byte[] imageBytes = tex.EncodeToPNG(); DestroyImmediate(tex); Resources.UnloadUnusedAssets(); return(imageBytes); }
/// <summary> /// 用户上传照片 /// </summary> /// <param name="accountID">账户ID</param> /// <param name="file"></param> /// <returns></returns> internal async Task <string> SaveOneFile(ObjectId accountID, IFormFile file) { string resultFileId = ""; long size = 0; var filename = ContentDispositionHeaderValue .Parse(file.ContentDisposition) .FileName .Trim('"'); string saveDir = $@"{ConstantProperty.BaseDir}{ConstantProperty.AlbumDir}"; string dbSaveDir = $@"{ConstantProperty.AlbumDir}"; if (!Directory.Exists(saveDir)) { Directory.CreateDirectory(saveDir); } string exString = filename.Substring(filename.LastIndexOf(".")); string saveName = Guid.NewGuid().ToString("N"); filename = $@"{saveDir}{saveName}{exString}"; size += file.Length; FileModel <string[]> fileCard = new FileModel <string[]>(); using (FileStream fs = System.IO.File.Create(filename)) { file.CopyTo(fs); fs.Flush(); string[] fileUrls = new string[] { $@"{dbSaveDir}{saveName}{exString}" }; } var accountCollection = mongo.GetMongoCollection <AccountModel>(); var account = accountCollection.Find(x => x.AccountID.Equals(accountID)).FirstOrDefault(); if (account.UploadImages == null) { accountCollection.UpdateOne(x => x.AccountID.Equals(accountID), Builders <AccountModel> .Update.Set(x => x.UploadImages, new List <FileModel <string[]> >())); } //ThreadPool.QueueUserWorkItem(new WaitCallback(ImageTool.Create3Img), params3Img); return(await Task.Run(() => { ParamsCreate3Img params3Img = new ParamsCreate3Img() { FileName = filename, FileDir = ConstantProperty.AlbumDir }; params3Img.OnFinish += fileModel => { fileModel.FileID = ObjectId.GenerateNewId(); accountCollection.UpdateOne(x => x.AccountID.Equals(accountID), Builders <AccountModel> .Update.Push(x => x.UploadImages, fileModel)); //mongo.GetMongoCollection<FileModel<string[]>>("FileModel").InsertOne(fileModel); resultFileId = fileModel.FileID.ToString(); }; ImageTool.Create3Img(params3Img); return resultFileId; })); }
public static ArkDinoEntry Convert(UAssetFileBlueprint f, UAssetCacheBlock cache, Dictionary <string, PropertyReader> dinoEntries) { //Open reader PropertyReader reader = new PropertyReader(f.GetFullProperties(cache)); //Get the dino settings UAssetFileBlueprint settingsFileAdult = ArkDinoFood.GetAdultFile(f, cache); UAssetFileBlueprint settingsFileBaby = ArkDinoFood.GetBabyFile(f, cache); //Get time int time = (int)Math.Round((DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0)).TotalSeconds); //Get status component UAssetFileBlueprint statusComponent = ArkDinoEntryStatus.GetFile(f, cache); PropertyReader statusReader = new PropertyReader(statusComponent.GetFullProperties(cache)); //Use name tag to find entry string tag = reader.GetPropertyStringOrName("DinoNameTag"); if (!dinoEntries.ContainsKey(tag)) { throw new Exception($"Could not find dino entry for '{f.classname}' (tag '{tag}')"); } PropertyReader entry = dinoEntries[tag]; //Now, load the material used for the dino image UAssetFileMaterial entryMaterial = entry.GetProperty <ObjectProperty>("DinoMaterial").GetReferencedFileMaterial(); UAssetFileMaterial.TextureParameterValue entryMaterialTexture = entryMaterial.textureParameters[0]; ClassnamePathnamePair entryTexture = entryMaterialTexture.prop.GetReferencedFile(); //Read ArkDinoEntry e = new ArkDinoEntry { screen_name = reader.GetPropertyString("DescriptiveName", null), colorizationIntensity = reader.GetPropertyFloat("ColorizationIntensity", 1), babyGestationSpeed = reader.GetPropertyFloat("BabyGestationSpeed", -1), extraBabyGestationSpeedMultiplier = reader.GetPropertyFloat("ExtraBabyGestationSpeedMultiplier", -1), babyAgeSpeed = reader.GetPropertyFloat("BabyAgeSpeed", null), extraBabyAgeMultiplier = reader.GetPropertyFloat("ExtraBabyAgeSpeedMultiplier", -1), useBabyGestation = reader.GetPropertyBool("bUseBabyGestation", false), statusComponent = ArkDinoEntryStatus.Convert(statusComponent, statusReader), adultFoods = ArkDinoFood.Convert(settingsFileAdult, cache), childFoods = ArkDinoFood.Convert(settingsFileBaby, cache), classname = f.classname, blueprintPath = "N/A", captureTime = time, icon = ImageTool.QueueImage(entryTexture, ImageTool.ImageModifications.None), icon_white = ImageTool.QueueImage(entryTexture, ImageTool.ImageModifications.White) }; //Finally, read stats ArkStatsRipper.DoRipStats(statusReader, e); return(e); }
public JsonResult ThumbnailAvatarUploadImage(string userToken) { UserInfo userInfo = GetUserInfoFromUserToken(userToken); try { if (userInfo != null && Request.Form.Files != null && Request.Form.Files.Count > 0) { for (int i = 0; i < Request.Form.Files.Count; i++) { IFormFile file = Request.Form.Files[i]; if (file.Length > 0) { byte[] byteArray = null; using (MemoryStream ms = new MemoryStream()) { file.CopyTo(ms); byteArray = ms.ToArray(); } if (byteArray != null && byteArray.Length > 0) { byte[] resizeArr = ImageTool.ResizeImage(byteArray, new System.Drawing.Size(200, 200)); using (VistosDbContext ctx = new VistosDbContext()) { UserAvatar userAvatar = new UserAvatar() { Deleted = false, Created = DateTime.Now, Modified = DateTime.Now, CreatedBy_FK = userInfo.UserId, Avatar = resizeArr }; ctx.UserAvatar.Add(userAvatar); ctx.SaveChanges(); var staleItem = Url.Action("GetThumbnailAvatar", "VistosApi", new { id = userInfo.UserId }); //**Response.RemoveOutputCacheItem(staleItem); return(Json(new { id = userAvatar.Id })); } } } } } } catch (Exception ex) { Logger.SaveLogError(LogLevel.Error, "ThumbnailAvatarUploadImage", ex, null, userInfo); } return(null); }
private int GetAIAction() { Texture2D tex = ImageTool.RenderToTex(_envCamera, _envImageWidth, _envImageHeight); byte[] bytes = tex.EncodeToPNG(); float[,] qout = _tfModel.GetValue("Input", "Qout", bytes); int action = GetMaxValueIndex(qout); return(action); }
/// <summary> /// 折线图拖拽结束回调 /// </summary> private void OnLineButtonDragEnd() { ImageTool.SetImageAlpha(_lineButtonImage, 0); if (_isIn) { _lineButton.GetComponent <DragItem>().enabled = false; _lineButtonRect.anchoredPosition = _contentTextRect.anchoredPosition; _titleText.GetComponent <DragItem>().enabled = true; } }
/// <summary> /// Create a new webhook /// </summary> /// <param name="name"></param> /// <param name="avatar"></param> /// <param name="reason">Reason for audit logs.</param> /// <returns></returns> public async Task<DiscordWebhook> CreateWebhookAsync(string name, Optional<Stream> avatar = default, string reason = null) { var av64 = Optional.FromNoValue<string>(); if (avatar.HasValue && avatar.Value != null) using (var imgtool = new ImageTool(avatar.Value)) av64 = imgtool.GetBase64(); else if (avatar.HasValue) av64 = null; return await this.Discord.ApiClient.CreateWebhookAsync(this.Id, name, av64, reason).ConfigureAwait(false); }
public User[] GetFriends() { long[] FriendNums = DB.Friends.Where(u => u.SendUser == UserSource.UloginNumber || u.AcceptUser == UserSource.UloginNumber).Select(u => u.AcceptUser != UserSource.UloginNumber ? u.AcceptUser : u.SendUser).ToArray(); var FriendModels = DB.Users.ToArray().Where(u => FriendNums.Where(f => f == u.UloginNumber).Count() > 0).ToArray(); foreach (User u in FriendModels) { ImageTool.GetUserHeadImage(u.UloginNumber ?? 0); } return(FriendModels.ToArray()); }
static Image GetImageFromResources(string imageName) { Assembly assembly = Assembly.GetExecutingAssembly(); Stream stream = assembly.GetManifestResourceStream(imageName); if (stream == null) { stream = assembly.GetManifestResourceStream("Images." + imageName); } return(ImageTool.ImageFromStream(stream)); }
/////////////////////////////////////////////////////////////////////////////////////////////////////// public MultiChartArray() { InitializeComponent(); m_axisRange = new float[4]; m_uiTask = TaskScheduler.FromCurrentSynchronizationContext(); m_tokenSource = new CancellationTokenSource(); m_imageTool = new ImageTool(); }
public void ImageToolChanged(ImageTool newTool, ImageTool oldTool) { }
private string DisplayImageAction() { int iResize = mc_iResizeModifier; string strPageURL = ImageScoreActiveURL(); int iFrameWidth = 1 + iResize; int iFrameHeight = 1 + iResize; ImageTool objImage = null; if (m_sourceImageURL.Length > 0) { objImage = new ImageTool(m_sourceImagePhysical); //<iframe src="/WorkAreaR2/WorkArea/Foundation/Widgets/Dialogs/ImageScore.aspx?s=/400WorkareaR2/image/ACat1.jpg" // id="imageaffect" width="80%" height="80%" marginheight="0%" marginwidth="0%"></iframe> strPageURL += "?s=" + EkFunctions.UrlEncode(m_sourceImageURL); if (m_strCommand.Length > 0) strPageURL += "&c=" + EkFunctions.UrlEncode(m_strCommand); iFrameWidth = objImage.Width + iResize; iFrameHeight = objImage.Height + iResize; if (iFrameWidth < mc_iMinIFrameWidth) iFrameWidth = mc_iMinIFrameWidth; if (iFrameHeight < mc_iMinIFrameHeight) iFrameHeight = mc_iMinIFrameHeight; } int iAreaHeight = iFrameHeight + mc_iBorderEditMargin; int iAreaWidth = iFrameWidth + mc_iBorderEditMargin; string strIframe = ""; EkImgToolEditAreaDisplay.Style.Add("width", iAreaWidth + "px"); if (IsFileAccessibleForEdit(m_sourceImagePhysical)) { strIframe += "<div style=\"text-align: center; background-color: transparent; \" height=\"100%\" width=\"" + iAreaWidth + "px\"><br />"; //strIframe += "Image location: " + m_sourceImageURL; strIframe += "<iframe src=\"" + strPageURL + "\" id=\"imageaffect\" "; //strIframe += "width=\"" + iFrameWidth + "\" height=\"" + iFrameHeight + "\" "; strIframe += "width=\"" + iAreaWidth + "px\" height=\"100%\" "; if (objImage != null) { int maxdim = (objImage.Height > objImage.Width) ? objImage.Height : objImage.Width; if (hdnCurrentCommand.Value != ImageData.ImageCommand.Rotate.ToString()) { // only need to set max height/width if we're rotating maxdim = objImage.Height; } strIframe += "onload=\"setIframeHeight('imageaffect', " + (maxdim + 50) + ", " + iAreaWidth + ")\" "; } //strIframe += "scrolling=\"yes\" "; strIframe += "frameborder=\"0\" marginheight=\"0%\" marginwidth=\"0%\"></iframe>"; strIframe += "</div>"; } else { strIframe += "<hr /><div style=' font-weight:bold; text-align:center '>"; if (m_strErrorMessage.Length > 0) { strIframe += m_strErrorMessage; } else { strIframe += "This image can't be edited."; } strIframe += "</div><hr /><br />"; } return strIframe; }
private void FillImageInformation() { // Should we show the resizer. if ((m_sourceImageURL.Length > 0) && (ImageData.ImageCommand.Resize.ToString() == hdnCurrentCommand.Value.ToString())) { //ImageSizeInfoArea.Visible = true; ImageTool objImage = new ImageTool(m_sourceImagePhysical); if (objImage.FileSize > 4096) { lblImageFileSizeInKs.Text = Convert.ToString(objImage.FileSize / 1024); lblImageFileSizeInKs.ToolTip = lblImageFileSizeInKs.Text; lblImageSizeUnit.Text = "K"; } else { lblImageFileSizeInKs.Text = Convert.ToString(objImage.FileSize); lblImageFileSizeInKs.ToolTip = lblImageFileSizeInKs.Text; lblImageSizeUnit.Text = "bytes"; } txtImageResizeWidth.Text = objImage.Width.ToString(); txtImageResizeWidth.ToolTip = txtImageResizeWidth.Text; txtImageResizeHeight.Text = objImage.Height.ToString(); txtImageResizeHeight.ToolTip = txtImageResizeHeight.Text; txtMaxImageHeight.Text = objImage.Height.ToString(); // We need to save the original settings for aspect calculations. hdnImageResizeOrigWidth.Value = objImage.Width.ToString(); hdnImageResizeOrigHeight.Value = objImage.Height.ToString(); } else { //ImageSizeInfoArea.Visible = false; } }
static void Init () { win = ScriptableObject.CreateInstance( typeof(ImageTool) ) as ImageTool; win.ShowUtility(); }
private void ResetSelectionRect() { // We will do this here, so that we get the basic image info. ImageTool objTool = new ImageTool(m_strSrcImagePath); long iLocX = (objTool.Width / 15) + 1; long iLocY = (objTool.Height / 15) + 1; long iWidth = (objTool.Width / 2) + 1; long iHeight = (objTool.Height / 2) + 1; TextStartX.Value = iLocX.ToString(); TextStartY.Value = iLocY.ToString(); TextWidth.Value = iWidth.ToString(); TextHeight.Value = iHeight.ToString(); }