Hearthstone card search support

This commit is contained in:
Master Kwoth
2016-02-05 08:01:31 +01:00
parent 4fce93c5cf
commit 861a587212
5 changed files with 72 additions and 8 deletions

View File

@@ -217,11 +217,13 @@ namespace NadekoBot.Extensions {
public static int GB(this int value) => value.MB() * 1000;
public static Stream ToStream(this System.Drawing.Image img, System.Drawing.Imaging.ImageFormat format = null) {
Console.WriteLine("To stream");
if (format == null)
format = System.Drawing.Imaging.ImageFormat.Jpeg;
MemoryStream stream = new MemoryStream();
img.Save(stream, format);
stream.Position = 0;
Console.WriteLine("To stream finished");
return stream;
}
@@ -230,23 +232,32 @@ namespace NadekoBot.Extensions {
/// </summary>
/// <param name="images">The Images you want to merge.</param>
/// <returns>Merged bitmap</returns>
public static Bitmap Merge(this IEnumerable<Image> images) {
public static Bitmap Merge(this IEnumerable<Image> images,int reverseScaleFactor = 1) {
Console.WriteLine("Start merge");
if (images.Count() == 0) return null;
int width = images.Sum(i => i.Width);
int height = images.First().Height;
Bitmap bitmap = new Bitmap(width, height);
int height = images.First().Height ;
Bitmap bitmap = new Bitmap(width / reverseScaleFactor, height / reverseScaleFactor);
var r = new Random();
int offsetx = 0;
foreach (var img in images) {
Bitmap bm = new Bitmap(img);
for (int w = 0; w < img.Width; w++) {
for (int h = 0; h < img.Height; h++) {
bitmap.SetPixel(w + offsetx, h, bm.GetPixel(w, h));
for (int h = 0; h < bitmap.Height; h++) {
bitmap.SetPixel(w / reverseScaleFactor + offsetx, h , bm.GetPixel(w, h *reverseScaleFactor));
}
}
offsetx += img.Width;
offsetx += img.Width/reverseScaleFactor;
}
Console.WriteLine("Finish merge");
return bitmap;
}
/// <summary>
/// Merges Images into 1 Image and returns a bitmap asynchronously.
/// </summary>
/// <param name="images">The Images you want to merge.</param>
/// <returns>Merged bitmap</returns>
public static async Task<Bitmap> MergeAsync(this IEnumerable<Image> images, int reverseScaleFactor = 1) =>
await Task.Run(() => images.Merge(reverseScaleFactor));
}
}

View File

@@ -76,6 +76,9 @@ namespace NadekoBot
try {
var obj = new ParseObject("Stats");
obj["OnlineUsers"] = await Task.Run(() => NadekoBot.client.Servers.Sum(x => x.Users.Count()));
obj["RealOnlineUsers"] = await Task.Run(() => NadekoBot
.client.Servers
.Sum(x => x.Users.Where(u => u.Status == UserStatus.Online).Count()));
obj["ConnectedServers"] = NadekoBot.client.Servers.Count();
await obj.SaveAsync();

View File

@@ -13,6 +13,7 @@
public bool? ForwardMessages;
public string OsuApiKey;
public string SoundCloudClientID;
public string MashapeKey;
}
public class AnimeResult
{