public static Bitmap GetPreview(ByteFileInfo file) { switch (FileHandler.GetType(file)) { case "NCGR": NCGR ncgr = new NCGR(file.Data); FileHandler.LastGraphic = ncgr; if (FileHandler.LastPal == null) { return((Bitmap)null); } try { return(ncgr.CharacterData.ToBitmap(FileHandler.LastPal, 0)); } catch { return((Bitmap)null); } case "NCLR": MKDS_Course_Modifier.G2D_Binary_File_Format.NCLR nclr = new MKDS_Course_Modifier.G2D_Binary_File_Format.NCLR(file.Data); System.Drawing.Color[] colorArray1 = nclr.PaletteData.ToColorArray(); Bitmap bitmap1 = new Bitmap(128, (int)Math.Round((double)colorArray1.Length / 16.0) * 8); using (Graphics graphics = Graphics.FromImage((Image)bitmap1)) { graphics.Clear(System.Drawing.Color.Transparent); int num = 0; for (int y = 0; y < (int)Math.Round((double)colorArray1.Length / 16.0) * 8; y += 8) { for (int x = 0; x < 128; x += 8) { if (num < colorArray1.Length) { graphics.FillRectangle((Brush) new SolidBrush(colorArray1[num++]), x, y, 8, 8); } } } } FileHandler.LastPal = nclr; return(bitmap1); case "NCL": System.Drawing.Color[] colorArray2 = new NCL(file.Data).PaletteData.ToColorArray(); Bitmap bitmap2 = new Bitmap(128, (int)Math.Round((double)colorArray2.Length / 16.0) * 8); using (Graphics graphics = Graphics.FromImage((Image)bitmap2)) { graphics.Clear(System.Drawing.Color.Transparent); int num = 0; for (int y = 0; y < (int)Math.Round((double)colorArray2.Length / 16.0) * 8; y += 8) { for (int x = 0; x < 128; x += 8) { if (num < colorArray2.Length) { graphics.FillRectangle((Brush) new SolidBrush(colorArray2[num++]), x, y, 8, 8); } } } } return(bitmap2); case "NSCR": MKDS_Course_Modifier.G2D_Binary_File_Format.NSCR nscr = new MKDS_Course_Modifier.G2D_Binary_File_Format.NSCR(file.Data); if (FileHandler.LastPal == null || FileHandler.LastGraphic == null) { return((Bitmap)null); } try { return(nscr.ScreenData.ToBitmap(FileHandler.LastGraphic, FileHandler.LastPal)); } catch { return((Bitmap)null); } case "NCER": MKDS_Course_Modifier.G2D_Binary_File_Format.NCER ncer = new MKDS_Course_Modifier.G2D_Binary_File_Format.NCER(file.Data); if (FileHandler.LastPal == null || FileHandler.LastGraphic == null) { return((Bitmap)null); } try { return(ncer.CellBankBlock.CellDataBank.GetBitmap(0, FileHandler.LastGraphic, FileHandler.LastPal)); } catch { return((Bitmap)null); } case "ICG.BIN": case "NCG.BIN": FileHandler.LastRawGraphic = file.Data; return(FileHandler.LastRawPal != null?Graphic.ConvertData(FileHandler.LastRawGraphic, FileHandler.LastRawPal, 0, (int)Math.Sqrt(FileHandler.LastRawPal.Length / 2 >= 256 ? (double)FileHandler.LastRawGraphic.Length : (double)(FileHandler.LastRawGraphic.Length * 2)), (int)Math.Sqrt(FileHandler.LastRawPal.Length / 2 >= 256 ? (double)FileHandler.LastRawGraphic.Length : (double)(FileHandler.LastRawGraphic.Length * 2)), FileHandler.LastRawPal.Length / 2 >= 256?Graphic.GXTexFmt.GX_TEXFMT_PLTT256 : Graphic.GXTexFmt.GX_TEXFMT_PLTT16, Graphic.NNSG2dCharacterFmt.NNS_G2D_CHARACTER_FMT_CHAR, true, false) : (Bitmap)null); case "ICL.BIN": case "NCL.BIN": System.Drawing.Color[] colorArray3 = Graphic.ConvertABGR1555(file.Data); Bitmap bitmap3 = new Bitmap(128, (int)Math.Round((double)colorArray3.Length / 16.0) * 8); using (Graphics graphics = Graphics.FromImage((Image)bitmap3)) { int num = 0; for (int y = 0; y < (int)Math.Round((double)colorArray3.Length / 16.0) * 8; y += 8) { for (int x = 0; x < 128; x += 8) { graphics.FillRectangle((Brush) new SolidBrush(colorArray3[num++]), x, y, 8, 8); } } } FileHandler.LastRawPal = file.Data; return(bitmap3); case "ISC.BIN": case "NSC.BIN": if (FileHandler.LastRawPal != null && FileHandler.LastRawGraphic != null) { try { return(Graphic.ConvertData(FileHandler.LastRawGraphic, (int)Math.Sqrt(FileHandler.LastRawPal.Length / 2 >= 256 ? (double)FileHandler.LastRawGraphic.Length : (double)(FileHandler.LastRawGraphic.Length * 2)), (int)Math.Sqrt(FileHandler.LastRawPal.Length / 2 >= 256 ? (double)FileHandler.LastRawGraphic.Length : (double)(FileHandler.LastRawGraphic.Length * 2)), FileHandler.LastRawPal, file.Data, (int)Math.Sqrt((double)(file.Data.Length / 2)) * 8, (int)Math.Sqrt((double)(file.Data.Length / 2)) * 8, FileHandler.LastRawPal.Length / 2 >= 256 ? Graphic.GXTexFmt.GX_TEXFMT_PLTT256 : Graphic.GXTexFmt.GX_TEXFMT_PLTT16, Graphic.NNSG2dCharacterFmt.NNS_G2D_CHARACTER_FMT_CHAR)); } catch { } } return((Bitmap)null); case "ENPG": try { return(Graphic.ConvertData(((IEnumerable <byte>)file.Data).ToList <byte>().GetRange(0, file.Data.Length - 512).ToArray(), ((IEnumerable <byte>)file.Data).ToList <byte>().GetRange(file.Data.Length - 512, 512).ToArray(), 0, (int)Math.Sqrt((double)(file.Data.Length - 512)), (int)Math.Sqrt((double)(file.Data.Length - 512)), Graphic.GXTexFmt.GX_TEXFMT_PLTT256, Graphic.NNSG2dCharacterFmt.NNS_G2D_CHARACTER_FMT_BMP, true, false)); } catch { return((Bitmap)null); } case "BMP": return((Bitmap)Image.FromStream((Stream) new MemoryStream(file.Data))); case "TEX": return(new TEX(file.Data).GetBitmap(0)); default: return((Bitmap)null); } }
//CdL: nome, annidicorso,cfu per laurea, corsi associali public CorsoDiLaurea(NCL nomeCorsoLaurea, int anniDiCorso, int cfuPerLaurea) { nomeCorsoLaurea = NomeCorsoLaurea; //TO FIX anniDiCorso = AnniDiCorso; cfuPerLaurea = CFUPerLaurea; }