Exemple #1
0
        private static void MasterVolumeMapping(int leftColor, int rightColor, float leftVolumeNormalized,
                                                float rightVolumeNormalized, int bandWidth, int height, int baselineY, DirectBitmap directBitmap)
        {
            int heightL = (int)(height * (leftVolumeNormalized));
            int heightR = (int)(height * (rightVolumeNormalized));

            for (int i = 0; i < bandWidth; i++)
            {
                for (int j = baselineY - heightL; j <= baselineY; j++)
                {
                    directBitmap.SetPixel(i, j, leftColor);
                }
            }
            for (int i = bandWidth; i < 2 * bandWidth; i++)
            {
                for (int j = baselineY - heightR; j <= baselineY; j++)
                {
                    directBitmap.SetPixel(i, j, rightColor);
                }
            }
        }
        //Done, using EFLA-E Algorithm (http://www.edepot.com/algorithm.html)
        private static void FastLineAlgorithm(DirectBitmap bitmap, int startX, int startY, int endX, int endY,
                                              int color)
        {
            bool yLonger  = false;
            int  shortLen = endY - startY;
            int  longLen  = endX - startX;

            if (Math.Abs(shortLen) > Math.Abs(longLen))
            {
                int swap = shortLen;
                shortLen = longLen;
                longLen  = swap;
                yLonger  = true;
            }

            int decInc;

            if (longLen == 0)
            {
                decInc = 0;
            }
            else
            {
                decInc = (shortLen << 16) / longLen;
            }

            if (yLonger)
            {
                if (longLen > 0)
                {
                    longLen += startY;
                    for (int j = 0x8000 + (startX << 16); startY <= longLen; ++startY)
                    {
                        bitmap.SetPixel(j >> 16, startY, color);
                        j += decInc;
                    }

                    return;
                }

                longLen += startY;
                for (int j = 0x8000 + (startX << 16); startY >= longLen; --startY)
                {
                    bitmap.SetPixel(j >> 16, startY, color);
                    j -= decInc;
                }

                return;
            }

            if (longLen > 0)
            {
                longLen += startX;
                for (int j = 0x8000 + (startY << 16); startX <= longLen; ++startX)
                {
                    bitmap.SetPixel(startX, j >> 16, color);
                    j += decInc;
                }

                return;
            }

            longLen += startX;
            for (int j = 0x8000 + (startY << 16); startX >= longLen; --startX)
            {
                bitmap.SetPixel(startX, j >> 16, color);
                j -= decInc;
            }
        }