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


C# Image.setPixelColor方法代码示例

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


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

示例1: process

        public Image process(Image imageIn)
        {
            int r, g, b, a;
            for (int x = 0; x < (imageIn.getWidth() - 1); x++)
            {
                for (int y = 0; y < (imageIn.getHeight() - 1); y++)
                {
                    r = imageIn.getRComponent(x, y);
                    g = imageIn.getGComponent(x, y);
                    b = imageIn.getBComponent(x, y);
                    int nMod = 0;
                    if (_direct) // horizontal direction
                        nMod = y % _width;
                    else if (_direct == false) // vertical direction
                        nMod = x % _width;

                    double fDelta = 255.0 * (_opacity / 100.0) / (_width - 1.0);
                    a = Function.FClamp0255(nMod * fDelta);
                    int colorR = _color & 0xFF0000 >> 16;
                    int colorG = _color & 0x00FF00 >> 8;
                    int colorB = _color & 0x0000FF;
                    if (_color == 0xFF)
                    {
                        imageIn.setPixelColor(x, y, colorR, colorG, colorB);
                        continue;
                    }
                    if (a == 0)
                        continue;

                    int t = 0xFF - a;
                    imageIn.setPixelColor(x, y, (colorR * a + r * t) / 0xFF, (colorG * a + g * t) / 0xFF, (colorB * a + b * t) / 0xFF);
                }
            }
            return imageIn;
        }
开发者ID:java02014,项目名称:ImageFilterForWindowsPhone,代码行数:35,代码来源:BlindFilter.cs

示例2: process

        public Image process(Image imageIn)
        {
            int height = imageIn.getHeight();
            int width = imageIn.getWidth();
            int color, color2;

            if (IsHorizontal)
            {
                for (int y = 0; y < height; y++)
                {
                    for (int x = 0; x < (width / 2); x++)
                    {
                        color = imageIn.getPixelColor(x, y);
                        color2 = imageIn.getPixelColor(width - 1 - x, y);
                        imageIn.setPixelColor(width - 1 - x, y, color);
                        imageIn.setPixelColor(x, y, color2);
                    }
                }
            }
            else
            {
                for (int x = 0; x < width; x++)
                {
                    for (int y = 0; y < (height / 2); y++)
                    {
                        color = imageIn.getPixelColor(x, y);
                        color2 = imageIn.getPixelColor(x, height - 1 - y);
                        imageIn.setPixelColor(x, height - 1 - y, color);
                        imageIn.setPixelColor(x, y, color2);
                    }
                }
            }
            return imageIn;
        }
开发者ID:java02014,项目名称:ImageFilterForWindowsPhone,代码行数:34,代码来源:MirrorFilter.cs

示例3: process

        public Image process(Image imageIn)
        {
            int mix1 = (int)(Mixture * 255f);
            int mix2 = 255 - mix1;
            int r, g, b, r1, g1, b1;
            for (int x = 0; x < imageIn.getWidth(); x++)
            {
                for (int y = 0; y < imageIn.getHeight(); y++)
                {
                    int xx = x % pattern.getWidth();
                    int yy = y % pattern.getHeight();

                    r = imageIn.getRComponent(x, y);
                    g = imageIn.getGComponent(x, y);
                    b = imageIn.getBComponent(x, y);
                    r1 = Image.SAFECOLOR(r + pattern.getRComponent(xx, yy));
                    g1 = Image.SAFECOLOR(g + pattern.getGComponent(xx, yy));
                    b1 = Image.SAFECOLOR(b + pattern.getBComponent(xx, yy));
                    r = (r * mix2) + (r1 * mix1);
                    g = (g * mix2) + (g1 * mix1);
                    b = (b * mix2) + (b1 * mix1);
                    imageIn.setPixelColor(x, y, r >> 8, g >> 8, b >> 8);
                }
            }
            return imageIn;
        }
开发者ID:java02014,项目名称:ImageFilterForWindowsPhone,代码行数:26,代码来源:FillPatternFilter.cs

示例4: process

 //@Override
 public Image process(Image imageIn)
 {
     int width = imageIn.getWidth();
     int height = imageIn.getHeight();
     Image clone = imageIn.clone();
     int r = 0, g = 0, b = 0;
     for (int x = 0; x < width; x++)
     {
         for (int y = 0; y < height; y++)
         {
             int k = NoiseFilter.getRandomInt(1, 123456);
             //像素块大小
             int dx = x + k % 19;
             int dy = y + k % 19;
             if (dx >= width)
             {
                 dx = width - 1;
             }
             if (dy >= height)
             {
                 dy = height - 1;
             }
             r = clone.getRComponent(dx, dy);
             g = clone.getGComponent(dx, dy);
             b = clone.getBComponent(dx, dy);
             imageIn.setPixelColor(x, y, r, g, b);
         }
     }
     return imageIn;
 }
