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


C# Bitmap.Apply方法代码示例

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


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

示例1: ApplyFilters

 public static Bitmap ApplyFilters(Bitmap image)
 {
     return image
         .Apply(new Grayscale(.5, .5, .5))
         .ApplyInPlace(new SobelEdgeDetector())
         .Apply(new FillHoles())
         .Apply(new ExtractBiggestBlob());
 }
开发者ID:MrHayato,项目名称:PhotoCache,代码行数:8,代码来源:ImageProcessor.cs

示例2: Bake

        public void Bake()
        {
            var tSize = TextureSize;
            _bakedTexture = new Bitmap(tSize.Width, tSize.Height);

            // Clear baked texture with transparent color.
            for (int y = 0; y < _bakedTexture.Height; y++)
                for (int x = 0; x < _bakedTexture.Width; x++)
                    _bakedTexture.SetPixel(x, y, Color.Transparent);

            int xOffset = 0;
            for (int i = 0; i < Text.Length; i++)
            {
                if (_font.textureList.ContainsKey(Text[i]) == false) continue;
                var textC = _font.textureList[Text[i]];
                if (textC == null) continue;

                float _scale = _charSettings[i].Scale;
                Color _foreColor = _charSettings[i].ForeColor;

                float cX = xOffset + textC.OffsetX * _scale;
                float cY = GetCursor() - textC.OffsetY * _scale;
                float cW = textC.Texture.Width * _scale;
                float cH = textC.Texture.Height * _scale;
                float cA = textC.Advance * _scale;

                if (cW <= 0 || cH <= 0)
                {
                    // Skip
                }
                else
                {
                    var origPixels = textC.Texture.uTexture.GetPixels32();
                    var newTexture = new UnityEngine.Texture2D(textC.Texture.Width, textC.Texture.Height);
                    newTexture.name = "backedGlyphTexture";
                    newTexture.SetPixels32(origPixels);
                    newTexture.Apply();
                    // Scale texture if needed.
                    if ((int)cW != newTexture.width || (int)cH != newTexture.height)
                    {
                        TextureScaler.scale(newTexture, (int)cW, (int)cH);
                        //TextureScale.Bilinear(newTexture, (int)cW, (int)cH);
                        newTexture.Apply();
                    }

                    var newImagePixels = newTexture.GetPixels32();
                    for (int p = 0; p < newImagePixels.Length; p++)
                    {
                        // BlendMode: Multiply
                        var origColor = Color.FromUColor(newImagePixels[p]);
                        var blendColorA = (float)(origColor.A * _foreColor.A) / 255;
                        var blendColorR = (float)(origColor.R * _foreColor.R) / 255;
                        var blendColorG = (float)(origColor.G * _foreColor.G) / 255;
                        var blendColorB = (float)(origColor.B * _foreColor.B) / 255;
                        var blendColor = Color.FromArgb((int)blendColorA, (int)blendColorR, (int)blendColorG, (int)blendColorB);
                        newImagePixels[p] = blendColor.ToUColor();
                    }

                    _bakedTexture.uTexture.SetPixels32((int)cX, (int)cY, newTexture.width, newTexture.height, newImagePixels);
                }

                xOffset += (int)cA;
            }

            _bakedTexture.Apply();

            if (AutoSize)
                Size = tSize;
        }
开发者ID:Meragon,项目名称:Unity-WinForms,代码行数:69,代码来源:BitmapLabel.cs

