public static async Task <Bitmap> GetInvisibleDressingRoomDragon(DragonCache dragon) { var azureImageService = new AzureImageService(); var apparelIds = dragon.GetApparel(); if (!apparelIds.Contains(22046)) { apparelIds = apparelIds.Concat(new[] { 22046 }).ToArray(); } var dressingRoomUrl = string.Format(DressingRoomDummyUrl, (int)dragon.DragonType, (int)dragon.Gender) + $"&apparel={string.Join(",", apparelIds)}"; var azureUrl = $@"dragoncache\{dragon}_invisible.png"; using (var client = new WebClient()) { var invisibleDragonBytesTask = client.DownloadDataTaskAsync(dressingRoomUrl); var invisibleDwagonImageBytes = await invisibleDragonBytesTask; using (var memStream = new MemoryStream(invisibleDwagonImageBytes, false)) await azureImageService.WriteImage(azureUrl, memStream); using (var memStream = new MemoryStream(invisibleDwagonImageBytes, false)) { var invisibleDwagon = (Bitmap)Image.FromStream(memStream); return(invisibleDwagon); } } }
public static async Task <Bitmap> GetDragonBaseImage(DragonCache dragon) { Bitmap dwagonImage; string azureUrl = $@"dragoncache\{dragon.SHA1Hash}.png"; var azureImageService = new AzureImageService(); if (await azureImageService.Exists(azureUrl) != null) { try { using (var stream = await azureImageService.GetImage(azureUrl)) dwagonImage = (Bitmap)Image.FromStream(stream); return(dwagonImage); } catch { } } using (var client = new WebClient()) { var dwagonImageBytes = await client.DownloadDataTaskAsync(dragon.ConstructImageString() ?? string.Format(DressingRoomDummyUrl, (int)dragon.DragonType, (int)dragon.Gender)); using (var memStream = new MemoryStream(dwagonImageBytes, false)) await azureImageService.WriteImage(azureUrl, memStream); using (var memStream = new MemoryStream(dwagonImageBytes, false)) { dwagonImage = (Bitmap)Image.FromStream(memStream); return(dwagonImage); } } }