开发者ID:java02014,项目名称:ImageFilterForWindowsPhone,代码行数:31,代码来源:MistFilter.cs

示例5: process

        public Image process(Image imageIn)
        {
            int height = imageIn.getHeight();
            int width = imageIn.getWidth();
            Image clone = imageIn.clone();
            imageIn.clearImage(0xffffff);

            //拉普拉斯模板
            int[] Laplacian = new int[] { -1, -1, -1, -1, 8 + _step, -1, -1, -1, -1 };
            for (int x = 1; x < width - 1; x++)
            {
                for (int y = 1; y < height - 1; y++)
                {
                    int r = 0, g = 0, b = 0;
                    int Index = 0;
                    for (int col = -1; col <= 1; col++)
                    {
                        for (int row = -1; row <= 1; row++)
                        {
                            int rr = clone.getRComponent(x + row, y + col);
                            int gg = clone.getGComponent(x + row, y + col);
                            int bb = clone.getBComponent(x + row, y + col);

                            r += rr * Laplacian[Index];
                            g += gg * Laplacian[Index];
                            b += bb * Laplacian[Index];
                            Index++;
                        }
                    }
                    imageIn.setPixelColor(x - 1, y - 1, Image.SAFECOLOR(r), Image.SAFECOLOR(g), Image.SAFECOLOR(b));
                }
            }
            return imageIn;
        }
开发者ID:java02014,项目名称:ImageFilterForWindowsPhone,代码行数:34,代码来源:SharpFilter.cs

示例6: process

        //@Override
        public Image process(Image imageIn)
        {
            int r, g, b, a = 20;
            int width = imageIn.getWidth();
            int height = imageIn.getHeight();
            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    r = imageIn.getRComponent(x, y);
                    g = imageIn.getGComponent(x, y);
                    b = imageIn.getBComponent(x, y);
                    int cr;
                    if ((x < _size) && (y < height - x) && (y >= x))
                        cr = Image.rgb(255, 255, 65); // left
                    else if ((y < _size) && (x < width - y) && (x >= y))
                        cr = Image.rgb(255, 255, 120); // top
                    else if ((x > width - _size) && (y >= width - x) && (y < height + x - width))
                        cr = Image.rgb(0, 0, 65); // right
                    else if (y > height - _size)
                        cr = Image.rgb(0, 0, 120); // bottom
                    else
                        continue;

                    int colorR = cr & 0xFF0000 >> 16;
                    int colorG = cr & 0x00FF00 >> 8;
                    int colorB = cr & 0x0000FF;
                    int t = 0xFF - a;
                    imageIn.setPixelColor(x, y, (colorR * a + r * t) / 0xFF, (colorG * a + g * t) / 0xFF, (colorB * a + b * t) / 0xFF);
                }
            }
            return imageIn;
        }
开发者ID:java02014,项目名称:ImageFilterForWindowsPhone,代码行数:34,代码来源:RaiseFrameFilter.cs

示例7: drawTone

        private void drawTone(int a_x, int a_y, Image imageIn)
        {
            int l_grayIntensity;
            int l_x;
            int l_y;

            for (int x = 0; x < DOT_AREA * DOT_AREA; x++)
            {
                l_x = x % DOT_AREA;
                l_y = x / DOT_AREA;

                if (a_x + l_x < imageIn.getWidth() && a_y + l_y < imageIn.getHeight())
                {

                    l_grayIntensity = 255 - (imageIn.getRComponent(a_x + l_x, a_y + l_y));
                    if (l_grayIntensity > arrDither[x])
                    {
                        imageIn.setPixelColor(a_x + l_x, a_y + l_y, 0, 0, 0);
                    }
                    else
                    {
                        imageIn.setPixelColor(a_x + l_x, a_y + l_y, 255, 255, 255);
                    }
                }
            }
        }
开发者ID:java02014,项目名称:ImageFilterForWindowsPhone,代码行数:26,代码来源:BigBrotherFilter.cs