示例3: GenDefaultFolderImage

            private static Bitmap GenDefaultFolderImage()
            {
                Bitmap folderImage = new Bitmap(16, 16);
                for (int i = 0; i < folderImage.Width; i++)
                    for (int k = 0; k < folderImage.Height; k++)
                        folderImage.SetPixel(i, k, Color.Transparent);

                for (int i = 0; i < 3; i++) folderImage.SetPixel(i, 0, Color.Transparent);
                for (int i = 3; i < 13; i++) folderImage.SetPixel(i, 0, Color.Transparent);
                for (int i = 13; i < 15; i++) folderImage.SetPixel(i, 0, Color.Transparent);
                for (int i = 0; i < 1; i++) folderImage.SetPixel(i, 1, Color.Transparent);
                for (int i = 0; i < 3; i++) folderImage.SetPixel(i, 2, Color.Transparent);
                for (int i = 3; i < 12; i++) folderImage.SetPixel(i, 2, Color.FromArgb(255, 218, 191, 127));
                for (int i = 0; i < 3; i++) folderImage.SetPixel(i, 3, Color.Transparent);
                for (int i = 3; i < 4; i++) folderImage.SetPixel(i, 3, Color.FromArgb(255, 218, 191, 127));
                for (int i = 4; i < 9; i++) folderImage.SetPixel(i, 3, Color.FromArgb(255, 248, 239, 215));
                for (int i = 9; i < 10; i++) folderImage.SetPixel(i, 3, Color.FromArgb(255, 218, 191, 127));
                for (int i = 10; i < 11; i++) folderImage.SetPixel(i, 3, Color.FromArgb(255, 237, 219, 179));
                for (int i = 11; i < 12; i++) folderImage.SetPixel(i, 3, Color.FromArgb(255, 218, 191, 127));
                for (int i = 0; i < 3; i++) folderImage.SetPixel(i, 4, Color.Transparent);
                for (int i = 3; i < 4; i++) folderImage.SetPixel(i, 4, Color.FromArgb(255, 218, 191, 127));
                for (int i = 4; i < 9; i++) folderImage.SetPixel(i, 4, Color.FromArgb(255, 248, 239, 215));
                for (int i = 9; i < 10; i++) folderImage.SetPixel(i, 4, Color.FromArgb(255, 218, 191, 127));
                for (int i = 10; i < 11; i++) folderImage.SetPixel(i, 4, Color.FromArgb(255, 237, 219, 179));
                for (int i = 11; i < 12; i++) folderImage.SetPixel(i, 4, Color.FromArgb(255, 218, 191, 127));
                for (int i = 0; i < 3; i++) folderImage.SetPixel(i, 5, Color.Transparent);
                for (int i = 3; i < 4; i++) folderImage.SetPixel(i, 5, Color.FromArgb(255, 218, 191, 127));
                for (int i = 4; i < 9; i++) folderImage.SetPixel(i, 5, Color.FromArgb(255, 248, 239, 215));
                for (int i = 9; i < 10; i++) folderImage.SetPixel(i, 5, Color.FromArgb(255, 218, 191, 127));
                for (int i = 10; i < 11; i++) folderImage.SetPixel(i, 5, Color.FromArgb(255, 237, 219, 179));
                for (int i = 11; i < 12; i++) folderImage.SetPixel(i, 5, Color.FromArgb(255, 218, 191, 127));
                for (int i = 0; i < 3; i++) folderImage.SetPixel(i, 6, Color.Transparent);
                for (int i = 3; i < 4; i++) folderImage.SetPixel(i, 6, Color.FromArgb(255, 218, 191, 127));
                for (int i = 4; i < 9; i++) folderImage.SetPixel(i, 6, Color.FromArgb(255, 248, 239, 215));
                for (int i = 9; i < 10; i++) folderImage.SetPixel(i, 6, Color.FromArgb(255, 218, 191, 127));
                for (int i = 10; i < 11; i++) folderImage.SetPixel(i, 6, Color.FromArgb(255, 237, 219, 179));
                for (int i = 11; i < 12; i++) folderImage.SetPixel(i, 6, Color.FromArgb(255, 218, 191, 127));
                for (int i = 0; i < 3; i++) folderImage.SetPixel(i, 7, Color.Transparent);
                for (int i = 3; i < 4; i++) folderImage.SetPixel(i, 7, Color.FromArgb(255, 218, 191, 127));
                for (int i = 4; i < 9; i++) folderImage.SetPixel(i, 7, Color.FromArgb(255, 248, 239, 215));
                for (int i = 9; i < 10; i++) folderImage.SetPixel(i, 7, Color.FromArgb(255, 218, 191, 127));
                for (int i = 10; i < 11; i++) folderImage.SetPixel(i, 7, Color.FromArgb(255, 237, 219, 179));
                for (int i = 11; i < 12; i++) folderImage.SetPixel(i, 7, Color.FromArgb(255, 218, 191, 127));
                for (int i = 0; i < 3; i++) folderImage.SetPixel(i, 8, Color.Transparent);
                for (int i = 3; i < 4; i++) folderImage.SetPixel(i, 8, Color.FromArgb(255, 218, 191, 127));
                for (int i = 4; i < 9; i++) folderImage.SetPixel(i, 8, Color.FromArgb(255, 248, 239, 215));
                for (int i = 9; i < 10; i++) folderImage.SetPixel(i, 8, Color.FromArgb(255, 218, 191, 127));
                for (int i = 10; i < 11; i++) folderImage.SetPixel(i, 8, Color.FromArgb(255, 237, 219, 179));
                for (int i = 11; i < 13; i++) folderImage.SetPixel(i, 8, Color.FromArgb(255, 218, 191, 127));
                for (int i = 0; i < 3; i++) folderImage.SetPixel(i, 9, Color.Transparent);
                for (int i = 3; i < 4; i++) folderImage.SetPixel(i, 9, Color.FromArgb(255, 218, 191, 127));
                for (int i = 4; i < 9; i++) folderImage.SetPixel(i, 9, Color.FromArgb(255, 248, 239, 215));
                for (int i = 9; i < 10; i++) folderImage.SetPixel(i, 9, Color.FromArgb(255, 218, 191, 127));
                for (int i = 10; i < 12; i++) folderImage.SetPixel(i, 9, Color.FromArgb(255, 237, 219, 179));
                for (int i = 12; i < 13; i++) folderImage.SetPixel(i, 9, Color.FromArgb(255, 218, 191, 127));
                for (int i = 0; i < 3; i++) folderImage.SetPixel(i, 10, Color.Transparent);
                for (int i = 3; i < 4; i++) folderImage.SetPixel(i, 10, Color.FromArgb(255, 218, 191, 127));
                for (int i = 4; i < 9; i++) folderImage.SetPixel(i, 10, Color.FromArgb(255, 248, 239, 215));
                for (int i = 9; i < 10; i++) folderImage.SetPixel(i, 10, Color.FromArgb(255, 218, 191, 127));
                for (int i = 10; i < 12; i++) folderImage.SetPixel(i, 10, Color.FromArgb(255, 237, 219, 179));
                for (int i = 12; i < 13; i++) folderImage.SetPixel(i, 10, Color.FromArgb(255, 218, 191, 127));
                for (int i = 0; i < 3; i++) folderImage.SetPixel(i, 11, Color.Transparent);
                for (int i = 3; i < 4; i++) folderImage.SetPixel(i, 11, Color.FromArgb(255, 218, 191, 127));
                for (int i = 4; i < 9; i++) folderImage.SetPixel(i, 11, Color.FromArgb(255, 248, 239, 215));
                for (int i = 9; i < 10; i++) folderImage.SetPixel(i, 11, Color.FromArgb(255, 218, 191, 127));
                for (int i = 10; i < 12; i++) folderImage.SetPixel(i, 11, Color.FromArgb(255, 237, 219, 179));
                for (int i = 12; i < 13; i++) folderImage.SetPixel(i, 11, Color.FromArgb(255, 218, 191, 127));
                for (int i = 0; i < 3; i++) folderImage.SetPixel(i, 12, Color.Transparent);
                for (int i = 3; i < 12; i++) folderImage.SetPixel(i, 12, Color.FromArgb(255, 218, 191, 127));

                folderImage.Apply();
                return folderImage;
            }
