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; }
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); }
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); }
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; }