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


C# System.GetPixel方法代码示例

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


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

示例1: GetDiff

        static int GetDiff(System.Drawing.Bitmap origin, System.Drawing.Bitmap target)
        {
            int sum = 0;
            for (int y = 0; y < Math.Max(origin.Height, target.Height); y++)
            {
                for (int x = 0; x < Math.Max(origin.Width, target.Width); x++)
                {
                    System.Drawing.Color co = new System.Drawing.Color();
                    System.Drawing.Color ct = new System.Drawing.Color();

                    if ( origin.Width > x &&
                        origin.Height > y)
                    {
                        co = origin.GetPixel(x, y);
                    }

                    if (target.Width > x &&
                        target.Height > y)
                    {
                        ct = target.GetPixel(x, y);
                    }

                    sum += (Math.Abs(co.R - ct.R) + Math.Abs(co.G - ct.G) + Math.Abs(co.B - ct.B) + Math.Abs(co.A - ct.A));
                }
            }

            return sum;
        }
开发者ID:Pctg-x8,项目名称:Altseed,代码行数:28,代码来源:Program.cs

示例2: DrawCharacter

        private System.Drawing.Bitmap DrawCharacter(System.Drawing.Bitmap bmp, System.Drawing.Color color, int size)
        {
            for (int y = 0; y < bmp.Height; y++)
            {
                for (int x = 0; x < bmp.Width; x++)
                {
                    System.Drawing.Color pixel = bmp.GetPixel(x, y);

                    if (pixel != System.Drawing.Color.FromArgb(0, 0, 0, 0))
                    {
                        if (pixel == System.Drawing.Color.FromArgb(255, 249, 249, 249))
                            bmp.SetPixel(x, y, System.Drawing.Color.White);
                        else
                        {
                            int red = (pixel.R + color.R) / 2;
                            int green = (pixel.G + color.G) / 2;
                            int blue = (pixel.B + color.B) / 2;
                            bmp.SetPixel(x, y, System.Drawing.Color.FromArgb(red,
                                                                             green,
                                                                             blue));
                        }
                    }
                }
            }

            System.Drawing.Bitmap newImage = new System.Drawing.Bitmap(size, size);
            using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(newImage))
            {
                g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
                g.DrawImage(bmp, new System.Drawing.Rectangle(0, 0, size, size));
            }

            return newImage;
        }
开发者ID:Nikoxxpro,项目名称:TerrariViewer,代码行数:34,代码来源:EquipmentControl.xaml.cs

示例3: GetHeightMap

 public static byte[] GetHeightMap(System.Drawing.Bitmap bm)
 {
     byte[] result = new byte[bm.Height * bm.Width];
     for (int x = 0; x < bm.Width; x++)
     {
         for (int y = 0; y < bm.Height; y++)
         {
             result[x + y * bm.Width] = bm.GetPixel(x, y).R;
         }
     }
     return result;
 }
开发者ID:JointJBA,项目名称:DisqueEngine,代码行数:12,代码来源:Extensions.cs

示例4: bitmapToColorArray

 /// <summary>
 /// Convets Bitmaps to color Sifteo.Color array.
 /// </summary>
 /// <returns>
 /// The to color array.
 /// </returns>
 /// <param name='bitmap'>
 /// Bitmap.
 /// </param>
 public Sifteo.Color[,]  bitmapToColorArray (System.Drawing.Bitmap bitmap)
 {
     Sifteo.Color[,]  colors = new Sifteo.Color[bitmap.Width,bitmap.Height];
     for (int i =0; i < bitmap.Width; i++)
     {
         for (int j=0; j < bitmap.Height; j++) 
         {
             System.Drawing.Color c = bitmap.GetPixel (i, j);
             colors [i,j] = new Sifteo.Color (c.R, c.G, c.B);    
         }
     }
     return colors;
 }
开发者ID:cvaldes2328,项目名称:SynFloSifteo1.0App,代码行数:22,代码来源:CubeImageHelper.cs

示例5: ConvertImageToLEDArray

 public static List<LED_Set> ConvertImageToLEDArray(int Light_Count, System.Drawing.Bitmap BitmapImage)
 {
     List<LED_Set> loaded_animation = new List<LED_Set> ();
     loaded_animation.Clear ();
     System.Drawing.Color CurrentColor;
     for (int y = 0; y < BitmapImage.Height; y++) {
         loaded_animation.Add (new LED_Set ());
         for (int x = 0; x < Light_Count; x++) {
             CurrentColor = BitmapImage.GetPixel (x, y);
             loaded_animation [y].LED_Values.Add (new LED (CurrentColor.R, CurrentColor.G, CurrentColor.B));
         }
     }
     return loaded_animation;
 }
开发者ID:digitalcircuit,项目名称:actinic,代码行数:14,代码来源:AnimationUtilities.cs

