static void appendLogos(List <string> logosForBuilding, ref Graphics g, int totalHeight, int totalWidth) { int noImgs = logosForBuilding.Count; List <Image> imgs = new List <Image>(); List <Size> imgSizes = new List <Size>(); int spacer = 5; int checkWidth = 0; // step one: get all sizes (not all logos are obviously square) and scale them to fit vertically Image single = null; float scale = 0, totalHeightf = (float)totalHeight; Size tmp = default(Size); int x_pos = 0; for (int i = 0; i < logosForBuilding.Count; i++) { try { single = ImageAllocator.LoadImageFastFromFile(logosForBuilding[i]); } catch (Exception) { BaseConfig.MyAnimeLog.Write("Could not load Image file... " + logosForBuilding[i]); return; } scale = totalHeightf / (float)single.Size.Height; tmp = new Size((int)(single.Width * scale), (int)(single.Height * scale)); checkWidth += tmp.Width; imgSizes.Add(tmp); imgs.Add(single); } // step two: check if we are too big horizontally and if so scale again checkWidth += imgSizes.Count * spacer; if (checkWidth > totalWidth) { scale = (float)checkWidth / (float)totalWidth; for (int i = 0; i < imgSizes.Count; i++) { imgSizes[i] = new Size((int)(imgSizes[i].Width / scale), (int)(imgSizes[i].Height / scale)); } } // step three: finally draw them for (int i = 0; i < imgs.Count; i++) { g.DrawImage(imgs[i], x_pos, totalHeight - imgSizes[i].Height, imgSizes[i].Width, imgSizes[i].Height); x_pos += imgSizes[i].Width + spacer; } }
/* * static string LogoSourceBluRay = mediaFolder + @"BLURAY.png"; * static string LogoSourceDVD = mediaFolder + @"DVD.png"; * * static string LogoCodecX264 = mediaFolder + @"AVC.png"; * static string LogoCodecXVid = mediaFolder + @"XVID.png"; * static string LogoCodecDivx = mediaFolder + @"DIVX.png"; * static string LogoCodecMpeg2 = mediaFolder + @"MP2V.png"; * static string LogoCodecAVC = mediaFolder + @"AVC.png"; * * static string LogoRes720 = mediaFolder + @"720p.png"; * static string LogoRes1080 = mediaFolder + @"1080p.png"; * * static string LogoDim16x9 = mediaFolder + @"WIDESCREEN.png"; * static string LogoDim4x3 = mediaFolder + @"FULLSCREEN.png"; */ public static string buildRating(double value, string offstar, string onstar, int width, int height) { try { Bitmap b = new Bitmap(width * 10, height); Image img = b; Graphics g = Graphics.FromImage(img); BaseConfig.MyAnimeLog.Write("Source: " + offstar + " Dest: " + onstar); Image off = ImageAllocator.LoadImageFastFromFile(GUIGraphicsContext.Skin + @"\Media\" + offstar); Image on = ImageAllocator.LoadImageFastFromFile(GUIGraphicsContext.Skin + @"\Media\" + onstar); int val = (int)Math.Floor(value); string tmpfile = onstar + "_" + ((int)val).ToString(CultureInfo.InvariantCulture) + "_"; for (int x = 0; x < 10; x++) { if (x < val) { g.DrawImage(on, new Rectangle(x * width, 0, width, height), new Rectangle(0, 0, on.Width, on.Height), GraphicsUnit.Pixel); } if (x >= val) { g.DrawImage(off, new Rectangle(x * width, 0, width, height), new Rectangle(0, 0, off.Width, off.Height), GraphicsUnit.Pixel); } if (x == val) { int sub = (int)((value - val) * width); tmpfile += sub; if (sub > 0) { var subSrc = (int)((value - val) * on.Width); g.DrawImage(on, new Rectangle(x * width, 0, sub, height), new Rectangle(0, 0, subSrc, on.Height), GraphicsUnit.Pixel); } } } tmpfile += ".png"; tmpfile = Path.Combine(pathfortmpfile, @"\anime3_" + tmpfile + ".png"); return(ImageAllocator.GetOtherImage(b, tmpfile, new Size(), true)); } catch (Exception ex) { BaseConfig.MyAnimeLog.Write("The Rating Building Engine generated an error: " + ex.ToString()); return(string.Empty); } }