예제 #1
0
        private void Adjust()
        {
            if (adjusted != null)
            {
                adjusted.Dispose();
                adjusted = null;
            }

            if (radial == 0)
            {
                adjusted = new Bitmap(origin);
            }
            else
            {
                alpha = red = blue = green = null;

                alpha = new int[width * height];
                red   = new int[width * height];
                green = new int[width * height];
                blue  = new int[width * height];

                for (int i = 0, j = 0; i < dataSize; i += 4, j++)
                {
                    red[j]   = imagePixels[i + 0];
                    green[j] = imagePixels[i + 1];
                    blue[j]  = imagePixels[i + 2];
                    alpha[j] = imagePixels[i + 3];
                }

                adjusted = Process(radial);
            }

            lc.ProcessUpdate(adjusted, true);
            f.DSUpdate();
        }
예제 #2
0
        private void Adjust()
        {
            if (adjusted != null)
            {
                adjusted.Dispose();
                adjusted = null;
            }

            adjusted = new Bitmap(origin);
            using (ImageAttributes imageAttributes = new ImageAttributes())
            {
                float[][] m =
                {
                    new float[] { 1 - (-cyanVal + magentaVal / 2 + yellowVal / 2),                                              0,                                              0, 0, 0 },
                    new float[] {                                               0, 1 - (cyanVal / 2 - magentaVal + yellowVal / 2),                                              0, 0, 0 },
                    new float[] {                                               0,                                              0, 1 - (cyanVal / 2 + magentaVal / 2 - yellowVal), 0, 0 },
                    new float[] {                                               0,                                              0,                                              0, 1, 0 },
                    new float[] {                                               0,                                              0,                                              0, 0, 1 }
                };
                ColorMatrix matrix = new ColorMatrix(m);

                imageAttributes.SetColorMatrix(matrix);
                using (Graphics g = Graphics.FromImage(adjusted))
                {
                    g.DrawImage(adjusted, new Rectangle(0, 0, adjusted.Width, adjusted.Height), 0, 0, origin.Width, origin.Height, GraphicsUnit.Pixel, imageAttributes);
                }
            }

            lc.ProcessUpdate(adjusted, true);
            f.DSUpdate();
        }
예제 #3
0
        private void Adjust()
        {
            if (adjusted != null)
            {
                adjusted.Dispose();
                adjusted = null;
            }
            adjusted = new Bitmap(origin);
            bmpData  = adjusted.LockBits(new Rectangle(0, 0, adjusted.Width, adjusted.Height), System.Drawing.Imaging.ImageLockMode.ReadWrite, adjusted.PixelFormat);
            IntPtr ptr = bmpData.Scan0;

            byte[] pixels = new byte[dataSize];

            for (int i = 0; i < dataSize; i += 4)
            {
                Color c = Color.FromArgb(imagePixels[i + 3], imagePixels[i + 0], imagePixels[i + 1], imagePixels[i + 2]);
                SetColor(ref c);
                pixels[i + 3] = imagePixels[i + 3];
                pixels[i + 0] = c.R;
                pixels[i + 1] = c.G;
                pixels[i + 2] = c.B;
            }

            System.Runtime.InteropServices.Marshal.Copy(pixels, 0, ptr, dataSize);
            adjusted.UnlockBits(bmpData);
            lc.ProcessUpdate(adjusted, true);
            f.DSUpdate();
        }
예제 #4
0
        private void Adjust()
        {
            if (adjusted != null)
            {
                adjusted.Dispose();
                adjusted = null;
            }

            adjusted = new Bitmap(origin);
            using (ImageAttributes imageAttributes = new ImageAttributes())
            {
                ColorMatrix matrix = new ColorMatrix();
                matrix.Matrix00 = matrix.Matrix11 = matrix.Matrix22 = contrast + 1f;
                matrix.Matrix33 = matrix.Matrix44 = 1f;
                matrix.Matrix40 = matrix.Matrix41 = matrix.Matrix42 = brightness;

                imageAttributes.SetColorMatrix(matrix);
                using (Graphics g = Graphics.FromImage(adjusted))
                {
                    g.DrawImage(adjusted, new Rectangle(0, 0, adjusted.Width, adjusted.Height), 0, 0, origin.Width, origin.Height, GraphicsUnit.Pixel, imageAttributes);
                }
            }

            lc.ProcessUpdate(adjusted, true);
            f.DSUpdate();
        }