示例6: measureTrimmingRect

        /// <summary>
        /// 周囲の黒い部分を除いた部分の範囲を返す
        /// </summary>
        /// <param name="bitmap">処理対象の画像</param>
        /// <returns>中央のマップ部分の範囲</returns>
        private static System.Drawing.Rectangle measureTrimmingRect(System.Drawing.Bitmap bitmap)
        {
            Contract.Requires<ArgumentNullException>(bitmap != null);

            var result = new System.Drawing.Rectangle(0, 0, bitmap.Width, bitmap.Height);
            var trimColor = System.Drawing.Color.Black;
            int centerX = bitmap.Width / 2, centerY = bitmap.Height / 2;
            if (compareSimilarColor(trimColor, bitmap.GetPixel(centerX, centerY))) {
                return result;
            }

            while (++result.X < bitmap.Width) {
                if (!compareSimilarColor(trimColor, bitmap.GetPixel(result.X, centerY))) {
                    break;
                }
            }
            while (++result.Y < bitmap.Height) {
                if (!compareSimilarColor(trimColor, bitmap.GetPixel(centerX, result.Y))) {
                    break;
                }
            }
            for (int right = bitmap.Width-1; right > result.X; --right) {
                if (!compareSimilarColor(trimColor, bitmap.GetPixel(right, centerY))) {
                    result.Width = right + 1 - result.X;
                    break;
                }
            }
            for (int bottom = bitmap.Height-1; bottom > result.Y; --bottom) {
                if (!compareSimilarColor(trimColor, bitmap.GetPixel(centerX, bottom))) {
                    result.Height = bottom + 1 - result.Y;
                    break;
                }
            }

            return result;
        }
开发者ID:sakano,项目名称:TMTools,代码行数:41,代码来源:MainWindow.xaml.cs

示例7: CreateFromBitmap

 public static Image CreateFromBitmap(System.Drawing.Bitmap bm)
 {
     Image imm = new Image();
     imm.HRes = bm.Width;
     imm.VRes = bm.Height;
     imm.Pixels = new Vector3[imm.VRes * imm.HRes];
     for (int x = 0; x < imm.HRes; x++)
     {
         for (int y = 0; y < imm.VRes; y++)
         {
             var c = bm.GetPixel(x, y);
             imm.Pixels[x + y * imm.HRes] = new Vector3((((float)c.R) / 255.0f), (((float)c.G) / 255.0f), (((float)c.B) / 255.0f));
         }
     }
     return imm;
 }
开发者ID:JointJBA,项目名称:DisqueEngine,代码行数:16,代码来源:Extensions.cs

示例8: BitMapToColors

        public static System.Drawing.Color[][] BitMapToColors(System.Drawing.Bitmap pic)
        {
            //  System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(pic.Length.Length, pic[0].Length);
             System.Drawing.Color[][] ret;
             ret = new System.Drawing.Color[pic.Width][];

             for (int w = 0; w < pic.Width; w++)
             {
             ret[w]= new System.Drawing.Color[pic.Height];
             for (int h = 0; h < pic.Height; h++)
                 ret[w][h] = pic.GetPixel(w, h);

             }

             return ret;
        }
开发者ID:ufjl0683,项目名称:sshmc,代码行数:16,代码来源:Util.cs

示例9: BitMapToColorsArray

        public static System.Drawing.Color[,] BitMapToColorsArray(System.Drawing.Bitmap pic)
        {
            System.Drawing.Color[,] ret;

             ret = new System.Drawing.Color[pic.Height, pic.Width];

             for (int w = 0; w < pic.Width; w++)
             {
            // ret[w] = new System.Drawing.Color[pic.Height];
             for (int h = 0; h < pic.Height; h++)
                 ret[h,w] = pic.GetPixel(w, h);

             }

             return ret;
        }
开发者ID:ufjl0683,项目名称:sshmc,代码行数:16,代码来源:Util.cs

示例10: BitmapToBlackWhite2

        public System.Drawing.Bitmap BitmapToBlackWhite2(System.Drawing.Bitmap src)
        {
            double treshold = 0.6;

            Bitmap dst = new Bitmap(src.Width, src.Height);

            for (int i = 0; i < src.Width; i++)
            {
                for (int j = 0; j < src.Height; j++)
                {
                    dst.SetPixel(i, j, src.GetPixel(i, j).GetBrightness() < treshold ? System.Drawing.Color.Black : System.Drawing.Color.White);
                }
            }

            return dst;
        }
开发者ID:andrey9594,项目名称:ImageDialRecognizer,代码行数:16,代码来源:Form1.cs

