public async Task SaveFacesAsync( Guid mediaId, IEnumerable <MediaFace> faces, CancellationToken cancellationToken) { if (faces != null) { foreach (MediaFace face in faces) { await Thumbnails.StoreAsync( new ThumbnailData(face.Thumbnail.Id, face.Thumbnail.Data), cancellationToken); face.Thumbnail.Data = null; } if (faces.Any()) { await _mediaStoreContext.Faces.InsertManyAsync( faces, options : null, cancellationToken); } } await _mediaStoreContext.Medias.UpdateOneAsync( x => x.Id == mediaId, Builders <Media> .Update.Set(f => f.FaceCount, faces.Count()), options : null, cancellationToken); }
private void DrawThumbnails() { // Draw thumbnail sprites uint?drawTextKey = null; host.Core.SpriteBatch.Begin(); foreach (var item in thumbDict) { // Draw thumbnail host.Core.SpriteBatch.Draw(item.Value.texture, item.Value.rect, Color.White); // Set key to draw text over thumb if (mouseOverThumb == item.Key) { drawTextKey = item.Key; } } host.Core.SpriteBatch.End(); // Draw thumbnail id text. This is done in a second batch to avoid alpha problems // with sprite render on some cards. host.Core.SpriteBatch.Begin(); if (drawTextKey != null) { Thumbnails thumb = thumbDict[drawTextKey.Value]; string thumbText = string.Format("{0}", thumb.key.ToString()); Vector2 thumbTextSize = host.Core.SmallFont.MeasureString(thumbText); int textX = (int)thumb.rect.X + (int)(thumb.rect.Width - thumbTextSize.X) / 2; Vector2 textPos = new Vector2(textX, (float)thumb.rect.Bottom - thumbTextSize.Y - 4); host.Core.SpriteBatch.DrawString(host.Core.SmallFont, thumbText, textPos, thumbTextColor); } host.Core.SpriteBatch.End(); }
public async Task <CreateArticleDTO> Handle(CreateArticleCommand command, CancellationToken token) { var thumbnail = new Thumbnails { Content = command.Thumbnail }; await _context.Thumbnails .AddAsync(thumbnail, token); var article = new Data.Article { Thumbnail = thumbnail, Content = command.Content, Author = await _context.AspNetUsers .FindAsync(command.AuthorId), Title = command.Title, Created = command.Created, Description = command.Description }; await _context.Article .AddAsync(article, token); await _context.SaveChangesAsync(token); return(new CreateArticleDTO { ArticleId = article.Id }); }
private string FormatEmojiImage(Emoji emoji) { if (emoji == null) { return(""); } string ret = ""; if (emoji.isCustomEmoji) { Thumbnails thumb = emoji.image.thumbnails.ElementAtOrDefault(0); if (thumb != null) { string url = thumb.url; int w = thumb.width; int h = thumb.height; ret = $"[img source='{url}' width={w} height={h}]"; } } else { ret = emoji.emojiId; } return(ret); }
public ShotsWindow(string photosceneid) { _photosceneid = photosceneid; InitializeComponent(); Thumbnails.View = Thumbnails.FindResource("tileView") as ViewBase; Thumbnails.ItemsSource = new ObservableCollection <ReCapPhotoItem> (); }
public void OutputThumbnailsToJson() { const string One = @"{{""input"":""http://example.com/file-name.avi"",""outputs"":[{{""thumbnails"":[{{""base_url"":""s3://bucket/directory"",""height"":120,""label"":null,""number"":6,""prefix"":""custom"",""width"":160}}]}}],""api_key"":""{0}""}}"; const string Two = @"{{""input"":""http://example.com/file-name.avi"",""outputs"":[{{""thumbnails"":[{{""headers"":{{""x-amz-acl"":""public-read-write""}},""base_url"":""s3://bucket/directory"",""filename"":""{{{{number}}}}_{{{{width}}}}x{{{{height}}}}-thumbnail"",""height"":120,""interval_in_frames"":10,""label"":null,""prefix"":""custom"",""width"":160}}]}}],""api_key"":""{0}""}}"; Thumbnails thumbs = new Thumbnails() { BaseUrl = "s3://bucket/directory", Prefix = "custom" }; Output output = new Output() { Thumbnails = new Thumbnails[] { thumbs.WithNumber(6).WithSize(160, 120) } }; CreateJobRequest request = new CreateJobRequest(Zencoder) { Input = "http://example.com/file-name.avi", Outputs = new Output[] { output } }; Assert.AreEqual(string.Format(CultureInfo.InvariantCulture, One, ApiKey), request.ToJson()); thumbs = thumbs.WithIntervalInFrames(10); thumbs.FileName = "{{number}}_{{width}}x{{height}}-thumbnail"; thumbs.Headers["x-amz-acl"] = "public-read-write"; output.Thumbnails = new Thumbnails[] { thumbs }; Assert.AreEqual(string.Format(CultureInfo.InvariantCulture, Two, ApiKey), request.ToJson()); }
private Task <bool> AddThumbnail(ImageSavedEventArgs msg) { return(Task <bool> .Run(async() => { var factor = 100 / msg.Image.Width; var scaledBitmap = CreateResizedImage(msg.Image, (int)(msg.Image.Width * factor), (int)(msg.Image.Height * factor), 0); scaledBitmap.Freeze(); await _dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() => { var thumbnail = new Thumbnail() { ThumbnailImage = scaledBitmap, ImagePath = msg.PathToImage, FileType = msg.FileType, Duration = msg.Duration, Mean = msg.Mean, HFR = msg.HFR, Filter = msg.Filter, IsBayered = msg.IsBayered }; Thumbnails.Add(thumbnail); SelectedThumbnail = thumbnail; })); return true; })); }
// Example getting images with images from a ZIP file on local disc // These examples come from the ReCap offical site that need to be downloaded first // as ReCap API cannot reference a ZIP file, or images in ZIP private void GetReCapExample(string url, string location) { if (!File.Exists(location)) { if (url != null) { if (System.Windows.MessageBox.Show("This sample is quite large, are you sure you want to proceed?\nThe file would be downloaded only once.", "ReCap Example download", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { ReCapExample_Download(url, location); } } return; } ObservableCollection <ReCapPhotoItem> items = new ObservableCollection <ReCapPhotoItem> (); FileStream zipStream = File.OpenRead(location); using (ZipArchive zip = new ZipArchive(zipStream)) { foreach (ZipArchiveEntry entry in zip.Entries) { items.Add(new ReCapPhotoItem() { Name = System.IO.Path.GetFileNameWithoutExtension(entry.Name), Type = System.IO.Path.GetExtension(entry.Name).Trim(new char [] { '.' }), Image = location + ":" + entry.FullName }); } } Thumbnails.ItemsSource = items; Thumbnails.SelectAll(); }
/// <summary> /// Animate thumbnail during mouse-over state. /// </summary> /// <param name="key">Key.</param> private void AnimateThumb(uint key) { if (!thumbDict.ContainsKey(key)) { return; } Thumbnails thumb = thumbDict[key]; // Step rotation in degrees thumb.rotation += 2f; if (thumb.rotation > 360.0f) { thumb.rotation -= 360.0f; } UpdateThumbnailTexture(ref thumb); // Enlarge rect size thumb.rect.X -= mouseOverThumbGrow / 2; thumb.rect.Y -= mouseOverThumbGrow / 2; thumb.rect.Width += mouseOverThumbGrow; thumb.rect.Height += mouseOverThumbGrow; thumbDict[key] = thumb; }
public IEnumerable <IGameWithMetaInfo> GetAllGames(Func <IGameMetaInfo, bool> filter) { foreach (var t in Thumbnails.Where(t => filter == null || filter(t))) { yield return(GameSource.GetGame(t.ID)); } }
/// <summary> /// Closing MainForm /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void FormMain_FormClosing(object sender, FormClosingEventArgs e) { //Stopping threads if (downloadthread != null) { downloadthread.Stop(); downloadthread = null; } if (thumbnailthread != null) { thumbnailthread.Stop(); thumbnailthread = null; } if (mjsource != null) { mjsource.Stop(); mjsource = null; } Properties.Settings.Default.WindowSize = this.Size; Properties.Settings.Default.WindowLocation = this.Location; Properties.Settings.Default.splitContainerDebugPosition = splitContainerDebug.SplitterDistance; Properties.Settings.Default.splitContainerPictureviewPosition = splitContainerPictureview.SplitterDistance; Properties.Settings.Default.Save(); log.Debug("Application closing"); }
/// <inheritdoc /> public async Task <IReadOnlyList <Video> > SearchVideosAsync(string query, int maxPages) { query.EnsureNotNull(nameof(query)); maxPages.EnsurePositive(nameof(maxPages)); // Get all videos across pages var videos = new List <Video>(); for (var i = 1; i <= maxPages; i++) { // Get search results var searchResultsJson = await GetSearchResultsAsync(query, i).ConfigureAwait(false); // Get videos var videosJson = searchResultsJson["video"].EmptyIfNull().ToArray(); // Break if there are no videos if (!videosJson.Any()) { break; } // Parse videos foreach (var videoJson in videosJson) { // Basic info var videoId = videoJson["encrypted_id"].Value <string>(); var videoAuthor = videoJson["author"].Value <string>(); var videoAuthorId = "UC" + videoJson["user_id"].Value <string>(); var videoUploadDate = videoJson["added"].Value <string>().ParseDateTimeOffset("M/d/yy"); var videoTitle = videoJson["title"].Value <string>(); var videoDuration = TimeSpan.FromSeconds(videoJson["length_seconds"].Value <double>()); var videoDescription = videoJson["description"].Value <string>().HtmlDecode(); // Keywords var videoKeywordsJoined = videoJson["keywords"].Value <string>(); var videoKeywords = Regex .Matches(videoKeywordsJoined, @"(?<=(^|\s)(?<q>""?))([^""]|(""""))*?(?=\<q>(?=\s|$))") .Cast <Match>() .Select(m => m.Value) .Where(s => s.IsNotBlank()) .ToArray(); // Statistics var videoViews = videoJson["views"].Value <string>().StripNonDigit().ParseLong(); var videoLikes = videoJson["likes"].Value <long>(); var videoDislikes = videoJson["dislikes"].Value <long>(); var videoStatistics = new Statistics(videoViews, videoLikes, videoDislikes); // Video var videoThumbnails = new Thumbnails(videoId); var video = new Video(videoId, videoTitle, videoDescription, videoAuthor, videoAuthorId, videoUploadDate, videoDuration, videoKeywords, videoThumbnails, videoStatistics); videos.Add(video); } } return(videos); }
public async Task <IReadOnlyDictionary <Guid, MediaThumbnail> > GetThumbnailsByMediaIdsAsync( IEnumerable <Guid> mediaIds, ThumbnailSizeName size, CancellationToken cancellationToken) { FilterDefinition <Media> filter = Builders <Media> .Filter .In(x => x.Id, mediaIds.ToList()); filter = filter & Builders <Media> .Filter.ElemMatch(x => x.Thumbnails, Builders <MediaThumbnail> .Filter.Eq(t => t.Size, size)); List <Media> medias = await _mediaStoreContext.Medias.Find(filter) .ToListAsync(cancellationToken); var result = new Dictionary <Guid, MediaThumbnail>(); foreach (Media media in medias) { MediaThumbnail?thumb = media !.Thumbnails !.Where(x => x.Size == size && x.Format == "webp") .FirstOrDefault(); if (thumb != null) { thumb.Data = await Thumbnails.GetAsync(thumb.Id, cancellationToken); result.Add(media.Id, thumb); } } return(result); }
private static void Main(string[] args) { var size = new System.Drawing.Size(300, 300); Thumbnails.FromIamge("1.jpg", "image.jpg", size); Thumbnails.FromIamge("1.gif", "gif.jpg", size); Thumbnails.FromVideo("1.mp4", "video.jpg"); Console.WriteLine("Hello World!"); }
private void buildLocalThumbnailModels() { foreach (var thumb in Service.Library.Thumbnails) { if (thumb.Image.UriSource != new Uri("ms-appx:///Vap-logo-placeholder.jpg")) { Thumbnails.Add(thumb.Image); } } }
private async Task Refresh() { Processing = true; FolderName = null; RefreshPhotosCommand.RaiseCanExecuteChanged(); Thumbnails.Clear(); var filters = FilterFactory.CreateStreamFilters(); var maxItems = (uint)_highlightStrategy.BatchSize * 5; if (SessionModel.Instance.Folder != null) { FolderName = SessionModel.Instance.Folder.DisplayName; var models = await GetPhotosFromFolderAsync(SessionModel.Instance.Folder, maxItems); for (var i = 0; i < models.Count; i++) { var k = i % (_highlightStrategy.BatchSize); var highlight = _highlightStrategy.HighlightedIndexes.Contains(k); Thumbnails.Add(new ThumbnailViewModel(models[i], TakeRandomFilter(filters), highlight)); } } else { var models = await GetPhotosFromFolderAsync(Windows.Storage.KnownFolders.CameraRoll, maxItems); FolderName = Windows.Storage.KnownFolders.CameraRoll.DisplayName; #if !WINDOWS_PHONE_APP if (models.Count == 0) { models = await GetPhotosFromFolderAsync(Windows.Storage.KnownFolders.PicturesLibrary, maxItems); FolderName = Windows.Storage.KnownFolders.PicturesLibrary.DisplayName; } #endif for (var i = 0; i < models.Count; i++) { var k = i % (_highlightStrategy.BatchSize); var highlight = _highlightStrategy.HighlightedIndexes.Contains(k); Thumbnails.Add(new ThumbnailViewModel(models[i], TakeRandomFilter(filters), highlight)); } } Processing = false; RefreshPhotosCommand.RaiseCanExecuteChanged(); }
public byte[] GetThumbnailForExtension(string extension, Thumbnails.Size pxSize = Thumbnails.Size.Px32) { try { return iconsStorage.GetIcon(extension, pxSize); } catch (Exception) { return iconsStorage.GetIcon("_blank", pxSize); } }
public byte[] GetIcon(string type, Thumbnails.Size size) { var icon = IconsData[size].GetObject(type) as byte[]; if (icon == null) { return IconsData[size].GetObject(BLANK) as byte[]; } return icon; }
void ClearElements() { foreach (ItemCollectionPanelThumbnail element in Thumbnails.ToList()) { GameObject.Destroy(element.gameObject); } foreach (ItemCollectionPanelLine element in Lines.ToList()) { GameObject.Destroy(element.gameObject); } }
public UploadSucceeded ToSerializeable() { return(new UploadSucceeded { name = this.Name, size = this.Size, url = "/api/files/" + this.Id, thumbnailUrl = Thumbnails.GetThumbnail(this.Name), deleteUrl = "/api/files/" + this.Id, deleteType = "DELETE" }); }
void ValidateElements() { if (IsDisplayingThumbnails != ThumbnailSwitch.IsOn) { ClearElements(); } if (IsDisplayingThumbnails) { foreach (ItemCollectionPanelThumbnail element in Thumbnails.ToList()) { if (!Items.Contains(element.Item)) { GameObject.Destroy(element.gameObject); } } } else { foreach (ItemCollectionPanelLine element in Lines.ToList()) { if (!Items.Contains(element.Item)) { GameObject.Destroy(element.gameObject); } } } foreach (Item item in Items) { if (!ItemsListed.Contains(item)) { GameObject element; if (IsDisplayingThumbnails) { ItemCollectionPanelThumbnail thumbnail_inventory_element = GameObject.Instantiate(ThumbnailPrefab); thumbnail_inventory_element.Item = item; element = thumbnail_inventory_element.gameObject; } else { ItemCollectionPanelLine line_inventory_element = GameObject.Instantiate(LinePrefab); line_inventory_element.Item = item; element = line_inventory_element.gameObject; } element.transform.SetParent(Grid.transform, false); } } }
private void GenerateThumbnails(long imageId) { try { Thumbnails.GetThumbnail(this.mContext.ContentResolver, imageId, Android.Provider.ThumbnailKind.MiniKind, (Options)null); } catch// (System.NullReferenceException e) { //Console.WriteLine(e.ToString()); //Console.Write(e.StackTrace); } }
public IGameWithMetaInfo GetRandomGame(Func <IGameMetaInfo, bool> filter) { var filteredGames = Thumbnails.Where(t => filter == null || filter(t)); if (filteredGames.Count() == 0) { return(null); } var thumbnail = filteredGames.ElementAt(RandomNumberGenerator.Next(filteredGames.Count())); return(GameSource.GetGame(thumbnail.ID)); }
/// <summary> /// Returns a list of disk paths for original image (if exists) and generated thumbnails /// </summary> /// <returns></returns> public List <string> GetAllFilePaths() { var paths = new List <string>(); if (!string.IsNullOrEmpty(OriginalFilePath)) { paths.Add(OriginalFilePath); } paths.AddRange(Thumbnails.Select(x => x.DiskPath)); return(paths); }
public string[] GetThumbnails() { if (this.Thumbnails != null && this.Thumbnails.Length > 0) { var arrayThumbnails = Thumbnails.Split(','); if (arrayThumbnails.Length > 0) { return(arrayThumbnails); } } return(new string[0]); }
private void ShowCluster(int clusterId) { if (bitmapReader != null && clusters != null) { Thumbnails.Clear(); foreach (int descriptorId in clusters[clusterId]) { // TODO verbose (videoID, shotID...) Bitmap bitmap = bitmapReader.ReadFrame(descriptorId); Thumbnails.Add(new Thumbnail(descriptorId.ToString(), BitmapToImageSource(bitmap))); } } }
public byte[] GetThumbnailForMimeType(string mimeType, Thumbnails.Size pxSize = Thumbnails.Size.Px32) { try { var extension = MimeTypeMap.GetExtension(mimeType).Replace(".", ""); return iconsStorage.GetIcon(extension, pxSize); } catch (Exception) { return iconsStorage.GetIcon("_blank", pxSize); } }
static void ReloadStrings() { Main.Reload(); Buttons.Reload(); Tools.Reload(); Copier.Reload(); Log.Reload(); Warning.Reload(); Credits.Reload(); Misc.Reload(); Thumbnails.Reload(); AvatarInfo.Reload(); }
protected static Size GetThumbnailSize(Image original, Thumbnails.Size maxPxSize) { double factor; if (original.Width > original.Height) { factor = (double)maxPxSize / original.Width; } else { factor = (double)maxPxSize / original.Height; } return new Size((int)(original.Width * factor), (int)(original.Height * factor)); }
private void UpdateStatusMessage() { int count; string message; // State how many models we are viewing if (!useFilteredModels) { count = host.ModelManager.Arch3dFile.Count; message = string.Format("Exploring all {0} models in ARCH3D.BSA.", count); } else { count = host.FilteredModelsArray.Length; message = string.Format("Exploring filtered list of {0} models.", count); } // Determine which thumbnails are actually visible in the client area. // Discounts non-visible thumbnails above and below client used for scrolling. int first = 99999, last = -99999; foreach (var item in thumbDict) { // Get System.Drawing.Rectangle for thumbnail Thumbnails thumb = thumbDict[item.Key]; System.Drawing.Rectangle rect = new System.Drawing.Rectangle( thumb.rect.Left, thumb.rect.Top, thumb.rect.Width, thumb.rect.Height); // Only consider if completely or partially inside client rectangle if (host.ClientRectangle.Contains(rect)) { if (thumb.index < first) { first = thumb.index; } if (thumb.index > last) { last = thumb.index; } } } // Add position in list message += string.Format(" You are viewing models {0}-{1}.", first, last); // Set the message host.StatusMessage = message; }
private async Task ProcessResponse(ConnectorClient connector, Activity input) { Activity reply = null; string exMsg = string.Empty; if (IsvalidUri(input.Text, out exMsg)) { await Thumbnails.ProcessScreenshots(connector, input); } else { reply = input.CreateReply("Hii, What is the URL you want a thumbnail for..?"); await connector.Conversations.ReplyToActivityAsync(reply); } }
private void ThumbnailsChanged() { if (AutoSize) { if (Thumbnails == null || Thumbnails.Count == 0) { Width = 0; Height = 0; } else { var first = Thumbnails.Get(0).Thumbnail; Width = first.PixelWidth; Height = first.PixelHeight; } } }
/// <summary> /// 解析Emoji元素 /// </summary> /// <param name="run">json data</param> /// <returns>回傳留言的Emoji物件。若Json data內非Emoji則回傳null</returns> private Emoji ParseEmoji(dynamic run) { Emoji ret = new Emoji(); dynamic emojiObj = JsonHelper.TryGetValue(run, "emoji"); if (emojiObj == null) { return(null); } ret.emojiId = Convert.ToString(JsonHelper.TryGetValue(emojiObj, "emojiId", "")); dynamic shortcuts = JsonHelper.TryGetValue(emojiObj, "shortcuts"); for (int i = 0; i < shortcuts.Count; i++) { ret.shortcuts.Add(Convert.ToString(shortcuts[i])); } dynamic searchTerms = JsonHelper.TryGetValue(emojiObj, "searchTerms"); for (int i = 0; i < searchTerms.Count; i++) { ret.searchTerms.Add(Convert.ToString(searchTerms[i])); } ret.isCustomEmoji = Convert.ToBoolean(JsonHelper.TryGetValue(emojiObj, "isCustomEmoji", false)); dynamic thumbsObj = JsonHelper.TryGetValueByXPath(emojiObj, "image.thumbnails"); for (int i = 0; i < thumbsObj.Count; i++) { Thumbnails thumbs = new Thumbnails(); thumbs.url = Convert.ToString(JsonHelper.TryGetValueByXPath(thumbsObj, $"{i.ToString()}.url")); thumbs.width = Convert.ToInt32(JsonHelper.TryGetValueByXPath(thumbsObj, $"{i.ToString()}.width", 0)); thumbs.height = Convert.ToInt32(JsonHelper.TryGetValueByXPath(thumbsObj, $"{i.ToString()}.height", 0)); ret.image.thumbnails.Add(thumbs); } ret.image.accessibility.accessibilityData.label = Convert.ToString(JsonHelper.TryGetValueByXPath(emojiObj, "image.accessibility.accessibilityData.label", "")); return(ret); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ltlLabTitle.Text = Language.GetTextByID(217); LabHeaderCmuc.Text = Language.GetTextByID(91); LabTieude.Text = Language.GetTextByID(29); LabNoidung.Text = Language.GetTextByID(35); LabTomtat.Text = Language.GetTextByID(31); LabImg.Text = Language.GetTextByID(33); clsHoivien hoivien = new clsHoivien(); DataRow drow = hoivien.GetInfo(newsid); LabTenTieude.Text = drow["title"].ToString(); LabND_tomtat.Text = drow["summary"].ToString(); LabNoidungbai.Text = hoivien.GetContent(newsid); string groupid = drow["groupid"].ToString(); Groups objgroup = new Groups(); DataRow vdr = objgroup.GetInfo(groupid); LabChuyenmuc.Text = vdr["title"].ToString().Trim(); //images string sFile = drow["logo"].ToString().Trim(); if (sFile.Length > 0) { string cImages = sFile.Substring(0, 4); if (cImages != "data") { fImage.Attributes.Add("style", "width:100px;height:100px"); fImage.Src = sFile; } else { fImage.Src = Thumbnails.viewAsThumbnails(sFile, Convert.ToInt32(drow["fwidth"].ToString()), Convert.ToInt32(drow["fheight"].ToString()), "news_m", drow["id"].ToString()); } } else { fImage.Src = Globals.UrlRootImages + "data/images/no-image.gif"; } } }
public void reset() { _dicTnKeyToItem.Clear(); _queItem.Clear(); reload(); var nAvailableWidth = SystemInformation.WorkingArea.Width - _leftMarginal - SystemInformation.VerticalScrollBarWidth - 30; var nImagesInOneRow = trackBar1.Value; if (_flikKategori == FlikKategori.Porträtt) nImagesInOneRow *= 2; _thumbnailWidth = nAvailableWidth/nImagesInOneRow - 5; _tns = new Thumbnails(null, Global.Skola, _thumbnailWidth, 1000, 7); Update(); }
public void GetThumbnailForImageReturnsProperIcon_Px(Thumbnails.Size size) { var target = new IconThumbnail(); // Act var pngIcon = target.GetThumbnailForMimeType("image/png", size); var jpegIcon = target.GetThumbnailForMimeType("image/jpeg", size); var bmpIcon = target.GetThumbnailForMimeType("image/bmp", size); var tiffIcon = target.GetThumbnailForMimeType("image/tiff", size); var gifIcon = target.GetThumbnailForMimeType("image/gif", size); var blankIcon = target.GetThumbnailForMimeType("blank", size); // Assert CheckImageIcon(blankIcon, (int)size); CheckImageIcon(pngIcon, (int)size); CheckImageIcon(jpegIcon, (int)size); CheckImageIcon(bmpIcon, (int)size); CheckImageIcon(tiffIcon, (int)size); CheckImageIcon(gifIcon, (int)size); }
private object ParseXml(string type, string XmlString, Func<string, object> customParser) { var imageList = new Thumbnails(); var xDoc = System.Xml.Linq.XDocument.Parse(XmlString); if (xDoc.Root.Name.ToString() == "error") { var str = "API error:\n" + xDoc.Descendants("error") .Select(el => el.Element("error_msg").Value) .ToList<String>()[0]; Debug.WriteLine(str); return null; } if (customParser != null) return customParser(XmlString); switch (type) { case ("photos.getAlbums"): var albums = xDoc.Descendants("album").Select(a => new Thumbnail { Name = a.Element("aid").Value, Title = a.Element("title").Value, Image = ImageDataFromUri(a.Element("thumb_src").Value), Checked = false }); imageList.Clear(); foreach (var album in albums) imageList.Add(album); return imageList; case ("photos.get"): Func<System.Xml.Linq.XElement, string> tmp = (xElement) => { var bigImage = xElement.Element("src_xxxbig"); if (bigImage != null && !string.IsNullOrWhiteSpace(bigImage.Value)) return bigImage.Value; bigImage = xElement.Element("src_xxbig"); if (bigImage != null && !string.IsNullOrWhiteSpace(bigImage.Value)) return bigImage.Value; bigImage = xElement.Element("src_xbig"); if (bigImage != null && !string.IsNullOrWhiteSpace(bigImage.Value)) return bigImage.Value; bigImage = xElement.Element("src_big"); if (bigImage != null && !string.IsNullOrWhiteSpace(bigImage.Value)) return bigImage.Value; bigImage = xElement.Element("src"); if (bigImage != null && !string.IsNullOrWhiteSpace(bigImage.Value)) return bigImage.Value; bigImage = xElement.Element("src_small"); if (bigImage != null && !string.IsNullOrWhiteSpace(bigImage.Value)) return bigImage.Value; return null; }; var photos = xDoc.Descendants("photo") .Select(a => new Thumbnail() { Name = a.Element("src_small").Value.Split('/').Last(), Title = tmp(a).Split('/').Last(), BigImage = tmp(a), Image = ImageDataFromUri(a.Element("src_small").Value), Checked = false }); imageList.Clear(); foreach (var photo in photos) imageList.Add(photo); return imageList; case "utils.resolveScreenName": return xDoc.Element("response").HasElements ? xDoc.Element("response").Element("object_id").Value : null; case "users.get": return xDoc.Element("response").Element("id").Value; default: break; } return null; }
/// <summary> /// Returns a Translated name for selected Thumbnail Mod /// </summary> /// <param name="widebanner">Thumbnail enum to translate</param> /// <returns>Translated Name</returns> private string GetThumbnailName(Thumbnails thumb) { switch (thumb) { case Thumbnails.Default: return Translation.ThumbnailDefault; case Thumbnails.TwelveByFourAndEightByThreeGrid: return Translation.Thumbnail_12x4_8x3_Grid; case Thumbnails.TwelveByThreeAndEightByTwoGrid: return Translation.Thumbnail_12x3_8x2_Grid; default: return Translation.WideBannerDefault; } }
private void trackBar1_Scroll( object sender, EventArgs e ) { _tns.Dispose(); _tns = null; foreach ( var img in _imageChache.Values ) img.Dispose(); _imageChache.Clear(); reset(); }
public override void Initialize() { Thumbnails = new Thumbnails(); Thumbnails.Add(new Thumbnail { Width = 200, Height = 100, Name = "SmallPreview" }); Thumbnails.Add(new Thumbnail { Width = 400, Height = 300, Name = "BigPreview" }); }
public void OutputThumbnailsToJson() { const string One = @"{{""input"":""http://example.com/file-name.avi"",""outputs"":[{{""thumbnails"":[{{""base_url"":""s3://bucket/directory"",""height"":120,""number"":6,""prefix"":""custom"",""width"":160}}]}}],""api_key"":""{0}""}}"; Thumbnails thumbs = new Thumbnails() { BaseUrl = "s3://bucket/directory", Prefix = "custom" }; Output output = new Output() { Thumbnails = new Thumbnails[] { thumbs.WithNumber(6).WithSize(160, 120) } }; CreateJobRequest request = new CreateJobRequest(Zencoder) { Input = "http://example.com/file-name.avi", Outputs = new Output[] { output } }; Assert.AreEqual(String.Format(CultureInfo.InvariantCulture, One, ApiKey), request.ToJson()); }
public ImageThumbnail(Stream image, Thumbnails.Size thumbnailMaxPxSize = Thumbnails.Size.Px32) { ImgThumbnail = GenerateThumbnail(Image.FromStream(image), thumbnailMaxPxSize); }
protected static Image GenerateThumbnail(Image img, Thumbnails.Size maxPxSize) { Size thumbnailSize = GetThumbnailSize(img, Thumbnails.Size.Px32); return img.GetThumbnailImage(thumbnailSize.Width, thumbnailSize.Height, null, IntPtr.Zero); }