Exemple #1
0
        public static Bitmap DrawOutlineFromLaplacian(Bitmap bmp, Color oldColor, Color penColor)
        {
            Bitmap outputBM = new Bitmap(bmp.Width, bmp.Height);

            var lockedOutputBitmap = new LockedBitmap(outputBM);

            lockedOutputBitmap.LockBits();

            var lockedOrigBitmap = new LockedBitmap(bmp);

            lockedOrigBitmap.LockBits();


            Graphics g = Graphics.FromImage(outputBM);

            for (int y = 0; y < lockedOrigBitmap.Height; y++)
            {
                for (int x = 0; x < lockedOrigBitmap.Width; x++)
                {
                    for (int c = 255; c > 100; c--)
                    {
                        if (lockedOrigBitmap.GetPixel(x, y) == Color.FromArgb(c, c, c))
                        {
                            lockedOutputBitmap.SetPixel(x, y, penColor);
                        }
                    }
                }
            }

            lockedOrigBitmap.UnlockBits();
            lockedOutputBitmap.UnlockBits();

            return(outputBM);
        }
Exemple #2
0
        // replace one color with another
        public static void ReplaceColor(Bitmap bmp, Color oldColor, Color newColor)
        {
            var lockedBitmap = new LockedBitmap(bmp);

            lockedBitmap.LockBits();

            for (int y = 0; y < lockedBitmap.Height; y++)
            {
                for (int x = 0; x < lockedBitmap.Width; x++)
                {
                    if (lockedBitmap.GetPixel(x, y) == oldColor)
                    {
                        lockedBitmap.SetPixel(x, y, newColor);
                    }
                }
            }
            lockedBitmap.UnlockBits();
        }