/// <summary> /// SDK initializer which should be called one time only on first script call. /// </summary> public static void Initialize() { ContextOptions.Initialize(); Scanner.Initialize(); TileReader.Initialize(); ScriptLogger.Initialize(); }
public CenteredTileReader(TileReader tileReader, Color color) : base(tileReader) { this.color = color; offsetX = 0; offsetY = 0; // find the number of tiles for the dimension with the largest number of tiles uint numTilesLongestSide = Math.Max(tileReader.NumberTilesX, tileReader.NumberTilesY); // find the number of tiles that is a power of two that is greater than // or equal to numTilesLongestSide uint numTilesPowerOf2 = 0; uint powerOf2 = 0; while (numTilesPowerOf2 < numTilesLongestSide) { powerOf2++; numTilesPowerOf2 = (uint)Math.Pow(2, powerOf2); } numTilesX = numTilesPowerOf2; numTilesY = numTilesPowerOf2; // calculate the offsets offsetX = (numTilesPowerOf2 - tileReader.NumberTilesX) / 2; offsetY = (numTilesPowerOf2 - tileReader.NumberTilesY) / 2; // initialize the blank Bitmap }
public MosaicInfo(TileReader reader) { this.reader = reader; this.ScaleMinIntensity = reader.LoadInfo.TotalMinIntensity; this.ScaleMaxIntensity = reader.LoadInfo.TotalMaxIntensity; this.IsCorrelated = reader.LoadInfo.IsCorrelated; this.IsCompositeRGB = reader.LoadInfo.IsCompositeRGB; }
static void Main(string[] args) { SkillGainTracker skillGainTracker = new SkillGainTracker(Skill.Lumberjacking, new DiscordSkillChangeEventHandler()); skillGainTracker.Start(); TileReader.Initialize(); new RaillessLumberjacking().Start(); skillGainTracker.Stop(); }
static void Main(string[] args) { SkillGainTracker skillGainTracker = new SkillGainTracker(Skill.Mining, new DiscordSkillChangeEventHandler()); skillGainTracker.Start(); ScriptLogger.LogToStealth = true; TileReader.Initialize(); new RaillessMining().MineCave(); skillGainTracker.Stop(); }
/** * Note that the TileReader passed in should support the pyramid algorithm, i.e., that * the foloowing two things should be true: 1) the number of tiles in botht the X and Y * dimmensions should be equal and 2) that number should be a power of two. */ public AsynchronousPyramidGenerator(TileReader tileReader, string outputDir) { this.tileReader = tileReader; this.outputDir = outputDir; // we really should be checking that the given TileReader supports the pyramid algorithm, // i.e., that the number of both X and Y tiles are equal and that that number is a power // of two. For now, we'll just let it encounter an exception. // calculate the number of levels given the number of tiles along one dimension // supported by the given TileReader levels = (uint)Math.Log(tileReader.NumberTilesX, 2.0) + 1; //Console.WriteLine("Levels: " + levels); }
public SequentialRecursivePyramidGenerator(string filename, uint levels) { this.levels = levels; // create the output directory this.outputDir = Directory.GetParent(filename).ToString() + @"\" + Path.GetFileNameWithoutExtension(filename) + "_sequential"; Directory.CreateDirectory(outputDir); uint tilesPerSide = (uint)Math.Pow(2, levels - 1); ImageReader imageReader = new DefaultImageReader(filename); // for now get the smaller of the image width and height; this will mean that // some of the longer dimension will be excluded from the final pyramid tiles uint length = (uint)Math.Min(imageReader.Height, imageReader.Width); // calculate the tile dimension uint tileDimension = length / tilesPerSide; // finally, create the TileReader tileReader = new DefaultTileReader(imageReader, tileDimension); Console.WriteLine("SequentialRecursivePyramidGenerator - tiles per side: {0}, tile dimension: {1}", tilesPerSide, tileDimension); }
public CenteredTileReader(TileReader tileReader) : this(tileReader, Color.White) { }
public tileHashReader(Tree tree = default, TileReader tr = default) { this.tree = tree; this.tr = tr; }
public TileReaderDecorator(TileReader tileReader) { this.tileReader = tileReader; }
public void Open(string[] originalFilePaths) { this.originalFilePaths = originalFilePaths; string[] cachefilePaths = new string[1]; MosaicPlugin.AllPlugins["Linear Scale"].Enabled = false; MosaicPlugin.AllPlugins["RGB Balance"].Enabled = false; TileReader[] tileReaders = new TileReader[6]; tileReaders[0] = new MosaicFileReader(originalFilePaths, this); tileReaders[1] = new Version2SequenceFileReader(originalFilePaths, this); tileReaders[2] = new SequenceFileReader(originalFilePaths, this); tileReaders[3] = new RosMosaicSequenceFileReader(originalFilePaths, this); tileReaders[4] = new ImageCollectionFileReader(originalFilePaths, this); tileReaders[5] = new MultiSequenceFileReader(originalFilePaths, this); foreach (TileReader t in tileReaders) { if (t.CanRead()) { originalTileReader = tileReader = t; break; } } if(tileReader == null) { MessageBox.Show("Unknown file type"); return; } // Check if there is cache availiable for this file if (tileReader.HasCache()) { cachefilePaths[0] = tileReader.GetCacheFilePath(); if (tileReader.GetType() != typeof(MosaicFileReader)) // create a new reader to read this cache, if we opened a mos file, we already have the reader tileReader = new MosaicFileReader(cachefilePaths, this); } this.menuStrip.Enabled = false; this.toolStrip.Enabled = false; ToolStripProgressBar progressbar = (ToolStripProgressBar)this.feedbackStatusStrip.Items[1]; openThreadController = new ThreadController(this); openThreadController.SetThreadCompletedCallback(OpenFileThreadCompleted); openThreadController.SetThreadProgressCallback(OpenFileProgressIndicator); tileReader.SetThreadController(openThreadController); progressbar.Value = 0; this.statusStrip.Refresh(); try { tileReader.ReadHeader(); } catch (MosaicException e) { // The cache file failed to be read. // Probably as the format has changed. Here we delete the cache file and recall the open function if (tileReader.GetType() == typeof(MosaicFileReader)) { if (originalTileReader.GetType() != typeof(MosaicFileReader)) { File.Delete(cachefilePaths[0]); this.Open(originalFilePaths); } else { // The user has tried to open the mos (cache) file directly // We don't know what other files to fall back too so we just error and return. // File.Delete(cachefilePaths[0]); // DO NOT DELETE THE FILE THEY JUST TRIED TO OPEN! MessageBox.Show("Unable to load file", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } else { MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } catch (Exception e) { MessageBox.Show("Failed to read header information correctly. " + e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } finally { this.menuStrip.Enabled = true; this.toolStrip.Enabled = true; } MosaicWindow.MosaicInfo = new MosaicInfo(tileReader); this.tileOverView.CreateOverview(); this.tileOverView.Location = new Point(25, this.TileView.Bottom - this.tileOverView.Height - 25); this.tileOverView.Show(); // TileLoadInfo should now be ready as we have read the header. this.BlendingEnabled = true; this.CorrelationEnabled = true; // Threaded Operation tileReader.CreateThumbnails(); }