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


C# Image.getGComponent方法代码示例

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


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

示例1: 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

示例2: 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

示例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 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

示例5: 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

示例6: 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

示例7: process

        //@Override
        public Image process(Image imageIn)
        {
            int r, g, b;
            // Convert to integer factors
            int bfi = (int)(BrightnessFactor * 255);
            float cf = 1f + ContrastFactor;
            cf *= cf;
            int cfi = (int)(cf * 32768) + 1;
            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);
                    // Modify brightness (addition)
                    if (bfi != 0)
                    {
                        // Add brightness
                        int ri = r + bfi;
                        int gi = g + bfi;
                        int bi = b + bfi;
                        // Clamp to byte boundaries
                        r = (byte)(ri > 255 ? 255 : (ri < 0 ? 0 : ri));
                        g = (byte)(gi > 255 ? 255 : (gi < 0 ? 0 : gi));
                        b = (byte)(bi > 255 ? 255 : (bi < 0 ? 0 : bi));
                    }
                    // Modifiy contrast (multiplication)
                    if (cfi != 32769)
                    {
                        // Transform to range [-128, 127]
                        int ri = r - 128;
                        int gi = g - 128;
                        int bi = b - 128;

                        // Multiply contrast factor
                        ri = (ri * cfi) >> 15;
                        gi = (gi * cfi) >> 15;
                        bi = (bi * cfi) >> 15;

                        // Transform back to range [0, 255]
                        ri = ri + 128;
                        gi = gi + 128;
                        bi = bi + 128;

                        // Clamp to byte boundaries
                        r = (byte)(ri > 255 ? 255 : (ri < 0 ? 0 : ri));
                        g = (byte)(gi > 255 ? 255 : (gi < 0 ? 0 : gi));
                        b = (byte)(bi > 255 ? 255 : (bi < 0 ? 0 : bi));
                    }
                    imageIn.setPixelColor(x, y, r, g, b);
                }
            }
            return imageIn;
        }
开发者ID:java02014,项目名称:ImageFilterForWindowsPhone,代码行数:56,代码来源:BrightContrastFilter.cs

示例8: process

        //@Override
        public Image process(Image imageIn)
        {
            int r, g, b, a;
            int ratio = imageIn.getWidth() > imageIn.getHeight() ? imageIn.getHeight() * 32768 / imageIn.getWidth() : imageIn.getWidth() * 32768 / imageIn.getHeight();

            // Calculate center, min and max
            int cx = imageIn.getWidth() >> 1;
            int cy = imageIn.getHeight() >> 1;
            int max = cx * cx + cy * cy;
            int min = (int)(max * (1 - Size));
            int diff = max - min;

            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);

                    // Calculate distance to center and adapt aspect ratio
                    int dx = cx - x;
                    int dy = cy - y;
                    if (imageIn.getWidth() > imageIn.getHeight())
                    {
                        dx = (dx * ratio) >> 15;
                    }
                    else
                    {
                        dy = (dy * ratio) >> 15;
                    }
                    int distSq = dx * dx + dy * dy;

                    if (distSq > min)
                    {
                        // Calculate vignette
                        int v = ((max - distSq) << 8) / diff;
                        v *= v;

                        // Apply vignette
                        int ri = (r * v) >> 16;
                        int gi = (g * v) >> 16;
                        int bi = (b * v) >> 16;

                        // Check bounds
                        r = (byte)(ri > 255 ? 255 : (ri < 0 ? 0 : ri));
                        g = (byte)(gi > 255 ? 255 : (gi < 0 ? 0 : gi));
                        b = (byte)(bi > 255 ? 255 : (bi < 0 ? 0 : bi));
                    }

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

