Пример #1
0
        static void ProcessRow(PrimitiveReader reader, int row, SlpGraphic graphic, LineMask mask)
        {
            int i = 0;

            // Some fully transparent rows just have '-32768' for left and the command '15'.
            // Thus the entire row must be filled in here.
            if (mask.Left == short.MinValue)
            {
                mask.Left = (short)graphic.Width;
            }

            for ( ; i < mask.Left; i++)
            {
                graphic[i, row] = -1;
            }
            while (ProcessCommand(reader, row, graphic, ref i))
            {
                ;
            }

            int max = i + mask.Right;

            for ( ; i < max; i++)
            {
                graphic[i, row] = -1;
            }
        }
Пример #2
0
        /// <inheritdoc/>
        public override string ToString()
        {
            string blockCellsStr  = new CellCollection(BlockCells).ToString();
            string blockDigitsStr = new DigitCollection(BlockMask.GetAllSets()).ToString(null);
            string lineCellsStr   = new CellCollection(LineCells).ToString();
            string lineDigitsStr  = new DigitCollection(LineMask.GetAllSets()).ToString(null);
            string interCellsStr  = new CellCollection(IntersectionCells).ToString();
            string interDigitsStr = new DigitCollection(IntersectionMask.GetAllSets()).ToString(null);
            string elimStr        = new ConclusionCollection(Conclusions).ToString();

            return
                ($"{Name}: {interCellsStr}({interDigitsStr}) - " +
                 $"{blockCellsStr}({blockDigitsStr}) & {lineCellsStr}({lineDigitsStr}) => {elimStr}");
        }
Пример #3
0
        static void ReadFrameData(PrimitiveReader reader, SlpFrameInfo frame)
        {
            long pos1     = reader.Stream.Position;
            int  height   = frame.Height;
            int  rowCount = Math.Abs(height);

            LineMask[] masks = new LineMask[rowCount];
            for (int i = 0; i < rowCount; i++)
            {
                masks[i] = LineMask.ReadFrom(reader);
            }

            long pos2 = reader.Stream.Position;

            uint[] commandOffsets = new uint[rowCount];
            for (int i = 0; i < commandOffsets.Length; i++)
            {
                commandOffsets[i] = reader.ReadUInt32();
            }
            System.Diagnostics.Debugger.Break();

            SlpGraphic graphic = new SlpGraphic(frame.Width, height);

            Console.WriteLine("POS :" + reader.Stream.Position);
            for (int i = 0; i < masks.Length; i++)
            {
                Console.WriteLine("CHECK:" + reader.Stream.Position + "," + commandOffsets[i]);
                ProcessRow(reader, i, graphic, masks[i]);
            }
            Console.WriteLine("POS2:" + reader.Stream.Position);

            long ttt = 0;

            using (StreamWriter tempWriter = new StreamWriter(Path.Combine("tests", "log.txt"))) {
                foreach (string file in Directory.EnumerateFiles("pals"))
                {
                    Palette palette = Palette.FromFile(file);
                    using (Bitmap bmp = graphic.CreateBitmap(palette)) {
                        bmp.Save(Path.Combine("tests", ttt + ".bmp"));
                        //bmp.Save( Path.Combine( "tests", ttt + ".png" ), ImageFormat.Png );
                    }
                    ttt++;
                    tempWriter.WriteLine(ttt + " : " + file);
                }
            }
            throw new Exception();
        }