示例#1
0
 public static Bitmap ApplyFilters(Bitmap image)
 {
     return image
         .Apply(new Grayscale(.5, .5, .5))
         .ApplyInPlace(new SobelEdgeDetector())
         .Apply(new FillHoles())
         .Apply(new ExtractBiggestBlob());
 }
示例#2
0
        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;
        }
示例#3
0
            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;
            }
示例#4
0
            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;
            }