示例8: process

        //@Override
        public Image process(Image imageIn)
        {
            float saturation = this.SaturationFactor + 1f;
            float negosaturation = 1f - saturation;

            int r, g, b, a;
            for (int x = 0; x < imageIn.getWidth(); x++)
            {
                for (int y = 0; y < imageIn.getHeight(); y++)
                {
                    r = imageIn.getRComponent(x, y);
                    g = imageIn.getGComponent(x, y);
                    b = imageIn.getBComponent(x, y);

                    float nego1 = negosaturation * 0.2126f;
                    float ngeo2 = nego1 + saturation;
                    float ngeo3 = negosaturation * 0.7152f;
                    float nego4 = ngeo3 + saturation;
                    float nego5 = negosaturation * 0.0722f;
                    float nego6 = nego5 + saturation;
                    float nego7 = ((r * ngeo2) + (g * ngeo3)) + (b * nego5);
                    float nego8 = ((r * nego1) + (g * nego4)) + (b * nego5);
                    float nego9 = ((r * nego1) + (g * ngeo3)) + (b * nego6);
                    r = (nego7 > 255f) ? ((byte)255f) : ((nego7 < 0f) ? ((byte)0f) : ((byte)nego7));
                    g = (nego8 > 255f) ? ((byte)255f) : ((nego8 < 0f) ? ((byte)0f) : ((byte)nego8));
                    b = (nego9 > 255f) ? ((byte)255f) : ((nego9 < 0f) ? ((byte)0f) : ((byte)nego9));
                    imageIn.setPixelColor(x, y, r, g, b);
                }
            }
            return imageIn;
        }
开发者ID:java02014,项目名称:ImageFilterForWindowsPhone,代码行数:32,代码来源:SaturationModifyFilter.cs

示例9: process

        public Image process(Image imageIn)
        {
            int r, g, b;
            for (int x = 0; x < imageIn.getWidth(); x++)
            {
                for (int y = 0; y < imageIn.getHeight(); y++)
                {
                    r = imageIn.getRComponent(x, y);
                    g = imageIn.getGComponent(x, y);
                    b = imageIn.getBComponent(x, y);

                    int d = 0;
                    if (((y - 1) % _size == 0) && (x % _size > 0) && ((x + 1) % _size > 0))
                        d = -_depth; // top
                    else if (((y + 2) % _size == 0) && (x % _size > 0) && ((x + 1) % _size > 0))
                        d = _depth; // bottom
                    else if (((x - 1) % _size == 0) && (y % _size > 0) && ((y + 1) % _size) > 0)
                        d = _depth; // left
                    else if (((x + 2) % _size == 0) && (y % _size > 0) && ((y + 1) % _size) > 0)
                        d = -_depth; // right

                    imageIn.setPixelColor(x, y, Image.SAFECOLOR(r + d), Image.SAFECOLOR(g + d), Image.SAFECOLOR(b + d));
                }
            }
            return imageIn;
        }
开发者ID:java02014,项目名称:ImageFilterForWindowsPhone,代码行数:26,代码来源:ThreeDGridFilter.cs

示例10: process

        //@Override
        public Image process(Image imageIn)
        {
            int r, g, b;
            for (int x = 0; x < imageIn.getWidth(); x++)
            {
                for (int y = 0; y < imageIn.getHeight(); y += 3)
                {
                    r = 0;
                    g = 0;
                    b = 0;
                    for (int w = 0; w < 3; w++)
                    {
                        if (y + w < imageIn.getHeight())
                        {
                            r += (imageIn.getRComponent(x, y + w)) / 2;
                            g += (imageIn.getGComponent(x, y + w)) / 2;
                            b += (imageIn.getBComponent(x, y + w)) / 2;
                        }
                    }
                    r = getValidInterval(r);
                    g = getValidInterval(g);
                    b = getValidInterval(b);

                    for (int w = 0; w < 3; w++)
                    {
                        if (y + w < imageIn.getHeight())
                        {
                            if (w == 0)
                            {
                                imageIn.setPixelColor(x, y + w, r, 0, 0);
                            }
                            else if (w == 1)
                            {
                                imageIn.setPixelColor(x, y + w, 0, g, 0);
                            }
                            else if (w == 2)
                            {
                                imageIn.setPixelColor(x, y + w, 0, 0, b);
                            }
                        }
                    }
                }
            }
            return imageIn;
        }
开发者ID:java02014,项目名称:ImageFilterForWindowsPhone,代码行数:46,代码来源:MonitorFilter.cs

