当前位置: 首页>>代码示例>>C#>>正文


C# FastBitmap.GetPixel方法代码示例

本文整理汇总了C#中FastBitmap.GetPixel方法的典型用法代码示例。如果您正苦于以下问题:C# FastBitmap.GetPixel方法的具体用法?C# FastBitmap.GetPixel怎么用?C# FastBitmap.GetPixel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FastBitmap的用法示例。


在下文中一共展示了FastBitmap.GetPixel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AverageColor

 public static Color AverageColor(Bitmap bitmap)
 {
     FastBitmap fbm = new FastBitmap(bitmap);
     int width = bitmap.Width, height = bitmap.Height;
     int r = 0, g = 0, b = 0, total = width * height;
     fbm.LockImage();
     Color c = fbm.GetPixel(0, 0);
     r += c.R;
     g += c.G;
     b += c.B;
     for (int x = 0; x < width; x++) {
         for (int y = 0; y < height; y++) {
             c = fbm.GetPixel(x, y);
             r += c.R;
             g += c.G;
             b += c.B;
         }
     }
     fbm.UnlockImage();
     r /= total;
     r = (r / 16) * 16;
     g /= total;
     g = (g / 16) * 16;
     b /= total;
     b = (b / 16) * 16;
     return Color.FromArgb(r, g, b);
 }
开发者ID:Magicpig55,项目名称:MMP,代码行数:27,代码来源:ImageProcessor.cs

示例2: fastBitmapPngRead

 public void fastBitmapPngRead()
 {
     FastBitmap img = new FastBitmap("../../image/3.png");
     Color firstPixel = img.GetPixel(0,0);
     Color middlePixel = img.GetPixel(300, 150);
     Color preLastPixel = img.GetPixel(734, 735);
     Color lastPixel = img.GetPixel(735, 735);
     Assert.IsTrue(firstPixel == Color.FromArgb(0, 0, 0, 0));
     Assert.IsTrue(middlePixel == Color.FromArgb(255, 254, 222, 88));
     Assert.IsTrue(preLastPixel == Color.FromArgb(128, 0, 0, 255));
     Assert.IsTrue(lastPixel.A==0);
 }
开发者ID:thedeoxen,项目名称:FastedBitmap,代码行数:12,代码来源:UnitTest1.cs

