public void SetImage(Bitmap bmp) { var s = new Size(248, 248); // ((&H20140 - &H140) / 256 / 2 / 32) * 31) if (bmp.Size != s) { bmp = (Bitmap)TextureManager.ResizeImage(bmp, s, false); } _ImageBytes = BackgroundImageConverter.GetBytes(bmp); _Image = null; }
public Image GetImage() { if (_ImageBytes is object) { var s = new Size(248, 248); // ((_ImageByts.Length - &H140) / 256 / 2 / 32) * 31) var img = BackgroundImageConverter.GetImage(_ImageBytes, s); _Image = img; return(img); } else { return(null); } }
private void OnGetWallpapers(TLVector <TLWallPaperBase> results, int skip, int take) { var currentItem = StateService.CurrentBackground; foreach (var result in results.Skip(skip).Take(take)) { var wallpaper = result as TLWallPaper; if (wallpaper == null) { continue; } var size = BackgroundImageConverter.GetPhotoSize(wallpaper.Sizes, 480.0); if (size != null) { var location = size.Location as TLFileLocation; if (location != null) { var fileName = String.Format("{0}_{1}_{2}.jpg", location.VolumeId, location.LocalId, location.Secret); BackgroundItem item; var isSelected = currentItem != null && "telegram" + wallpaper.Id == currentItem.Name; if (isSelected) { item = currentItem; item.IsSelected = true; } else { item = new BackgroundItem { Name = "telegram" + wallpaper.Id, Wallpaper = wallpaper, IsoFileName = fileName }; } Static.Add(item); } } } }