示例9: process

        //@Override
        public Image process(Image imageIn)
        {
            for (int x = 0; x < (imageIn.getWidth() - 1); x++)
            {
                for (int y = 0; y < imageIn.getHeight(); y++)
                {
                    int rr = imageIn.getRComponent(x, y) - imageIn.getRComponent(x + 1, y) + 128;
                    int gg = imageIn.getGComponent(x, y) - imageIn.getGComponent(x + 1, y) + 128;
                    int bb = imageIn.getBComponent(x, y) - imageIn.getBComponent(x + 1, y) + 128;
                    //处理溢出
                    if (rr > 255) rr = 255;
                    if (rr < 0) rr = 0;
                    if (gg > 255) gg = 255;
                    if (gg < 0) gg = 0;
                    if (bb > 255) bb = 255;
                    if (bb < 0) bb = 0;

                    imageIn.setPixelColor(x, y, rr, gg, bb);
                }
            }
            return imageIn;
        }
开发者ID:java02014,项目名称:ImageFilterForWindowsPhone,代码行数:23,代码来源:ReliefFilter.cs

示例10: 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

示例11: 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

示例12: 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

示例13: process

        //@Override
        public Image process(Image imageIn)
        {
            int r, g, b;
             int width = imageIn.getWidth();
             int height = imageIn.getHeight();
             int ratio = width >  height ?  height * 32768 / width : width * 32768 /  height;

             // Calculate center, min and max
             int cx = width >> 1;
             int cy = height >> 1;
             int max = cx * cx + cy * cy;
             int min = (int)(max * (1 - Size));
             int diff = max - min;

             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);

                  // Calculate distance to center and adapt aspect ratio
                  int dx = cx - x;
                  int dy = cy - y;
                  if (width > height){
                     dx = (dx * ratio) >> 15;
                  }
                  else{
                     dy = (dy * ratio) >> 15;
                  }
                  int distSq = dx * dx + dy * dy;
                  float v =  ((float)distSq / diff) * 255;
                  r = (int)(r + (v));
                  g = (int)(g + (v));
                  b = (int)(b + (v));
                  r = (byte)(r > 255 ? 255 : (r < 0 ? 0 : r));
                  g = (byte)(g > 255 ? 255 : (g < 0 ? 0 : g));
                  b = (byte)(b > 255 ? 255 : (b < 0 ? 0 : b));
                  imageIn.setPixelColor(x,y,r,g,b);
              }
             }
             return imageIn;
        }
开发者ID:java02014,项目名称:ImageFilterForWindowsPhone,代码行数:43,代码来源:FeatherFilter.cs

示例14: process

        //@Override
        public Image process(Image imageIn)
        {
            int r, g, b;
            int threshold = (int)(this.Threshold * 255f);

            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 rgb = (((r * 0x1b36) + (g * 0x5b8c)) + (b * 0x93e)) >> 15;
                    r = g = b = rgb > threshold ? 0xff : 0;
                    imageIn.setPixelColor(x, y, r, g, b);
                }
            }
            return imageIn;
        }
开发者ID:java02014,项目名称:ImageFilterForWindowsPhone,代码行数:21,代码来源:ThresholdFilter.cs

示例15: process

 //@Override
 public Image process(Image imageIn)
 {
     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 quanR = (((float)((int)(r * 0.003921569f * levels))) / levels) * 255f;
             float quanG = (((float)((int)(g * 0.003921569f * levels))) / levels) * 255f;
             float quanB = (((float)((int)(b * 0.003921569f * levels))) / levels) * 255f;
             r = (quanR > 255f) ? 255 : ((quanR < 0f) ? 0 : ((byte)quanR));
             g = (quanG > 255f) ? 255 : ((quanG < 0f) ? 0 : ((byte)quanG));
             b = (quanB > 255f) ? 255 : ((quanB < 0f) ? 0 : ((byte)quanB));
             imageIn.setPixelColor(x, y, r, g, b);
         }
     }
     return imageIn;
 }
开发者ID:java02014,项目名称:ImageFilterForWindowsPhone,代码行数:22,代码来源:ColorQuantizeFilter.cs


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