示例11: LoadBitmap

 public static Bitmap LoadBitmap(System.Drawing.Bitmap bmp)
 {
     int w = bmp.Width;
     int h = bmp.Height;
     Bitmap result = new Bitmap(w, h);
     for (int y = 0; y < h; ++y)
     {
         for (int x = 0; x < w; ++x)
         {
             System.Drawing.Color pixel = bmp.GetPixel(x, y);
             int argb = pixel.ToArgb();
             int col = (argb & 0xf) >> 2;
             if (pixel.A == 255 && pixel.R == 255 && pixel.G == 0 && pixel.B == 255) col = -1;
             result.pixels[x + y * w] = col;
         }
     }
     return result;
 }
开发者ID:rlods,项目名称:PocDotNet,代码行数:18,代码来源:Art.cs

示例12: BitmapToSurface

        ImageSurface BitmapToSurface(System.Drawing.Bitmap bmp)
        {
            Int32[] data = new Int32[bmp.Width * bmp.Height];
            for (int y = 0; y < bmp.Height; y++)
                for (int x = 0; x < bmp.Width; x++)
                {
                    System.Drawing.Color col = bmp.GetPixel(x, y);
                    data[x + y * bmp.Width] = col.ToArgb();
                }

            // pin databuffer until imgSurf is destroyed
            _gc_h_surface_data_buffer = System.Runtime.InteropServices.GCHandle.Alloc(data, System.Runtime.InteropServices.GCHandleType.Pinned);

            // create image surface
            IntPtr dataPtr = System.Runtime.InteropServices.Marshal.UnsafeAddrOfPinnedArrayElement(data, 0);
            ImageSurface imgSurf = new ImageSurface(dataPtr, Format.Argb32, bmp.Width, bmp.Height, bmp.Width * 32 / 8);

            return imgSurf;
        }
开发者ID:djpnewton,项目名称:ddraw,代码行数:19,代码来源:WFCairoGraphics.cs

示例13: GetHistogram

        public long[] GetHistogram(System.Drawing.Bitmap picture)
        {
            long[] myHistogram = new long[256];

            for (int i = 0; i < picture.Size.Width; i++)
                for (int j = 0; j < picture.Size.Height; j++)
                {
                    System.Drawing.Color c = picture.GetPixel(i, j);

                    long Temp = 0;
                    Temp += c.R;
                    Temp += c.G;
                    Temp += c.B;

                    Temp = (int)Temp / 3;
                    myHistogram[Temp]++;
                }

            return myHistogram;
        }
开发者ID:adipurapunya,项目名称:pengenalan-pola-winform,代码行数:20,代码来源:Histogram.cs

示例14: CreateMaskFromImage

        public static IntPtr CreateMaskFromImage(Display display, System.Drawing.Bitmap image)
        {
            int width = image.Width;
            int height = image.Height;
            int stride = (width + 7) >> 3;
            byte[] mask = new byte[stride * height];
            bool msbfirst = (XBitmapBitOrder(display) == 1); // 1 = MSBFirst

            for (int y = 0; y < height; ++y)
            {
                for (int x = 0; x < width; ++x)
                {
                    byte bit = (byte) (1 << (msbfirst ? (7 - (x & 7)) : (x & 7)));
                    int offset = y * stride + (x >> 3);

                    if (image.GetPixel(x, y).A >= 128)
                        mask[offset] |= bit;
                }
            }

            return XCreatePixmapFromBitmapData(display, XDefaultRootWindow(display),
                                               mask, width, height, new IntPtr(1), IntPtr.Zero, 1);
        }
开发者ID:umby24,项目名称:ClassicalSharp,代码行数:23,代码来源:Functions.cs

示例15: Image

        //public Image(int width, int height)
        //{
        //    _pixels = new Pixel[width, height];
        //    for (int x = 0; x < width; x++)
        //        for (int y = 0; y < height; y++)
        //            _pixels[x, y] = new Pixel(x, y);
        //}
        public Image(double width, double height, System.Drawing.Bitmap bitmap, Interpolators.IInterpolator interpolator)
        {
            if (interpolator == null)
                throw new ArgumentNullException("interpolator", "interpolator is null.");
            if (bitmap == null)
                throw new ArgumentNullException("bitmap", "bitmap is null.");
            if (Width < 0)
                throw new Exception("Width can't be negative");
            if (Height < 0)
                throw new Exception("Height can't be negative");

            Width = width;
            Height = height;
            _interpolator = interpolator;

            ScaleHorizontal = (bitmap.Width - 1) / Width;
            ScaleVertical = (bitmap.Height - 1) / Height;

            _pixels = new Pixel[bitmap.Width, bitmap.Height];

            for (int x = 0; x < bitmap.Width; x++)
                for (int y = 0; y < bitmap.Height; y++)
                    _pixels[x, y] = new Pixel(bitmap.GetPixel(x, bitmap.Height - y - 1).GetBrightness(), x, y);
        }
开发者ID:sr480,项目名称:ImageToGCode,代码行数:31,代码来源:Image.cs


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