示例11: process

 //@Override
 public Image process(Image imageIn)
 {
     int r, g, b;
     int[] array = new int[256];
     int[] numArray = new int[imageIn.getHeight() * imageIn.getWidth()];
     int contrast = (int)(this.ContrastIntensity * 255f);
     int pos = 0;
     for (int x = 0; x < imageIn.getWidth(); x++)
     {
         for (int y = 0; y < imageIn.getHeight(); y++)
         {
             r = imageIn.getRComponent(x, y);
             g = imageIn.getGComponent(x, y);
             b = imageIn.getBComponent(x, y);
             int index = (r * 0x1b36 + g * 0x5b8c + b * 0x93e) >> 15;
             array[index]++;
             numArray[pos] = index;
             pos++;
         }
     }
     for (int i = 1; i < 0x100; i++)
     {
         array[i] += array[i - 1];
     }
     for (int i = 0; i < 0x100; i++)
     {
         array[i] = (array[i] << 8) / imageIn.getHeight() * imageIn.getWidth();
         array[i] = ((contrast * array[i]) >> 8) + (((0xff - contrast) * i) >> 8);
     }
     pos = 0;
     for (int x = 0; x < imageIn.getWidth(); x++)
     {
         for (int y = 0; y < imageIn.getHeight(); y++)
         {
             r = imageIn.getRComponent(x, y);
             g = imageIn.getGComponent(x, y);
             b = imageIn.getBComponent(x, y);
             if (numArray[pos] != 0)
             {
                 int num = array[numArray[pos]];
                 r = (r * num) / numArray[pos];
                 g = (g * num) / numArray[pos];
                 b = (b * num) / numArray[pos];
                 r = (r > 0xff) ? ((byte)0xff) : ((r < 0) ? ((byte)0) : ((byte)r));
                 g = (g > 0xff) ? ((byte)0xff) : ((g < 0) ? ((byte)0) : ((byte)g));
                 b = (b > 0xff) ? ((byte)0xff) : ((b < 0) ? ((byte)0) : ((byte)b));
             }
             imageIn.setPixelColor(x, y, r, g, b);
             pos++;
         }
     }
     return imageIn;
 }
开发者ID:java02014,项目名称:ImageFilterForWindowsPhone,代码行数:54,代码来源:HistogramEqualFilter.cs

示例12: fillRect

 /**
  * Method to extrapolate out
  *
  * @param imageIn
  * @param a_x
  * @param a_y
  * @param squareSize
  * @param a_rgb
  */
 private void fillRect(Image imageIn, int a_x, int a_y, int squareSize, int a_rgb)
 {
     for (int x = a_x; x < a_x + squareSize; x++)
     {
         for (int y = a_y; y < a_y + squareSize; y++)
         {
             if (x < imageIn.getWidth() && y < imageIn.getHeight())
             {
                 imageIn.setPixelColor(x, y, a_rgb);
             }
         }
     }
 }
开发者ID:java02014,项目名称:ImageFilterForWindowsPhone,代码行数:22,代码来源:PixelateFilter.cs

示例13: process

 public Image process(Image imageIn)
 {
     int r, g, b;
     for (int x = 0; x < imageIn.getWidth(); x++)
     {
         for (int y = 0; y < imageIn.getHeight(); y++)
         {
             r = (255 - imageIn.getRComponent(x, y));
             g = (255 - imageIn.getGComponent(x, y));
             b = (255 - imageIn.getBComponent(x, y));
             imageIn.setPixelColor(x, y, r, g, b);
         }
     }
     return imageIn;
 }
开发者ID:java02014,项目名称:ImageFilterForWindowsPhone,代码行数:15,代码来源:InvertFilter.cs

示例14: process

 //@Override
 public Image process(Image imageIn)
 {
     int r, g, b, corfinal;
     for (int x = 0; x < imageIn.getWidth(); x++)
     {
         for (int y = 0; y < imageIn.getHeight(); y++)
         {
             r = imageIn.getRComponent(x, y);
             g = imageIn.getGComponent(x, y);
             b = imageIn.getBComponent(x, y);
             corfinal = (int)((r * 0.3) + (b * 0.59) + (g * 0.11));
             imageIn.setPixelColor(x, y, corfinal, corfinal, corfinal);
         }
     }
     return imageIn;
 }
开发者ID:java02014,项目名称:ImageFilterForWindowsPhone,代码行数:17,代码来源:BlackWhiteFilter.cs

示例15: process

 //@Override
 public virtual Image process(Image imageIn)
 {
     int width = imageIn.getWidth();
     int height = imageIn.getHeight();
     float[] imageArray = ConvertImageWithPadding(imageIn, width, height);
     imageArray = ApplyBlur(imageArray, width, height);
     int newwidth = width + Padding * 2;
     for (int i = 0; i < height; i++)
     {
         int num = ((i + 3) * newwidth) + 3;
         for (int j = 0; j < width; j++)
         {
             int pos = (num + j) * 3;
             imageIn.setPixelColor(j, i, (byte)(imageArray[pos] * 255f), (byte)(imageArray[pos + 1] * 255f), (byte)(imageArray[pos + 2] * 255f));
         }
     }
     return imageIn;
 }
开发者ID:java02014,项目名称:ImageFilterForWindowsPhone,代码行数:19,代码来源:GaussianBlurFilter.cs


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