public void Append_Sprite(TIM sprite_sheet, Bitmap dest) { if (alpha != 3072) { return; } if (sprite_width > sprite_sheet.Image.Width) { sprite_width = (short)sprite_sheet.Image.Width; } Bitmap sprite = sprite_sheet.Image.Clone(new Rectangle(m_Sprite_Sheet_Coord, new Size(sprite_width, sprite_height)), sprite_sheet.Image.PixelFormat); sprite.MakeTransparent(Color.FromArgb(0, 0, 0, 0)); if (flip_vertically) { sprite.RotateFlip(RotateFlipType.RotateNoneFlipX); } if (flip_horizontally) { sprite.RotateFlip(RotateFlipType.RotateNoneFlipY); } Bitmap tempBitmap = new Bitmap(dest.Width, dest.Height); using (Graphics grD = Graphics.FromImage(dest)) { grD.DrawImage(sprite, m_World_Position); } }
private TimeScope Map(TIM tim, Catalog catalog) { DateTime?stamp1 = null; if (tim.A.HasValue) { stamp1 = tim.A.Value; } DateTime?stamp2 = null; if (tim.B.HasValue) { stamp2 = tim.B.Value; } var timeScope = new TimeScope { TimeStamp1 = stamp1, TimeStamp2 = stamp2, DateContext = DateContextEnum.ActualStart }; if (catalog.TimeScopes == null) { catalog.TimeScopes = new List <TimeScope>(); } catalog.TimeScopes.Add(timeScope); return(timeScope); }
private static void AreEqual(TimeScope timeScope, TIM tim) { Assert.AreEqual(timeScope.TimeStamp1, tim.A); Assert.AreEqual(timeScope.TimeStamp2, tim.B); // todo. check other attributes and PTN, dlvs,.... }
private static IEnumerable <XElement> CreateDlvElements(TIM tim) { var dlvs = tim.Items.Where(x => x.GetType() == typeof(DLV)).Cast <DLV>().ToList(); if (dlvs.Any()) { return(dlvs.Select(x => { var dlvElement = new XElement("DLV"); var ddi = x.A; if (String.IsNullOrEmpty(ddi)) { dlvElement.SetAttributeValue("A", ddi); } else { var value = int.Parse(ddi).ToString("X4"); dlvElement.SetAttributeValue("A", value); } dlvElement.SetAttributeValue("B", x.B); dlvElement.SetAttributeValue("C", x.C); dlvElement.SetAttributeValue("D", x.D); dlvElement.SetAttributeValue("E", x.E); dlvElement.SetAttributeValue("F", x.F); return dlvElement; }).ToList()); } return(new List <XElement>()); }
private static SpatialValue CreateSpatialValue(TIM tim, byte order, int value) { var dlvs = tim.Items.Where(x => x.GetType() == typeof(DLV)); var matchingDlv = dlvs.ElementAtOrDefault(order) as DLV; if (matchingDlv == null) { return(null); } var ddis = DdiLoader.Ddis; var resolution = 1d; if (matchingDlv.A != null && ddis.ContainsKey(Convert.ToInt32(matchingDlv.A, 16))) { resolution = ddis[Convert.ToInt32(matchingDlv.A, 16)].Resolution; } var spatialValue = new SpatialValue { Id = order, Dlv = matchingDlv, Value = value * resolution, }; return(spatialValue); }
public void GivenOperationDataWhenMapThenXmlReaderIsCalled() { _operationData.Id.UniqueIds.Add(new UniqueId { Id = "TLG00016", IdType = IdTypeEnum.String, Source = UniqueIdMapper.IsoSource }); var meters = new List <WorkingData> { new NumericWorkingData() }; var sections = new List <DeviceElementUse> { new DeviceElementUse { GetWorkingDatas = () => meters } }; var sectionsByDepth = new Dictionary <int, IEnumerable <DeviceElementUse> > { { 0, sections } }; _operationData.GetDeviceElementUses = x => sectionsByDepth[x]; _operationData.MaxDepth = 0; var tim = new TIM(); _timHeaderMock.Setup(x => x.Map(meters)).Returns(tim); MapSingle(); _xmlReaderMock.Verify(x => x.WriteTlgXmlData(_datacardPath, "TLG00016.xml", tim)); }
public void Setup() { _datacardPath = "dataCardPath"; _tlg = new TLG(); _tlgs = new List <TLG> { _tlg }; _tim = new TIM(); _tims = new List <TIM> { _tim }; _linkedIds = new Dictionary <string, List <UniqueId> >(); _spatialRecordMapperMock = new Mock <ISpatialRecordMapper>(); _xmlReaderMock = new Mock <IXmlReader>(); _binaryReaderMock = new Mock <IBinaryReader>(); _sectionMapperMock = new Mock <ISectionMapper>(); _uniqueIdMapperMock = new Mock <IUniqueIdMapper>(); _tlg.A = "fileName"; _xmlReaderMock.Setup(x => x.ReadTlgXmlData(_datacardPath, _tlg.A + ".xml")).Returns(_tims); _isoSpatialRows = new List <ISOSpatialRow>(); _binaryReaderMock.Setup(x => x.Read(_datacardPath, _tlg.A + ".bin", _tim)).Returns(_isoSpatialRows); _sections = new List <DeviceElementUse>(); _sectionMapperMock.Setup(x => x.Map(_tims, _isoSpatialRows)).Returns(_sections); _operationDataMapper = new OperationDataMapper(_xmlReaderMock.Object, _binaryReaderMock.Object, _spatialRecordMapperMock.Object, _sectionMapperMock.Object, _uniqueIdMapperMock.Object); }
public void GivenTimHeaderWhenWriteThenDlvHasAttributes() { var dlv = new DLV { A = "123", B = 456, C = "DLV-1", D = 2, E = new byte(), F = new byte() }; var timHeader = new TIM { Items = new List <DLV> { dlv }.ToArray() }; var xdoc = _xmlReader.WriteTlgXmlData(_dataPath, _fileName, timHeader); var actualDlv = xdoc.Element("TIM").Elements("DLV").First(); var expected = "007B"; Assert.AreEqual(expected, actualDlv.Attribute("A").Value); Assert.AreEqual(dlv.B.Value.ToString(), actualDlv.Attribute("B").Value); Assert.AreEqual(dlv.C, actualDlv.Attribute("C").Value); Assert.AreEqual(dlv.D.Value.ToString(), actualDlv.Attribute("D").Value); Assert.AreEqual(dlv.E.Value.ToString(), actualDlv.Attribute("E").Value); Assert.AreEqual(dlv.F.Value.ToString(), actualDlv.Attribute("F").Value); }
public void Generate_Animation(TIM sprite_sheet) { foreach (Anim_Group g in Groups) { g.Generate_Frame(sprite_sheet); } }
public TIM Map(IEnumerable <WorkingData> workingData) { var tim = new TIM { ASpecified = true, A = null, BSpecified = false, B = null, CSpecified = false, C = null, DSpecified = true, D = TIMD.Item4, }; // TODO: This is not mapping the PTN Header? var ptn = _ptnHeaderMapper.Map(); var dlvs = _dlvHeaderMapper.Map(workingData).ToList(); var iWriters = new List <IWriter>(); if (ptn != null) { iWriters.Add(ptn); } if (dlvs != null) { iWriters.AddRange(dlvs); } tim.Items = iWriters.ToArray(); return(tim); }
public void Stop() { if (Running) { TIM.Stop(); this.Value = 0; } }
static void Main(string[] args) { string timFile = args.Length > 0 ? args[0] : "LayoutTest.xml"; Core.Init(); Core.Run(TIM.Load <Program>(timFile)); Core.Done(); }
/// <summary> /// Export a TIM file to a common image format. /// </summary> /// <param name="tim">The TIM file.</param> /// <param name="clutIndex">The index of the CLUT to export with.</param> /// <param name="filePath">The file path to export to.</param> /// <param name="format">The image format to export to.</param> public void ExportImage(TIM tim, int clutIndex, string filePath, ImageFormat format) { Log.Information($"Exporting image ({format}) to: {filePath}"); var image = LibLSDUtil.GetImageDataFromTIM(tim, clutIndex, flip: false); Bitmap bmp = ImageUtil.ImageDataToBitmap(image.data, image.width, image.height); bmp.Save(filePath, format); }
public static (float[] data, int width, int height) GetImageDataFromTIM(TIM tim, bool flip = true) { IColor[,] imageColors = tim.GetImage(); int width = imageColors.GetLength(1); int height = imageColors.GetLength(0); float[] imageData = ImageColorsToData(imageColors, width, height, flip); return(imageData, width, height); }
public void Generate_Frame(TIM sprite_sheet) { m_Group_Image = new Bitmap(sprite_sheet.Image.Width, sprite_sheet.Image.Height); foreach (Anim_Frame f in Frames) { f.Append_Sprite(sprite_sheet, m_Group_Image); } }
/// <summary> /// Export a TIM file to a common image format. /// </summary> /// <param name="tim">The TIM file.</param> /// <param name="filePath">The file path to export to.</param> /// <param name="format">The image format to export to.</param> public void ExportImage(TIM tim, string filePath, ImageFormat format) { Logger.Log()(LogLevel.INFO, $"Exporting image ({format}) to: {filePath}"); var image = LibLSDUtil.GetImageDataFromTIM(tim, flip: false); Bitmap bmp = ImageUtil.ImageDataToBitmap(image.data, image.width, image.height); bmp.Save(filePath, format); }
public void Setup() { _tim = new TIM(); _isoSpatialRows = new List <ISOSpatialRow>(); _representationMapperMock = new Mock <IRepresentationMapper>(); _enumeratorMeterFactoryMock = new Mock <IEnumeratedMeterFactory>(); _uniqueIdMapperMock = new Mock <IUniqueIdMapper>(); _meterMapper = new MeterMapper(_representationMapperMock.Object, _enumeratorMeterFactoryMock.Object, _uniqueIdMapperMock.Object); }
public void GivenNullTimHeaderWhenReadThenReturnedEmpty() { _tim = null; _bytes.Add(_numberOfDlvs); var result = Read(); Assert.IsEmpty(result); }
static void Main(string[] args) { TIM tim = new TIM(@"C:\Users\Dylan\Downloads\exar2\fpack_extract\anm\M027A\M027A_12.TIM.lzr"); HSE_Animation hse = new HSE_Animation(@"C:\Users\Dylan\Downloads\exar2\fpack_extract\anm\M027A\M027A_01WA.hse.lzr"); hse.Generate_Animation(tim); hse.Export_Animation(@"D:\Github\Hymma\anim.gif"); hse.Export_Frames(@"D:\Github\Hymma\"); }
public TIMDocument CreateDocument(TIM tim) { Mesh textureMesh = Mesh.CreateQuad(_shader); var img = LibLSDUtil.GetImageDataFromTIM(tim); textureMesh.Textures.Add(new Texture2D(img.width, img.height, img.data)); return(new TIMDocument(tim, textureMesh)); }
/// <summary> /// Get the pixels and width/height from a loaded TIM. /// </summary> /// <param name="tim">The loaded TIM.</param> /// <returns>TimData containing the TIM data.</returns> public static TimData GetImageDataFromTIM(TIM tim) { TimData data; data.Colors = tim.GetImage(); data.Width = data.Colors.GetLength(1); data.Height = data.Colors.GetLength(0); return(data); }
public void GivenPathAndTimHeaderWhenWriteTlgXmlDataThenTlgFileIsCreated() { var tim = new TIM(); _xmlReader.WriteTlgXmlData(Path.Combine(_dataPath, "TASKDATA"), _fileName, tim); var expectedPath = Path.Combine(_dataPath, "TASKDATA", _fileName); Assert.IsTrue(File.Exists(expectedPath)); }
//UserControl esegue l'override del metodo Dispose per pulire l'elenco dei componenti. protected override void Dispose(bool disposing) { if (disposing) { Stop(); TIM.Elapsed -= TIM_Elapsed; TIM.Close(); } base.Dispose(disposing); }
public XDocument WriteTlgXmlData(string datacardPath, string fileName, TIM timHeader) { var filePath = Path.Combine(datacardPath, fileName); var timElement = CreateTimElement(timHeader); var xdoc = new XDocument(timElement); xdoc.Save(filePath); return(xdoc); }
/// <summary> /// Gets the correct BaseFile class by comparing the file with the known header signatures. /// </summary> /// <param name="filePath">Filepath</param> /// <returns></returns> public static BaseFile GetTypeFromFile(string filePath) { byte[] buffer; using (BinaryReader reader = new BinaryReader(new FileStream(filePath, FileMode.Open))) { if (reader.BaseStream.Length < 256) { buffer = new byte[reader.BaseStream.Length]; reader.Read(buffer, 0, buffer.Length); } else { buffer = new byte[256]; reader.Read(buffer, 0, 256); } } if (BG.Compare(buffer)) { return(new BGFile(filePath)); } if (LZB.Compare(buffer)) { return(new LZBFile(filePath)); } if (PACK.Compare(buffer)) { return(new PBFile(filePath)); } if (SEQ.Compare(buffer)) { return(new SEQFile(filePath)); } if (STR.Compare(filePath)) { return(new STRFile(filePath)); } if (TIM.Compare(buffer)) { return(new TIMFile(filePath)); } if (VB.Compare(buffer)) { return(new VBFile(filePath)); } if (VH.Compare(buffer)) { return(new VHFile(filePath)); } if (XA.Compare(filePath)) { return(new XAFile(filePath)); } return(new BaseFile(filePath)); }
public void TestTIMWithMultipleCLUTs() { using (BinaryReader br = new BinaryReader(TestUtil.OpenTestData("ETC.TIM"))) { TIM tim = new TIM(br); Assert.True(tim.Header.HasCLUT); Assert.IsNotNull(tim.ColorLookup); Assert.AreEqual(TIMHeader.PixelModes.CLUT4Bit, tim.Header.PixelMode); Assert.AreEqual(4, tim.ColorLookup.Value.NumberOfCLUTs); } }
public List <WorkingData> Map(TIM tim, IEnumerable <ISOSpatialRow> isoSpatialRows, int sectionId) { var meters = new List <WorkingData>(); var dlvs = tim.Items.Where(x => (x as DLV) != null).Cast <DLV>(); for (int order = 0; order < dlvs.Count(); order++) { var dlv = dlvs.ElementAt(order); meters.AddRange(Map(dlv, isoSpatialRows, sectionId, order)); } return(meters); }
public void GivenTimHeaderWithIsNullStateWhenWriteThenPtnDoesntAddAtributes() { var ptn = new PTN { ASpecified = false, A = null, BSpecified = false, B = null, CSpecified = false, C = null, DSpecified = false, D = null, ESpecified = false, E = null, FSpecified = false, F = null, GSpecified = false, G = null, HSpecified = false, H = null, ISpecified = false, I = null }; var tim = new TIM { Items = new List <IWriter> { ptn }.ToArray() }; var xdoc = _xmlReader.WriteTlgXmlData(_dataPath, _fileName, tim); var actualPtn = xdoc.Element("TIM").Element("PTN"); Assert.IsNull(actualPtn.Attribute("A")); Assert.IsNull(actualPtn.Attribute("B")); Assert.IsNull(actualPtn.Attribute("C")); Assert.IsNull(actualPtn.Attribute("D")); Assert.IsNull(actualPtn.Attribute("E")); Assert.IsNull(actualPtn.Attribute("F")); Assert.IsNull(actualPtn.Attribute("G")); Assert.IsNull(actualPtn.Attribute("H")); Assert.IsNull(actualPtn.Attribute("I")); }
//UserControl esegue l'override del metodo Dispose per pulire l'elenco dei componenti. protected override void Dispose(bool disposing) { if (disposing) { Stop(); TIM.Close(); /*if ((components != null)) { * components.Dispose(); * }*/ } base.Dispose(disposing); }
public void GivenTimHeaderWhenWriteThenPtnHasValues() { var ptn = new PTN { ASpecified = true, A = -123, BSpecified = true, B = 145, CSpecified = true, C = 123415, DSpecified = true, D = 7, ESpecified = true, E = 98.3, FSpecified = true, F = 33.2, GSpecified = true, G = 231, HSpecified = true, H = 21344, ISpecified = true, I = 231 }; var tim = new TIM { Items = new List <IWriter> { ptn }.ToArray() }; var xdoc = _xmlReader.WriteTlgXmlData(_dataPath, _fileName, tim); var actualPtn = xdoc.Element("TIM").Element("PTN"); Assert.AreEqual(ptn.A.Value.ToString(), actualPtn.Attribute("A").Value); Assert.AreEqual(ptn.B.Value.ToString(), actualPtn.Attribute("B").Value); Assert.AreEqual(ptn.C.Value.ToString(), actualPtn.Attribute("C").Value); Assert.AreEqual(ptn.D.Value.ToString(), actualPtn.Attribute("D").Value); Assert.AreEqual(ptn.E.Value.ToString(), actualPtn.Attribute("E").Value); Assert.AreEqual(ptn.F.Value.ToString(), actualPtn.Attribute("F").Value); Assert.AreEqual(ptn.G.Value.ToString(), actualPtn.Attribute("G").Value); Assert.AreEqual(ptn.H.Value.ToString(), actualPtn.Attribute("H").Value); Assert.AreEqual(ptn.I.Value.ToString(), actualPtn.Attribute("I").Value); }