开发者ID:Meragon,项目名称:Unity-WinForms,代码行数:73,代码来源:FileDialog.cs

示例4: GenDefaultFileImage

            private static Bitmap GenDefaultFileImage()
            {
                Bitmap fileImage = new Bitmap(16, 16);
                for (int i = 0; i < fileImage.Width; i++)
                    for (int k = 0; k < fileImage.Height; k++)
                        fileImage.SetPixel(i, k, Color.Transparent);

                for (int i = 0; i < 2; i++) fileImage.SetPixel(i, 1, Color.Transparent);
                for (int i = 2; i < 10; i++) fileImage.SetPixel(i, 1, Color.FromArgb(255, 180, 180, 180));
                for (int i = 10; i < 13; i++) fileImage.SetPixel(i, 1, Color.Transparent);
                for (int i = 13; i < 14; i++) fileImage.SetPixel(i, 1, Color.Transparent);
                for (int i = 0; i < 2; i++) fileImage.SetPixel(i, 2, Color.Transparent);
                for (int i = 2; i < 3; i++) fileImage.SetPixel(i, 2, Color.FromArgb(255, 180, 180, 180));
                for (int i = 3; i < 8; i++) fileImage.SetPixel(i, 2, Color.FromArgb(255, 233, 233, 233));
                for (int i = 8; i < 9; i++) fileImage.SetPixel(i, 2, Color.FromArgb(255, 180, 180, 180));
                for (int i = 9; i < 10; i++) fileImage.SetPixel(i, 2, Color.FromArgb(255, 233, 233, 233));
                for (int i = 10; i < 11; i++) fileImage.SetPixel(i, 2, Color.FromArgb(255, 180, 180, 180));
                for (int i = 11; i < 13; i++) fileImage.SetPixel(i, 2, Color.Transparent);
                for (int i = 13; i < 14; i++) fileImage.SetPixel(i, 2, Color.Transparent);
                for (int i = 0; i < 2; i++) fileImage.SetPixel(i, 3, Color.Transparent);
                for (int i = 2; i < 3; i++) fileImage.SetPixel(i, 3, Color.FromArgb(255, 180, 180, 180));
                for (int i = 3; i < 8; i++) fileImage.SetPixel(i, 3, Color.FromArgb(255, 233, 233, 233));
                for (int i = 8; i < 9; i++) fileImage.SetPixel(i, 3, Color.FromArgb(255, 180, 180, 180));
                for (int i = 9; i < 11; i++) fileImage.SetPixel(i, 3, Color.FromArgb(255, 233, 233, 233));
                for (int i = 11; i < 12; i++) fileImage.SetPixel(i, 3, Color.FromArgb(255, 180, 180, 180));
                for (int i = 12; i < 13; i++) fileImage.SetPixel(i, 3, Color.Transparent);
                for (int i = 13; i < 14; i++) fileImage.SetPixel(i, 3, Color.Transparent);
                for (int i = 0; i < 2; i++) fileImage.SetPixel(i, 4, Color.Transparent);
                for (int i = 2; i < 3; i++) fileImage.SetPixel(i, 4, Color.FromArgb(255, 180, 180, 180));
                for (int i = 3; i < 8; i++) fileImage.SetPixel(i, 4, Color.FromArgb(255, 233, 233, 233));
                for (int i = 8; i < 9; i++) fileImage.SetPixel(i, 4, Color.FromArgb(255, 180, 180, 180));
                for (int i = 9; i < 12; i++) fileImage.SetPixel(i, 4, Color.FromArgb(255, 233, 233, 233));
                for (int i = 12; i < 13; i++) fileImage.SetPixel(i, 4, Color.FromArgb(255, 180, 180, 180));
                for (int i = 13; i < 14; i++) fileImage.SetPixel(i, 4, Color.Transparent);
                for (int i = 0; i < 2; i++) fileImage.SetPixel(i, 5, Color.Transparent);
                for (int i = 2; i < 3; i++) fileImage.SetPixel(i, 5, Color.FromArgb(255, 180, 180, 180));
                for (int i = 3; i < 8; i++) fileImage.SetPixel(i, 5, Color.FromArgb(255, 233, 233, 233));
                for (int i = 8; i < 13; i++) fileImage.SetPixel(i, 5, Color.FromArgb(255, 180, 180, 180));
                for (int i = 13; i < 14; i++) fileImage.SetPixel(i, 5, Color.Transparent);
                for (int i = 0; i < 2; i++) fileImage.SetPixel(i, 6, Color.Transparent);
                for (int i = 2; i < 3; i++) fileImage.SetPixel(i, 6, Color.FromArgb(255, 180, 180, 180));
                for (int i = 3; i < 12; i++) fileImage.SetPixel(i, 6, Color.FromArgb(255, 233, 233, 233));
                for (int i = 12; i < 13; i++) fileImage.SetPixel(i, 6, Color.FromArgb(255, 180, 180, 180));
                for (int i = 13; i < 14; i++) fileImage.SetPixel(i, 6, Color.Transparent);
                for (int i = 0; i < 2; i++) fileImage.SetPixel(i, 7, Color.Transparent);
                for (int i = 2; i < 3; i++) fileImage.SetPixel(i, 7, Color.FromArgb(255, 180, 180, 180));
                for (int i = 3; i < 12; i++) fileImage.SetPixel(i, 7, Color.FromArgb(255, 233, 233, 233));
                for (int i = 12; i < 13; i++) fileImage.SetPixel(i, 7, Color.FromArgb(255, 180, 180, 180));
                for (int i = 13; i < 14; i++) fileImage.SetPixel(i, 7, Color.Transparent);
                for (int i = 0; i < 2; i++) fileImage.SetPixel(i, 8, Color.Transparent);
                for (int i = 2; i < 3; i++) fileImage.SetPixel(i, 8, Color.FromArgb(255, 180, 180, 180));
                for (int i = 3; i < 12; i++) fileImage.SetPixel(i, 8, Color.FromArgb(255, 233, 233, 233));
                for (int i = 12; i < 13; i++) fileImage.SetPixel(i, 8, Color.FromArgb(255, 180, 180, 180));
                for (int i = 13; i < 14; i++) fileImage.SetPixel(i, 8, Color.Transparent);
                for (int i = 0; i < 2; i++) fileImage.SetPixel(i, 9, Color.Transparent);
                for (int i = 2; i < 3; i++) fileImage.SetPixel(i, 9, Color.FromArgb(255, 180, 180, 180));
                for (int i = 3; i < 12; i++) fileImage.SetPixel(i, 9, Color.FromArgb(255, 233, 233, 233));
                for (int i = 12; i < 13; i++) fileImage.SetPixel(i, 9, Color.FromArgb(255, 180, 180, 180));
                for (int i = 13; i < 14; i++) fileImage.SetPixel(i, 9, Color.Transparent);
                for (int i = 0; i < 2; i++) fileImage.SetPixel(i, 10, Color.Transparent);
                for (int i = 2; i < 3; i++) fileImage.SetPixel(i, 10, Color.FromArgb(255, 180, 180, 180));
                for (int i = 3; i < 12; i++) fileImage.SetPixel(i, 10, Color.FromArgb(255, 233, 233, 233));
                for (int i = 12; i < 13; i++) fileImage.SetPixel(i, 10, Color.FromArgb(255, 180, 180, 180));
                for (int i = 13; i < 14; i++) fileImage.SetPixel(i, 10, Color.Transparent);
                for (int i = 0; i < 2; i++) fileImage.SetPixel(i, 11, Color.Transparent);
                for (int i = 2; i < 3; i++) fileImage.SetPixel(i, 11, Color.FromArgb(255, 180, 180, 180));
                for (int i = 3; i < 12; i++) fileImage.SetPixel(i, 11, Color.FromArgb(255, 233, 233, 233));
                for (int i = 12; i < 13; i++) fileImage.SetPixel(i, 11, Color.FromArgb(255, 180, 180, 180));
                for (int i = 13; i < 14; i++) fileImage.SetPixel(i, 11, Color.Transparent);
                for (int i = 0; i < 2; i++) fileImage.SetPixel(i, 12, Color.Transparent);
                for (int i = 2; i < 3; i++) fileImage.SetPixel(i, 12, Color.FromArgb(255, 180, 180, 180));
                for (int i = 3; i < 12; i++) fileImage.SetPixel(i, 12, Color.FromArgb(255, 233, 233, 233));
                for (int i = 12; i < 13; i++) fileImage.SetPixel(i, 12, Color.FromArgb(255, 180, 180, 180));
                for (int i = 13; i < 14; i++) fileImage.SetPixel(i, 12, Color.Transparent);
                for (int i = 0; i < 2; i++) fileImage.SetPixel(i, 13, Color.Transparent);
                for (int i = 2; i < 3; i++) fileImage.SetPixel(i, 13, Color.FromArgb(255, 180, 180, 180));
                for (int i = 3; i < 12; i++) fileImage.SetPixel(i, 13, Color.FromArgb(255, 233, 233, 233));
                for (int i = 12; i < 13; i++) fileImage.SetPixel(i, 13, Color.FromArgb(255, 180, 180, 180));
                for (int i = 13; i < 14; i++) fileImage.SetPixel(i, 13, Color.Transparent);
                for (int i = 0; i < 2; i++) fileImage.SetPixel(i, 14, Color.Transparent);
                for (int i = 2; i < 13; i++) fileImage.SetPixel(i, 14, Color.FromArgb(255, 180, 180, 180));
                for (int i = 13; i < 14; i++) fileImage.SetPixel(i, 14, Color.Transparent);

                fileImage.Apply();
                return fileImage;
            }
开发者ID:Meragon,项目名称:Unity-WinForms,代码行数:86,代码来源:FileDialog.cs


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