Exemplo n.º 1
0
        public void CombineData(byte[] prevData, int prevWidth, int prevHeight)
        {
            var dataX      = Rect.MinX;
            var dataY      = Rect.MinY;
            var dataWidth  = Rect.SizeX;
            var dataHeight = Rect.SizeY;

            if (Data != null && Data.Length >= dataWidth * dataHeight && prevData != null && prevData.Length >= prevWidth * prevHeight)
            {
                for (var y = 0; y < dataHeight; y++)
                {
                    for (var x = 0; x < dataWidth; x++)
                    {
                        var prevX = x + dataX;
                        var prevY = y + dataY;
                        var dataI = x + y * dataWidth;

                        if (prevX >= 0 && prevY >= 0 && prevX < prevWidth && prevY < prevHeight)
                        {
                            var prevI = prevX + prevY * prevWidth;
                            var dataA = D2dHelper.ConvertAlpha(Data[dataI]);
                            var prevA = D2dHelper.ConvertAlpha(prevData[prevI]);

                            Data[dataI] = D2dHelper.ConvertAlpha(dataA * prevA);
                        }
                        else
                        {
                            Data[dataI] = 0;
                        }
                    }
                }
            }
        }