예제 #5
0
        private void Adjust()
        {
            if (adjusted != null)
            {
                adjusted.Dispose();
                adjusted = null;
            }
            adjusted = new Bitmap(origin);
            bmpData  = adjusted.LockBits(new Rectangle(0, 0, adjusted.Width, adjusted.Height), System.Drawing.Imaging.ImageLockMode.ReadWrite, adjusted.PixelFormat);
            IntPtr ptr = bmpData.Scan0;

            byte[] pixels = new byte[dataSize];

            Random rand = new Random();

            for (int i = 0; i < dataSize; i += 4)
            {
                int R = imagePixels[i + 0] + rand.Next(-amount, amount + 1);
                int G = imagePixels[i + 1] + rand.Next(-amount, amount + 1);
                int B = imagePixels[i + 2] + rand.Next(-amount, amount + 1);

                if (R > 255)
                {
                    R = 255;
                }
                if (G > 255)
                {
                    G = 255;
                }
                if (B > 255)
                {
                    B = 255;
                }

                if (R < 0)
                {
                    R = 0;
                }
                if (G < 0)
                {
                    G = 0;
                }
                if (B < 0)
                {
                    B = 0;
                }

                pixels[i + 0] = (byte)R;
                pixels[i + 1] = (byte)G;
                pixels[i + 2] = (byte)B;
                pixels[i + 3] = imagePixels[i + 3];
            }

            System.Runtime.InteropServices.Marshal.Copy(pixels, 0, ptr, dataSize);
            adjusted.UnlockBits(bmpData);
            lc.ProcessUpdate(adjusted, true);
            f.DSUpdate();
        }
예제 #6
0
        private void Adjust()
        {
            if (adjusted != null)
            {
                adjusted.Dispose();
                adjusted = null;
            }
            adjusted = new Bitmap(origin);

            if (pixel != 1)
            {
                int k = pixel / 2;
                using (Graphics g = Graphics.FromImage(adjusted))
                {
                    g.Clear(Color.Transparent);
                    for (int y = 0; y < adjusted.Height + pixel; y += pixel)
                    {
                        if (y >= adjusted.Height)
                        {
                            y = adjusted.Height - 1;
                        }
                        for (int x = 0; x < adjusted.Width + pixel; x += pixel)
                        {
                            if (x >= adjusted.Width)
                            {
                                x = adjusted.Width - 1;
                            }
                            g.FillRectangle(new SolidBrush(origin.GetPixel(x, y)), x - k, y - k, pixel, pixel);
                            if (x == adjusted.Width - 1)
                            {
                                break;
                            }
                        }
                        if (y == adjusted.Height - 1)
                        {
                            break;
                        }
                    }
                }
            }

            lc.ProcessUpdate(adjusted, true);
            f.DSUpdate();
        }
예제 #7
0
        private void Adjust()
        {
            if (adjusted != null)
            {
                adjusted.Dispose();
                adjusted = null;
            }
            adjusted = new Bitmap(origin);
            bmpData  = adjusted.LockBits(new Rectangle(0, 0, adjusted.Width, adjusted.Height), System.Drawing.Imaging.ImageLockMode.ReadWrite, adjusted.PixelFormat);
            IntPtr ptr = bmpData.Scan0;

            byte[] pixels = new byte[dataSize];

            for (int i = 0; i < dataSize; i += 4)
            {
                int n = (int)((float)imagePixels[i] * 0.4f + (float)imagePixels[i + 1] * 0.4f + (float)imagePixels[i + 2] * 0.2f);

                if (n < level)
                {
                    pixels[i]     = 0;
                    pixels[i + 1] = 0;
                    pixels[i + 2] = 0;
                }
                else
                {
                    pixels[i]     = 255;
                    pixels[i + 1] = 255;
                    pixels[i + 2] = 255;
                }
                pixels[i + 3] = imagePixels[i + 3];
            }

            System.Runtime.InteropServices.Marshal.Copy(pixels, 0, ptr, dataSize);
            adjusted.UnlockBits(bmpData);

            lc.ProcessUpdate(adjusted, true);
            f.DSUpdate();
        }