コード例 #1
0
ファイル: TileSystem.cs プロジェクト: ArtReeX/memoria
        public void CopyRectExp(byte[] atlasArray, int atlasWidth, int toX, int toY, Tile tile, Overlay overlay, Size rectSize, uint fromX, uint fromY, bool ignoreTransparent)
        {
            if (tile.info == null)
            {
                Log.Warning($"MISSING TILE {overlay.GetOrderNumber()}, ({tile.x}, {tile.y}) COPY RECT EXP");
                return;
            }
            uint fromIndexX  = tile.info.offX * _factor + fromX;
            uint trueHeight  = overlay.info.h * _factor;
            uint trueWidth   = overlay.info.w * _factor;
            uint trueOffsetY = tile.info.offY * _factor;
            uint fromIndexY  = trueHeight - (trueOffsetY - fromY + Convert.ToUInt32(this.size.height)); // sigh

            for (uint i = 0; i < rectSize.height; i++)
            {
                for (uint j = 0; j < rectSize.width; j++)
                {
                    uint fromIndex = (fromIndexY + i) * trueWidth + fromIndexX + j;
                    uint toIndex   = (uint)((toY + i) * atlasWidth + toX + j);
                    if (ignoreTransparent && overlay.imageData[fromIndex * 4 + 3] < 127)
                    {
                        continue;
                    }
                    CopyBytesHelper.CopyPixel(overlay.imageData, atlasArray, fromIndex, toIndex);
                }
            }
        }
コード例 #2
0
ファイル: TileSystem.cs プロジェクト: ArtReeX/memoria
        public void CopyStripToAtlas(byte[] atlasArray, int atlasWidth, int atlasX, int atlasY, byte[] stripData, Size stripSize)
        {
            uint k = 0;

            for (uint i = 0; i < stripSize.height; i++)
            {
                for (uint j = 0; j < stripSize.width; j++)
                {
                    uint toIndex = (uint)((atlasY + i) * atlasWidth + atlasX + j);
                    CopyBytesHelper.CopyPixel(stripData, atlasArray, k++, toIndex);
                }
            }
        }
コード例 #3
0
ファイル: TileSystem.cs プロジェクト: ArtReeX/memoria
        public void CopyRect(byte[] atlasArray, int atlasWidth, int toX, int toY, Tile tile, Overlay overlay, Size rectSize, uint fromX, uint fromY, bool ignoreTransparent)
        {
            if (tile.info == null)
            {
                Log.Warning($"MISSING TILE {overlay.GetOrderNumber()}, ({tile.x}, {tile.y})");
                return;
            }
            uint fromIndexX  = tile.info.offX * _factor + fromX;
            uint trueHeight  = overlay.info.h * _factor;
            uint trueWidth   = overlay.info.w * _factor;
            uint trueOffsetY = tile.info.offY * _factor;
            uint fromIndexY  = trueHeight - (trueOffsetY - fromY + Convert.ToUInt32(this.size.height)); // sigh

            for (uint i = 0; i < rectSize.height; i++)
            {
                for (uint j = 0; j < rectSize.width; j++)
                {
                    uint fromIndex = (fromIndexY + i) * trueWidth + fromIndexX + j;
                    uint toIndex   = (uint)((toY + i) * atlasWidth + toX + j);
                    try
                    {
                        if (ignoreTransparent && overlay.imageData[fromIndex * 4 + 3] < 255)
                        {
                            continue;
                        }
                        CopyBytesHelper.CopyPixel(overlay.imageData, atlasArray, fromIndex, toIndex);
                    }
                    catch
                    {
                        Log.Message($"trueHeight {trueHeight}, trueOffsetY {trueOffsetY}, fromY {fromY}, size.height {this.size.height}, difference {trueOffsetY - fromY + Convert.ToUInt32(this.size.height)}");
                        Log.Message($"trueWidth {trueWidth}, fromIndexY {fromIndexY}, fromIndexX {fromIndexX}");
                        Log.Message($"fromIndex {fromIndex}, imageData {overlay.imageData.Length} toIndex{toIndex}, atlas {atlasArray.Length}");
                        return;
                    }
                }
            }
        }