public PhotonFilePrintParameters(int parametersPos, byte[] file) { byte[] data = ArraysEmulation.CopyOfRange(file, parametersPos, parametersPos + GetByteSize()); var ds = new BinaryReader(new MemoryStream(data)); bottomLiftDistance = ds.ReadSingle(); bottomLiftSpeed = ds.ReadSingle(); liftingDistance = ds.ReadSingle(); liftingSpeed = ds.ReadSingle(); retractSpeed = ds.ReadSingle(); volumeMl = ds.ReadSingle(); weightG = ds.ReadSingle(); costDollars = ds.ReadSingle(); bottomLightOffDelay = ds.ReadSingle(); lightOffDelay = ds.ReadSingle(); bottomLayerCount = ds.ReadInt32(); p1 = ds.ReadInt32(); p2 = ds.ReadInt32(); p3 = ds.ReadInt32(); p4 = ds.ReadInt32(); }
public static List <PhotonFileLayer> ReadLayers(PhotonFileHeader photonFileHeader, byte[] fileContent, int margin, Action <string> reportProgress) { var photonLayer = new PhotonLayer(photonFileHeader.GetResolutionX(), photonFileHeader.GetResolutionY()); var layers = new List <PhotonFileLayer>(); int antiAliasLevel = 1; if (photonFileHeader.GetVersion() > 1) { antiAliasLevel = photonFileHeader.GetAntiAliasingLevel(); } int layerCount = photonFileHeader.GetNumberOfLayers(); var start = photonFileHeader.GetLayersDefinitionOffsetAddress(); var ds = new BinaryReader(new MemoryStream(fileContent, start, fileContent.Length - start)); { var layerMap = new Dictionary <int, PhotonFileLayer>(); for (int i = 0; i < layerCount; i++) { reportProgress?.Invoke("Reading photon file layer " + (i + 1) + "/" + photonFileHeader.GetNumberOfLayers()); var layer = new PhotonFileLayer(ds) { photonFileHeader = photonFileHeader }; layer.imageData = ArraysEmulation.CopyOfRange(fileContent, layer.dataAddress, layer.dataAddress + layer.dataSize); layers.Add(layer); layerMap[i] = layer; } if (antiAliasLevel > 1) { for (int a = 0; a < (antiAliasLevel - 1); a++) { for (int i = 0; i < layerCount; i++) { reportProgress?.Invoke("Reading photon file AA " + (2 + a) + "/" + antiAliasLevel + " layer " + (i + 1) + "/" + photonFileHeader.GetNumberOfLayers()); var layer = new PhotonFileLayer(ds) { photonFileHeader = photonFileHeader }; layer.imageData = ArraysEmulation.CopyOfRange(fileContent, layer.dataAddress, layer.dataAddress + layer.dataSize); layerMap[i].AddAntiAliasLayer(layer); } } } } photonLayer.UnLink(); return(layers); }
public PhotonFilePreview(int previewAddress, byte[] file) { byte[] data = ArraysEmulation.CopyOfRange(file, previewAddress, previewAddress + 32); var ds = new BinaryReader(new MemoryStream(data)); resolutionX = ds.ReadInt32(); resolutionY = ds.ReadInt32(); imageAddress = ds.ReadInt32(); dataSize = ds.ReadInt32(); p1 = ds.ReadInt32(); p2 = ds.ReadInt32(); p3 = ds.ReadInt32(); p4 = ds.ReadInt32(); rawImageData = ArraysEmulation.CopyOfRange(file, imageAddress, imageAddress + dataSize); DecodeImageData(); }
public PhotonFileMachineInfo(int address, int byteSize, byte[] file) { this.infoByteSize = byteSize; if (byteSize > 0) { byte[] data = ArraysEmulation.CopyOfRange(file, address, address + byteSize); var ds = new BinaryReader(new MemoryStream(data)); { u1 = ds.ReadInt32(); u2 = ds.ReadInt32(); u3 = ds.ReadInt32(); u4 = ds.ReadInt32(); u5 = ds.ReadInt32(); u6 = ds.ReadInt32(); u7 = ds.ReadInt32(); machineNameAddress = ds.ReadInt32(); machineNameSize = ds.ReadInt32(); u8 = ds.ReadInt32(); u9 = ds.ReadInt32(); u10 = ds.ReadInt32(); u11 = ds.ReadInt32(); u12 = ds.ReadInt32(); u13 = ds.ReadInt32(); u14 = ds.ReadInt32(); u15 = ds.ReadInt32(); u16 = ds.ReadInt32(); u17 = ds.ReadInt32(); } machineName = ArraysEmulation.CopyOfRange(file, machineNameAddress, machineNameAddress + machineNameSize); } }