Ejemplo n.º 1
0
        private int GetBlockLengthNeeded(RawColorBlock rawColorBlock)
        {
            if (rawColorBlock.type == RawColorBlockType.SinglePixel)
            {
                return 1;
            }

            if (rawColorBlock.type == RawColorBlockType.FourPixel)
            {
                return 4;
            }

            var type = rawColorBlock.ThirdTetrade;
            return type + 3;
        }
Ejemplo n.º 2
0
        private int GetBlockLengthNeeded(RawColorBlock rawColorBlock)
        {
            if (rawColorBlock.type == RawColorBlockType.SinglePixel)
            {
                return(1);
            }

            if (rawColorBlock.type == RawColorBlockType.FourPixel)
            {
                return(4);
            }

            var type = rawColorBlock.ThirdTetrade;

            return(type + 3);
        }
Ejemplo n.º 3
0
        private bool TryToAppendCounterBlock(AbsoluteBlockContainer absoluteBlockContainer, RawColorBlock rawColorBlock, int blockSizeNeeded, out int lenthAdded)
        {
            var blockLengthNeeded = GetBlockLengthNeeded(rawColorBlock);

            var stripePadding = blockSizeNeeded < blockLengthNeeded
                ? (blockLengthNeeded - blockSizeNeeded)
                : 0;

            if (absoluteBlockContainer.CanAddFullBlock(blockSizeNeeded))
            {
                absoluteBlockContainer.Add(new RawColorBlockContainer(rawColorBlock, blockSizeNeeded, absoluteBlockContainer.TotalSpaceOccupied, stripePadding));
                lenthAdded = blockSizeNeeded;
                return(true);
            }

            var freeSpace = absoluteBlockContainer.FreeSpaceLeft;

            if (freeSpace > 0)
            {
                absoluteBlockContainer.Add(new RawColorBlockContainer(rawColorBlock, freeSpace, absoluteBlockContainer.TotalSpaceOccupied, stripePadding));
            }

            lenthAdded = freeSpace;
            return(false);
        }
Ejemplo n.º 4
0
        private bool TryToAppendCounterBlock(AbsoluteBlockContainer absoluteBlockContainer, RawColorBlock rawColorBlock, int blockSizeNeeded, out int lenthAdded)
        {
            var blockLengthNeeded = GetBlockLengthNeeded(rawColorBlock);

            var stripePadding = blockSizeNeeded < blockLengthNeeded
                ? (blockLengthNeeded - blockSizeNeeded)
                : 0;

            if (absoluteBlockContainer.CanAddFullBlock(blockSizeNeeded))
            {
                absoluteBlockContainer.Add(new RawColorBlockContainer(rawColorBlock, blockSizeNeeded, absoluteBlockContainer.TotalSpaceOccupied, stripePadding));
                lenthAdded = blockSizeNeeded;
                return true;
            }

            var freeSpace = absoluteBlockContainer.FreeSpaceLeft;

            if (freeSpace > 0)
            {
                absoluteBlockContainer.Add(new RawColorBlockContainer(rawColorBlock, freeSpace, absoluteBlockContainer.TotalSpaceOccupied, stripePadding));
            }

            lenthAdded = freeSpace;
            return false;
        }