private bool CreateIcon(string[] args) { IconImage iconImg = new IconImage(); string framePath = null; string titlePath = null; string outPath = null; for (int i = 0; i < args.Length; i++) { switch (args[i]) { case "create-icon": break; case "-frame": if (i + 1 < args.Length && framePath == null) { framePath = args[++i]; break; } else { Cll.Log.WriteLine("Error in the \"-frame\" option."); return(false); } case "-title": if (i + 1 < args.Length && titlePath == null) { titlePath = args[++i]; break; } else { Cll.Log.WriteLine("Error in the \"-title\" option."); return(false); } case "-out": if (i + 1 < args.Length && outPath == null) { outPath = args[++i]; break; } else { Cll.Log.WriteLine("Error in the \"-out\" option."); return(false); } default: Cll.Log.WriteLine("Invalid option \"" + args[i] + "\"."); return(false); } } if (framePath != null && !File.Exists(framePath)) { Cll.Log.WriteLine("The frame image \"" + framePath + "\" not exists."); return(false); } if (titlePath != null && !File.Exists(titlePath)) { Cll.Log.WriteLine("The title screen \"" + titlePath + "\" not exists."); return(false); } if (outPath != null) { if (!Directory.Exists(outPath)) { Cll.Log.WriteLine("The \"" + outPath + "\" folder not exist."); return(false); } } else { outPath = Environment.CurrentDirectory; } outPath += "\\icon.png"; Cll.Log.WriteLine("Creating icon -----------------------------------------------------------------"); if (titlePath != null) { Cll.Log.WriteLine("title: " + titlePath); } if (framePath != null) { Cll.Log.WriteLine("frame: " + framePath); } if (outPath != null) { Cll.Log.WriteLine("out: " + outPath); } System.Drawing.Bitmap icon = null; try { if (framePath != null) { iconImg.Frame = new System.Drawing.Bitmap(framePath); } if (titlePath != null) { iconImg.TitleScreen = new System.Drawing.Bitmap(titlePath); } icon = iconImg.Create(); icon.Save(outPath, System.Drawing.Imaging.ImageFormat.Png); icon.Dispose(); return(true); } catch { return(false); } finally { iconImg.Dispose(); if (icon != null) { icon.Dispose(); } } }
private bool InjectImages() { string currentDir = Environment.CurrentDirectory; Bitmap bootTvImg; Bitmap bootDrcImg; Bitmap iconImg; Bitmap tmp; Graphics g; try { Cll.Log.WriteLine("Creating bitmaps."); if (BootTvPath != null) { tmp = new Bitmap(BootTvPath); } else { tmp = BootTvImg.Create(); } bootTvImg = new Bitmap(1280, 720, PixelFormat.Format24bppRgb); g = Graphics.FromImage(bootTvImg); g.DrawImage(tmp, new Rectangle(0, 0, 1280, 720)); g.Dispose(); tmp.Dispose(); if (BootDrcPath != null) { tmp = new Bitmap(BootDrcPath); } else { tmp = BootDrcImg.Create(); } bootDrcImg = new Bitmap(854, 480, PixelFormat.Format24bppRgb); g = Graphics.FromImage(bootDrcImg); g.DrawImage(tmp, new Rectangle(0, 0, 854, 480)); g.Dispose(); tmp.Dispose(); if (IconPath != null) { tmp = new Bitmap(IconPath); } else { tmp = IconImg.Create(); } iconImg = new Bitmap(128, 128, PixelFormat.Format32bppArgb); g = Graphics.FromImage(iconImg); g.DrawImage(tmp, new Rectangle(0, 0, 128, 128)); g.Dispose(); tmp.Dispose(); Cll.Log.WriteLine("Bitmaps created."); } catch { Cll.Log.WriteLine("Error creating bitmaps."); return(false); } if (!NusContent.ConvertToTGA(bootTvImg, currentDir + "\\base\\meta\\bootTvTex.tga")) { Cll.Log.WriteLine("Error creating \"bootTvTex.tga\" file."); return(false); } if (!NusContent.ConvertToTGA(bootDrcImg, currentDir + "\\base\\meta\\bootDrcTex.tga")) { Cll.Log.WriteLine("Error creating \"bootDrcTex.tga\" file."); return(false); } if (!NusContent.ConvertToTGA(iconImg, currentDir + "\\base\\meta\\iconTex.tga")) { Cll.Log.WriteLine("Error creating \"iconTex.tga\" file."); return(false); } Cll.Log.WriteLine("Injected TGA files."); return(true); }