示例#1
0
        private MapInfoWithColorMap ReadFromJson(string fn)
        {
            string fnWithExt = Path.ChangeExtension(fn, "json");
            string path      = Path.Combine(BasePath, fnWithExt);

            JsonReader          jr    = new JsonReader();
            MapInfoWithColorMap miwcm = jr.Read(path);

            return(miwcm);
        }
示例#2
0
        public MapInfoWithColorMap Read(string path)
        {
            JsonSerializerSettings settings = BuildSerSettings();

            string fContents = File.ReadAllText(path);

            MapInfoWithColorMapForExport miwcmfe =
                JsonConvert.DeserializeObject <MapInfoWithColorMapForExport>(fContents, settings);

            ColorMap            cm     = ColorMap.GetFromColorMapForExport(miwcmfe.ColorMapForExport);
            MapInfoWithColorMap result = new MapInfoWithColorMap(miwcmfe.MapInfo, cm);

            return(result);
        }
示例#3
0
        public void Build(string fn, bool hiRez)
        {
            // TODO: HiRez, blockWidth and blockHeight should come from the RepoFile.

            MapInfoWithColorMap miwcm = ReadFromJson(fn);
            int      maxIterations    = miwcm.MapInfo.MaxIterations;
            ColorMap colorMap         = miwcm.ColorMap;

            string repofilename = miwcm.MapInfo.Name;

            //ValueRecords<KPoint, MapSectionWorkResult> countsRepo = new ValueRecords<KPoint, MapSectionWorkResult>(repofilename, useHiRezFolder: hiRez);
            //int blockLength = BlockWidth * BlockHeight;
            //MapSectionWorkResult workResult = new MapSectionWorkResult(blockLength, hiRez: hiRez, includeZValuesOnRead: false);
            //CanvasSize imageSizeInBlocks = GetImageSizeInBlocks(countsRepo);

            int blockLength = BlockWidth * BlockHeight;
            CountsRepoReader countsRepoReader  = new CountsRepoReader(repofilename, hiRez, BlockWidth, BlockHeight);
            CanvasSize       imageSizeInBlocks = GetImageSizeInBlocks(countsRepoReader);

            int w = imageSizeInBlocks.Width;
            int h = imageSizeInBlocks.Height;

            CanvasSize imageSize = new CanvasSize(w * BlockWidth, h * BlockHeight);

            string imagePath = GetImageFilename(fn, imageSize.Width, hiRez, BasePath);

            KPoint key = new KPoint(0, 0);

            using (PngImage pngImage = new PngImage(imagePath, imageSize.Width, imageSize.Height))
            {
                for (int vBPtr = 0; vBPtr < h; vBPtr++)
                {
                    key.Y = vBPtr;
                    for (int lPtr = 0; lPtr < 100; lPtr++)
                    {
                        ImageLine iLine   = pngImage.ImageLine;
                        int       linePtr = vBPtr * BlockHeight + lPtr;

                        for (int hBPtr = 0; hBPtr < w; hBPtr++)
                        {
                            key.X = hBPtr;

                            //if (countsRepo.ReadParts(key, workResult))
                            //{
                            //	int[] allCounts = workResult.Counts;
                            //	int[] countsForThisLine = GetOneLineFromCountsBlock(allCounts, lPtr);
                            //	BuildPngImageLineSegment(hBPtr * BlockWidth, countsForThisLine, iLine, maxIterations, colorMap);
                            //}
                            //else
                            //{
                            //	BuildBlankPngImageLineSegment(hBPtr * BlockWidth, BlockWidth, iLine);
                            //}

                            int[] countsForThisLine = countsRepoReader.GetCounts(key, lPtr);
                            if (countsForThisLine != null)
                            {
                                BuildPngImageLineSegment(hBPtr * BlockWidth, countsForThisLine, iLine, maxIterations, colorMap);
                            }
                            else
                            {
                                BuildBlankPngImageLineSegment(hBPtr * BlockWidth, BlockWidth, iLine);
                            }
                        }

                        pngImage.WriteLine(iLine);
                    }
                }
            }
        }