public DecodedFile(byte[] array, String name) { this.fileHeader = new GM1FileHeader(array); this.fileHeader.Name = name; this.palette = new Palette(array); this.images = new List <TGXImage>(); actualPositionInByteArray = (GM1FileHeader.fileHeaderSize + Palette.paletteSize);; if (fileHeader.IDataType == (UInt32)GM1FileHeader.DataType.Animations) { CreateImagesFromAnimationFile(array); } }
/// <summary> /// Decode the actual GM1 File to Imgs and the typical headers /// </summary> /// <param name="array">The GM1 File as Array</param> /// <param name="name">Name of the File</param> /// <returns></returns> public bool DecodeGm1File(byte[] array, String name) { if (Logger.Loggeractiv) { Logger.Log("DecodeGm1File:\nFile:" + name); } fileArray = array; if (this.fileHeader == null) { this.fileHeader = new GM1FileHeader(array); this.fileHeader.Name = name; if (fileHeader.IDataType == (UInt32)GM1FileHeader.DataType.Animations) { this.palette = new Palette(array); } if (Logger.Loggeractiv) { Logger.Log("Datatype" + ((GM1FileHeader.DataType)fileHeader.IDataType)); } } actualPositionInByteArray = (GM1FileHeader.fileHeaderSize + Palette.paletteSize); this._TGXImage = new List <TGXImage>(); this.tilesImage = new List <TilesImage>(); //Supported Types try { switch ((GM1FileHeader.DataType)fileHeader.IDataType) { case GM1FileHeader.DataType.Animations: case GM1FileHeader.DataType.Interface: case GM1FileHeader.DataType.TGXConstSize: case GM1FileHeader.DataType.Font: CreateImages(array); return(true); case GM1FileHeader.DataType.NOCompression: case GM1FileHeader.DataType.NOCompression1: CreateNoCompressionImages(array, ((GM1FileHeader.DataType)fileHeader.IDataType == GM1FileHeader.DataType.NOCompression1) ? 0 : 7); return(true); case GM1FileHeader.DataType.TilesObject: CreateTileImage(array); return(true); default: break; } } catch (Exception e) { if (Logger.Loggeractiv) { Logger.Log("Exception:\n" + e.Message); } MessageBoxWindow messageBox = new MessageBoxWindow(MessageBoxWindow.MessageTyp.Info, "Something went wrong: pls add a issue on the Github Page\n\nError:\n" + e.Message); messageBox.Show(); return(false); } return(false); }