/// <summary> /// Processes a new image part /// </summary> /// <param name="filename">Filename.</param> /// <param name="header">Header.</param> public void NewImage(string filename, GRBImageHeader header) { lock (syncLock) { if (ImageCache == null) { if (SaveDQF) { DQF = new ImageAssembler((int)header.width, (int)header.height, Epoch); } ImageCache = new ImageAssembler((int)header.width, (int)header.height, Epoch); } if (SaveDQF) { // Separate DQF string dqfFilename = $"{filename}.dqf"; try { byte[] buffer = File.ReadAllBytes(filename); buffer = buffer.Skip((int)header.dqfOffset).ToArray(); File.WriteAllBytes(dqfFilename, buffer); } catch (Exception e) { UIConsole.Error($"Error slicing DQF file to {filename}.dqf: {e.Message}"); UIConsole.Debug($"{e}"); } DQF.AppendJ2K(dqfFilename); try { File.Delete(dqfFilename); } catch (IOException e) { UIConsole.Error($"Error erasing file {filename}: {e.Message}"); UIConsole.Debug($"{e}"); } } ImageCache.AppendJ2K(filename); try { File.Delete(filename); } catch (IOException e) { UIConsole.Error($"Error erasing file {filename}: {e.Message}"); UIConsole.Debug($"{e}"); } if (ImageCache.Done) { ProcessBigImage(header); } } }