private void ReadFONT(FileStructure.FNT.FNT FNT) { Height = FNT.Header.Glyphs.Size1; Width = FNT.Header.Glyphs.Size2; Palette = FNT.Palette.Pallete; if (FNT.Header.Glyphs.BitsPerPixel == 4) { PixelFormat = PixelFormats.Indexed4; } else if (FNT.Header.Glyphs.BitsPerPixel == 8) { PixelFormat = PixelFormats.Indexed8; } else { throw new Exception("ReadFONT Error: unknown PixelFormat"); } var DecList = FNT.Compressed.GetDecompressedData(); if (FNT.Header.Glyphs.BitsPerPixel == 4) { Util.ReverseByteInList(DecList); } for (int i = 0; i < DecList.Count; i++) { var Cut = FNT.WidthTable[i] == null ? new VerticalCut(0, (byte)Width) : FNT.WidthTable[i].Value; int index = i + 32; if (DataList.ContainsKey(index)) { DataList[index] = DecList[i]; } else { DataList.Add(index, DecList[i]); } if (CutList.ContainsKey(index)) { CutList[index] = Cut; } else { CutList.Add(index, Cut); } } }
private void OpenFont(FileStructure.FNT.FNT FNT) { try { ReadFONT(FNT); if (CutList.ContainsKey(32)) { CutList[32] = new VerticalCut(10, 20); } } catch (Exception e) { Logging.Write("PersonaEditorLib", e); } }
public static ObjectFile OpenFile(string name, byte[] data, FileType type) { try { object Obj; if (type == FileType.BIN) { Obj = new FileStructure.Container.BIN(data); } else if (type == FileType.SPR) { Obj = new FileStructure.SPR.SPR(data); } else if (type == FileType.TMX) { Obj = new FileStructure.Graphic.TMX(data); } else if (type == FileType.BF) { Obj = new FileStructure.Container.BF(data, name); } else if (type == FileType.PM1) { Obj = new FileStructure.Container.PM1(data); } else if (type == FileType.BMD) { Obj = new FileStructure.Text.BMD(data); } else if (type == FileType.PTP) { Obj = new FileStructure.Text.PTP(data); } else if (type == FileType.FNT) { Obj = new FileStructure.FNT.FNT(data); } else if (type == FileType.BVP) { Obj = new FileStructure.Container.BVP(name, data); } else if (type == FileType.TBL) { try { Obj = new FileStructure.Container.TBL(data, name); } catch { Obj = new FileStructure.Container.BIN(data); } } else if (type == FileType.FTD) { Obj = new FileStructure.Text.FTD(data); } else if (type == FileType.DDS) { Obj = new FileStructure.Graphic.DDS(data); } else if (type == FileType.SPD) { Obj = new FileStructure.SPR.SPD(data); } else { Obj = new FileStructure.DAT(data); } return(new ObjectFile(name, Obj)); } catch { return(new ObjectFile(name, null)); } }