示例3: ApplyArea

		public IBitmap ApplyArea(IArea area)
		{
			//todo: performance can be improved by only creating a bitmap the size of the area, and not the entire background.
			//This will require to change the rendering as well to offset the location
			byte zero = (byte)0;
			Bitmap output = new Bitmap(Width, Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
			using (FastBitmap inBmp = new FastBitmap (_bitmap, ImageLockMode.ReadOnly))
			{
				using (FastBitmap outBmp = new FastBitmap (output, ImageLockMode.WriteOnly, true))
				{
					for (int y = 0; y < Height; y++)
					{
						int bitmapY = Height - y - 1;
						for (int x = 0; x < Width; x++)
						{
							System.Drawing.Color color = inBmp.GetPixel(x, bitmapY);
							byte alpha = area.IsInArea(new AGS.API.PointF(x, y)) ? color.A : zero;
							outBmp.SetPixel(x, bitmapY, System.Drawing.Color.FromArgb(alpha, color));
						}
					}
				}
			}

            return new DesktopBitmap(output, _graphics);
		}
开发者ID:tzachshabtay,项目名称:MonoAGS,代码行数:25,代码来源:DesktopBitmap.cs

示例4: ApplyFilter

        public void ApplyFilter(FastBitmap image)
        {
            const int blurRadius = 5;
            var map = new List<Color>[image.Width, image.Height];
            for (var i = 0; i < image.Width; ++i)
            {
                for (var j = 0; j < image.Height; ++j)
                {
                    for (var iInner = -blurRadius; iInner < blurRadius; ++iInner)
                    {
                        var x = i + iInner;
                        if (x < 0)
                        {
                            continue;
                        }
                        if (x >= image.Width)
                        {
                            break;
                        }

                        for (var jInner = -blurRadius; jInner < blurRadius; ++jInner)
                        {
                            var y = j + jInner;
                            if (y < 0)
                            {
                                continue;
                            }
                            if (y >= image.Height)
                            {
                                break;
                            }

                            var distance = Math.Sqrt((iInner*iInner) + (jInner*jInner));
                            if (distance > blurRadius)
                            {
                                continue;
                            }

                            if (map[i, j] == null)
                            {
                                map[i, j] = new List<Color>();
                            }
                            map[i, j].Add(image.GetPixel(x, y));
                        }
                    }
                }
            }

            for (var i = 0; i < image.Width; ++i)
            {
                for (var j = 0; j < image.Height; ++j)
                {
                    var r = (int)map[i, j].Average(a => a.R);
                    var g = (int)map[i, j].Average(a => a.G);
                    var b = (int)map[i, j].Average(a => a.B);

                    image.SetPixel(i, j, r, g, b);
                }
            }
        }
开发者ID:eouw0o83hf,项目名称:pixel-place,代码行数:60,代码来源:BlurFilter.cs

示例5: ProcessImage

        /// <summary>
        /// Processes the image.
        /// </summary>
        /// <param name="factory">
        /// The current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class containing
        /// the image to process.
        /// </param>
        /// <returns>
        /// The processed image from the current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class.
        /// </returns>
        public Image ProcessImage(ImageFactory factory)
        {
            Image image = factory.Image;

            try
            {
                Tuple<int, bool> parameters = this.DynamicParameter;
                int degrees = parameters.Item1;
                bool rotate = parameters.Item2;
                int width = image.Width;
                int height = image.Height;

                using (FastBitmap fastBitmap = new FastBitmap(image))
                {
                    if (!rotate)
                    {
                        for (int y = 0; y < height; y++)
                        {
                            for (int x = 0; x < width; x++)
                            {
                                HslaColor original = HslaColor.FromColor(fastBitmap.GetPixel(x, y));
                                HslaColor altered = HslaColor.FromHslaColor(degrees / 360f, original.S, original.L, original.A);
                                fastBitmap.SetPixel(x, y, altered);
                            }
                        }
                    }
                    else
                    {
                        for (int y = 0; y < height; y++)
                        {
                            for (int x = 0; x < width; x++)
                            {
                                HslaColor original = HslaColor.FromColor(fastBitmap.GetPixel(x, y));
                                HslaColor altered = HslaColor.FromHslaColor((original.H + (degrees / 360f)) % 1, original.S, original.L, original.A);
                                fastBitmap.SetPixel(x, y, altered);
                            }
                        }
                    }
                }

                return image;
            }
            catch (Exception ex)
            {
                throw new ImageProcessingException("Error processing image with " + this.GetType().Name, ex);
            }
        }
开发者ID:AlexSkarbo,项目名称:ImageProcessor,代码行数:57,代码来源:Hue.cs

示例6: IsMatch

        public bool IsMatch(FastBitmap bitmap, Point offset)
        {
            foreach (PixelMask mask in pixel_masks)
                if (bitmap.GetPixel(mask.X + offset.X, mask.Y + offset.Y) != mask.Color)
                    return false;

            return true;
        }
开发者ID:alexhanh,项目名称:Botting-Library,代码行数:8,代码来源:PixelMaskCollection.cs

示例7: AbsoluteDiff

        public static int AbsoluteDiff(FastBitmap bmp1, FastBitmap bmp2, Rectangle sub_rect)
        {
            int diff = 0;
            for (int y = sub_rect.Y; y < sub_rect.Y + sub_rect.Height; y++)
                for (int x = sub_rect.X; x < sub_rect.X + sub_rect.Width; x++)
                {
                    diff += AbsoluteDiff(Color.FromArgb(bmp1.GetPixel(x, y)), Color.FromArgb(bmp2.GetPixel(x, y)));
                }

            return diff;
        }
开发者ID:alexhanh,项目名称:Botting-Library,代码行数:11,代码来源:BitmapAnalyzer.cs

示例8: fastBitmapReadTestBigImg

        public void fastBitmapReadTestBigImg()
        {
            int redChanelSumm = 0;

            FastBitmap img = new FastBitmap("../../image/2.jpg");
            for (int y = 0; y < img.Height; y++)
            {
                for (int x = 0; x < img.Width; x++)
                {
                    redChanelSumm += img.GetPixel(x, y).R;
                }
            }
        }
开发者ID:thedeoxen,项目名称:FastedBitmap,代码行数:13,代码来源:UnitTest1.cs

示例9: IsMatch

        public bool IsMatch(FastBitmap bitmap)
        {
            for (int y = 0; y < mask.Height; y++)
            {
                for (int x = 0; x < mask.Width; x++)
                {
                    if (mask.GetPixel(x, y) != bitmap.GetPixel(x + location.X, y + location.Y))
                        return false;
                }
            }

            return true;
        }
开发者ID:alexhanh,项目名称:Botting-Library,代码行数:13,代码来源:BitmapMask.cs

示例10: GetDeviation

        private double GetDeviation(FastBitmap bitmap, FastBitmap background)
        {
            double sum = 0;
            int count = bitmap.Height * bitmap.Width;

            for (int x = 0; x < bitmap.Width; x++)
                for (int y = 0; y < bitmap.Height; y++)
                {
                    System.Drawing.Color c = background.GetPixel(x, y);
                    sum += c.GetBrightness();
                }

            double expectation = sum / count;
            sum = 0;
            for (int x = 0; x < bitmap.Width; x++)
                for (int y = 0; y < bitmap.Height; y++)
                {
                    System.Drawing.Color c = background.GetPixel(x, y);
                    sum += (c.GetBrightness() - expectation) * (c.GetBrightness() - expectation);
                }
            double variance = sum / count;
            return Math.Sqrt(variance);
        }
开发者ID:NatalliaBarysevich,项目名称:MiSOI,代码行数:23,代码来源:BackgroundSubtraction.cs

示例11: ConvertIntsToBitmap

 private Bitmap ConvertIntsToBitmap(int[,] map, FastBitmap frame)
 {
     Bitmap result = new Bitmap(map.GetLength(0), map.GetLength(1));
     for (int i = 0; i < map.GetLength(0); i++)
     {
         for (int j = 0; j < map.GetLength(1); j++)
         {
             if (map[i, j] == ObjectBit)
                 result.SetPixel(i, j, frame.GetPixel(i, j));
             else
                 result.SetPixel(i, j, Color.Black);
         }
     }
     return result;
 }
开发者ID:NatalliaBarysevich,项目名称:MiSOI,代码行数:15,代码来源:BackgroundSubtraction.cs

示例12: Grayscale

        public static Bitmap Grayscale(Bitmap b)
        {
            FastBitmap fb = new FastBitmap(b);

            for (int y = 0; y < b.Height; y++)
            {
                for (int x = 0; x < b.Width; x++)
                {
                    Color c = fb.GetPixel(x, y);
                    int luma = (int)(c.R * 0.3 + c.G * 0.59 + c.B * 0.11);
                    fb.SetPixel(x, y, Color.FromArgb(luma, luma, luma));
                }
            }
            return fb.GetBitmap();
        }
开发者ID:michaelrbk,项目名称:pixelart-vectorizer,代码行数:15,代码来源:Filters.cs

示例13: BinarizationThresholdMethodGetArray

 //binarization and return array
 public int[,] BinarizationThresholdMethodGetArray(Bitmap bitmap)
 {
     FastBitmap fastBitmap = new FastBitmap(bitmap);
     fastBitmap.LockImage();
     int sizeWidth = bitmap.Width;
     int sizeHeigh = bitmap.Height;
     int[,] ArrayForBinarizationImage = new int[sizeWidth, sizeHeigh];
     for (int i = 0; i < sizeWidth; i++)
     {
         for (int j = 0; j < sizeHeigh; j++)
         {
             ArrayForBinarizationImage[i, j] = ResultPixelColorAfterBinarization(fastBitmap.GetPixel(i, j).R);
         }
     }
     fastBitmap.UnlockImage();
     return ArrayForBinarizationImage;
 }
开发者ID:Romaxaqaz,项目名称:MRO_E-Ticket,代码行数:18,代码来源:ImageConverter.cs

示例14: Filter

 public void Filter(FastBitmap bitmap, int radius)
 {
     Parallel.For (0, bitmap.Width, x=>
         {
         for (int y = 0; y < bitmap.Height; y++)
         {
             List<int> list = new List<int>();
             for (int i = x - radius; i <= x + radius; i++)
             {
                 for (int j = y - radius; j <= y + radius; j++)
                 {
                     if (i < 0 || j < 0 || i >= bitmap.Width || j >= bitmap.Height)
                         list.Add(Color.Black.ToArgb());
                     else
                         list.Add(bitmap.GetPixel(x, y).ToArgb());
                 }
             }
             list.Sort();
             bitmap.SetPixel(x, y, Color.FromArgb(list[list.Count() / 2]));
         }
     }
     );
 }
开发者ID:NatalliaBarysevich,项目名称:MiSOI,代码行数:23,代码来源:MedianFilter.cs

示例15: GetSubtitleBitmap


//.........这里部分代码省略.........
                    if (bitmaps.Count > 1)
                    {
                        var merged = new Bitmap(maxWidth, totalHeight + 7 * bitmaps.Count);
                        int y = 0;
                        for (int k = 0; k < bitmaps.Count; k++)
                        {
                            Bitmap part = bitmaps[k];
                            if (checkBoxAutoTransparentBackground.Checked)
                                part.MakeTransparent();
                            using (var g = Graphics.FromImage(merged))
                                g.DrawImage(part, 0, y);
                            y += part.Height + 7;
                            part.Dispose();
                        }
                        b = merged;
                    }
                    else if (bitmaps.Count == 1)
                    {
                        b = bitmaps[0];
                    }

                    if (b != null)
                    {
                        if (_isSon && checkBoxCustomFourColors.Checked)
                        {
                            GetCustomColors(out background, out pattern, out emphasis1, out emphasis2);

                            FastBitmap fbmp = new FastBitmap(b);
                            fbmp.LockImage();
                            for (int x = 0; x < fbmp.Width; x++)
                            {
                                for (int y = 0; y < fbmp.Height; y++)
                                {
                                    Color c = fbmp.GetPixel(x, y);
                                    if (c.R == Color.Red.R && c.G == Color.Red.G && c.B == Color.Red.B) // normally anti-alias
                                        fbmp.SetPixel(x, y, emphasis2);
                                    else if (c.R == Color.Blue.R && c.G == Color.Blue.G && c.B == Color.Blue.B) // normally text?
                                        fbmp.SetPixel(x, y, pattern);
                                    else if (c.R == Color.White.R && c.G == Color.White.G && c.B == Color.White.B) // normally background
                                        fbmp.SetPixel(x, y, background);
                                    else if (c.R == Color.Black.R && c.G == Color.Black.G && c.B == Color.Black.B) // outline/border
                                        fbmp.SetPixel(x, y, emphasis1);
                                    else
                                        fbmp.SetPixel(x, y, c);
                                }
                            }
                            fbmp.UnlockImage();
                        }
                        if (checkBoxAutoTransparentBackground.Checked)
                            b.MakeTransparent();
                        returnBmp = b;
                    }
                }
            }
            else if (_xSubList != null)
            {
                if (index >= 0 && index < _xSubList.Count)
                {
                    if (checkBoxCustomFourColors.Checked)
                    {
                        GetCustomColors(out background, out pattern, out emphasis1, out emphasis2);
                        returnBmp = _xSubList[index].GetImage(background, pattern, emphasis1, emphasis2);
                    }
                    else
                    {
                        returnBmp = _xSubList[index].GetImage();
开发者ID:mgziminsky,项目名称:subtitleedit,代码行数:67,代码来源:VobSubOcr.cs


注:本文中的FastBitmap.GetPixel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。