Esempio n. 1
0
 public EditableImage(EditableImage image)
 {
     this.colors      = image.colors.Clone() as int[, ];
     this.PixelFormat = image.PixelFormat;
     this.Stride      = image.Stride;
     this.Palette     = image.Palette;
 }
Esempio n. 2
0
        public static Bitmap EditImage(Bitmap bmp, ImageEditEventHandler evt)
        {
            EditableImage img = new EditableImage(bmp);

            img.EditImage(evt);
            return(img.Image);
        }
Esempio n. 3
0
        /// <summary>
        /// Gets the average color. This process needs time
        /// </summary>
        /// <param name="bmp"></param>
        /// <returns>The average color</returns>
        public static System.Drawing.Color GetAverageColor(this Bitmap bmp)
        {
            EditableImage img = new EditableImage(bmp);

            long r = 0, g = 0, b = 0;

            for (int y = 0; y < img.Height; y++)
            {
                for (int x = 0; x < img.Width; x++)
                {
                    System.Drawing.Color color = img.GetPixel(x, y);

                    r += color.R;
                    g += color.G;
                    b += color.B;
                }
            }

            long count = img.Width * img.Height;

            return(System.Drawing.Color.FromArgb(
                       (int)(r / count).PutInto(0, 255),
                       (int)(g / count).PutInto(0, 255),
                       (int)(b / count).PutInto(0, 255)));
        }
Esempio n. 4
0
 public EditableImage(EditableImage image)
 {
     this.colors = image.colors.Clone() as int[,];
     this.PixelFormat = image.PixelFormat;
     this.Stride = image.Stride;
     this.Palette = image.Palette;
 }
Esempio n. 5
0
        /// <summary>
        /// Gets the average color. This process needs time
        /// </summary>
        /// <param name="bmp"></param>
        /// <returns>The average color</returns>
        public static System.Drawing.Color GetAverageColor(this Bitmap bmp)
        {
            EditableImage img = new EditableImage(bmp);

            long r = 0, g = 0, b = 0;

            for(int y = 0; y < img.Height; y++)
                for (int x = 0; x < img.Width; x++)
                {
                    System.Drawing.Color color = img.GetPixel(x, y);

                    r += color.R;
                    g += color.G;
                    b += color.B;
                }

            long count = img.Width * img.Height;
            return System.Drawing.Color.FromArgb(
                (int)(r / count).PutInto(0, 255),
                (int)(g / count).PutInto(0, 255),
                (int)(b / count).PutInto(0, 255));
        }
Esempio n. 6
0
 public static Bitmap EditImage(Bitmap bmp, ImageEditEventHandler evt)
 {
     EditableImage img = new EditableImage(bmp);
     img.EditImage(evt);
     return img.Image;
 }