Esempio n. 1
0
 public static Bitmap2 GetImage(char c, int width, int height, Color2 fgColor, Color2 bgColor)
 {
     if (height <= 1 || width <= 1) {
         return null;
     }
     Bitmap2 template = GetImage(c);
     if (template == null) {
         return null;
     }
     int twidth = template.Width;
     int theight = template.Height;
     Bitmap2 result = new Bitmap2(width, height);
     for (int i = 0; i < width; i++) {
         float wI1;
         float wI2;
         int indI = CalcInd(i, width, twidth, out wI1, out wI2);
         for (int j = 0; j < height; j++) {
             float wJ1;
             float wJ2;
             int indJ = CalcInd(j, height, theight, out wJ1, out wJ2);
             Color2 ij = IsSet(indI, indJ, template) ? fgColor : bgColor;
             Color2 ipj = IsSet(indI + 1, indJ, template) ? fgColor : bgColor;
             Color2 ijp = IsSet(indI, indJ + 1, template) ? fgColor : bgColor;
             Color2 ipjp = IsSet(indI + 1, indJ + 1, template) ? fgColor : bgColor;
             Color2 col = Average(new[] { ij, ipj, ijp, ipjp }, new[] { wI1 * wJ1, wI2 * wJ1, wI1 * wJ2, wI2 * wJ2 });
             result.SetPixel(i, j, col);
         }
     }
     return result;
 }
Esempio n. 2
0
        public Bitmap2 Transpose()
        {
            Bitmap2 result = new Bitmap2(Height, Width);

            for (int i = 0; i < Width; i++)
            {
                for (int j = 0; j < Height; j++)
                {
                    result.SetPixel(j, i, GetPixel(i, j));
                }
            }
            return(result);
        }
Esempio n. 3
0
 public static Bitmap2 ToBitmap2(Bitmap bitmap)
 {
     if (bitmap == null){
         return null;
     }
     Bitmap2 result = new Bitmap2(bitmap.Width, bitmap.Height);
     for (int i = 0; i < bitmap.Width; i++){
         for (int j = 0; j < bitmap.Height; j++){
             result.SetPixel(i, j, bitmap.GetPixel(i, j).ToArgb());
         }
     }
     return result;
 }
Esempio n. 4
0
        public Bitmap2 Lighter()
        {
            Bitmap2 result = new Bitmap2(Width, Height);

            for (int i = 0; i < Width; i++)
            {
                for (int j = 0; j < Height; j++)
                {
                    int p = GetPixel(i, j);
                    result.SetPixel(i, j,
                                    Color2.FromArgb(Math.Min(255, Color2.GetR(p) + 20), Math.Min(255, Color2.GetG(p) + 20),
                                                    Math.Min(255, Color2.GetB(p) + 20)).Value);
                }
            }
            return(result);
        }
Esempio n. 5
0
        public static Bitmap2 GetImage(char c, int width, int height, Color2 fgColor, Color2 bgColor)
        {
            if (height <= 1 || width <= 1)
            {
                return(null);
            }
            Bitmap2 template = GetImage(c);

            if (template == null)
            {
                return(null);
            }
            int     twidth  = template.Width;
            int     theight = template.Height;
            Bitmap2 result  = new Bitmap2(width, height);

            for (int i = 0; i < width; i++)
            {
                float wI1;
                float wI2;
                int   indI = CalcInd(i, width, twidth, out wI1, out wI2);
                for (int j = 0; j < height; j++)
                {
                    float  wJ1;
                    float  wJ2;
                    int    indJ = CalcInd(j, height, theight, out wJ1, out wJ2);
                    Color2 ij   = IsSet(indI, indJ, template) ? fgColor : bgColor;
                    Color2 ipj  = IsSet(indI + 1, indJ, template) ? fgColor : bgColor;
                    Color2 ijp  = IsSet(indI, indJ + 1, template) ? fgColor : bgColor;
                    Color2 ipjp = IsSet(indI + 1, indJ + 1, template) ? fgColor : bgColor;
                    Color2 col  = Average(new[] { ij, ipj, ijp, ipjp }, new[] { wI1 *wJ1, wI2 *wJ1, wI1 *wJ2, wI2 *wJ2 });
                    result.SetPixel(i, j, col);
                }
            }
            return(result);
        }
Esempio n. 6
0
        public static void FillShadedRectangle(Bitmap2 b, int w, int h)
        {
            b.FillRectangle(Color2.White, 0, 0, w - 1, h - 1);
            b.SetPixel(1, 1, Color2.FromArgb(230, 238, 252));
            b.SetPixel(1, h - 3, Color2.FromArgb(219, 227, 248));
            b.SetPixel(w - 3, 1, Color2.FromArgb(220, 230, 249));
            b.SetPixel(w - 3, h - 3, Color2.FromArgb(217, 227, 246));
            b.SetPixel(w - 1, h - 3, Color2.FromArgb(174, 192, 214));
            b.SetPixel(w - 2, h - 2, Color2.FromArgb(174, 196, 219));
            b.SetPixel(0, h - 2, Color2.FromArgb(195, 212, 231));
            b.SetPixel(0, h - 1, Color2.FromArgb(237, 241, 243));
            b.SetPixel(w - 2, h - 1, Color2.FromArgb(236, 242, 247));
            b.SetPixel(w - 1, h - 1, Color2.FromArgb(255, 255, 255));
            b.SetPixel(w - 1, h - 2, Color2.FromArgb(255, 255, 255));
            int wi = w - 5;
            int he = h - 5;

            int[][] upper = InterpolateRgb(225, 234, 254, 188, 206, 250, wi);
            int[][] lower = InterpolateRgb(183, 203, 249, 174, 200, 247, wi);
            for (int i = 0; i < wi; i++)
            {
                int[][] pix = InterpolateRgb(upper[0][i], upper[1][i], upper[2][i], lower[0][i], lower[1][i], lower[2][i], he);
                for (int j = 0; j < he; j++)
                {
                    b.SetPixel(i + 2, j + 2, Color2.FromArgb(pix[0][j], pix[1][j], pix[2][j]));
                }
            }
            int[][] pix2 = InterpolateRgb(208, 223, 252, 170, 192, 243, he);
            for (int j = 0; j < he; j++)
            {
                b.SetPixel(1, j + 2, Color2.FromArgb(pix2[0][j], pix2[1][j], pix2[2][j]));
            }
            pix2 = InterpolateRgb(185, 202, 243, 176, 197, 242, he);
            for (int j = 0; j < he; j++)
            {
                b.SetPixel(w - 3, j + 2, Color2.FromArgb(pix2[0][j], pix2[1][j], pix2[2][j]));
            }
            pix2 = InterpolateRgb(208, 223, 252, 175, 197, 244, wi);
            for (int i = 0; i < wi; i++)
            {
                b.SetPixel(i + 2, 1, Color2.FromArgb(pix2[0][i], pix2[1][i], pix2[2][i]));
            }
            pix2 = InterpolateRgb(183, 198, 241, 176, 196, 242, wi);
            for (int i = 0; i < wi; i++)
            {
                b.SetPixel(i + 2, h - 3, Color2.FromArgb(pix2[0][i], pix2[1][i], pix2[2][i]));
            }
            pix2 = InterpolateRgb(238, 237, 229, 160, 181, 211, he + 2);
            for (int i = 0; i < he + 2; i++)
            {
                b.SetPixel(w - 1, i, Color2.FromArgb(pix2[0][i], pix2[1][i], pix2[2][i]));
            }
            pix2 = InterpolateRgb(170, 192, 225, 126, 159, 211, w / 2);
            for (int i = 1; i <= w / 2; i++)
            {
                b.SetPixel(i, h - 1, Color2.FromArgb(pix2[0][i - 1], pix2[1][i - 1], pix2[2][i - 1]));
            }
            pix2 = InterpolateRgb(126, 159, 211, 148, 176, 221, w - 3 - w / 2);
            for (int i = w / 2 + 1; i <= w - 3; i++)
            {
                b.SetPixel(i, h - 1, Color2.FromArgb(pix2[0][i - w / 2 - 1], pix2[1][i - w / 2 - 1], pix2[2][i - w / 2 - 1]));
            }
        }
Esempio n. 7
0
 public Bitmap2 Darker()
 {
     Bitmap2 result = new Bitmap2(Width, Height);
     for (int i = 0; i < Width; i++){
         for (int j = 0; j < Height; j++){
             int p = GetPixel(i, j);
             result.SetPixel(i, j,
                 Color2.FromArgb(Math.Max(0, Color2.GetR(p) - 20), Math.Max(0, Color2.GetG(p) - 20),
                     Math.Max(0, Color2.GetB(p) - 20)).Value);
         }
     }
     return result;
 }
Esempio n. 8
0
 public Bitmap2 Transpose()
 {
     Bitmap2 result = new Bitmap2(Height, Width);
     for (int i = 0; i < Width; i++){
         for (int j = 0; j < Height; j++){
             result.SetPixel(j, i, GetPixel(i, j));
         }
     }
     return result;
 }
Esempio n. 9
0
 public static void FillShadedRectangle(Bitmap2 b, int w, int h)
 {
     b.FillRectangle(Color2.White, 0, 0, w - 1, h - 1);
     b.SetPixel(1, 1, Color2.FromArgb(230, 238, 252));
     b.SetPixel(1, h - 3, Color2.FromArgb(219, 227, 248));
     b.SetPixel(w - 3, 1, Color2.FromArgb(220, 230, 249));
     b.SetPixel(w - 3, h - 3, Color2.FromArgb(217, 227, 246));
     b.SetPixel(w - 1, h - 3, Color2.FromArgb(174, 192, 214));
     b.SetPixel(w - 2, h - 2, Color2.FromArgb(174, 196, 219));
     b.SetPixel(0, h - 2, Color2.FromArgb(195, 212, 231));
     b.SetPixel(0, h - 1, Color2.FromArgb(237, 241, 243));
     b.SetPixel(w - 2, h - 1, Color2.FromArgb(236, 242, 247));
     b.SetPixel(w - 1, h - 1, Color2.FromArgb(255, 255, 255));
     b.SetPixel(w - 1, h - 2, Color2.FromArgb(255, 255, 255));
     int wi = w - 5;
     int he = h - 5;
     int[][] upper = InterpolateRgb(225, 234, 254, 188, 206, 250, wi);
     int[][] lower = InterpolateRgb(183, 203, 249, 174, 200, 247, wi);
     for (int i = 0; i < wi; i++){
         int[][] pix = InterpolateRgb(upper[0][i], upper[1][i], upper[2][i], lower[0][i], lower[1][i], lower[2][i], he);
         for (int j = 0; j < he; j++){
             b.SetPixel(i + 2, j + 2, Color2.FromArgb(pix[0][j], pix[1][j], pix[2][j]));
         }
     }
     int[][] pix2 = InterpolateRgb(208, 223, 252, 170, 192, 243, he);
     for (int j = 0; j < he; j++){
         b.SetPixel(1, j + 2, Color2.FromArgb(pix2[0][j], pix2[1][j], pix2[2][j]));
     }
     pix2 = InterpolateRgb(185, 202, 243, 176, 197, 242, he);
     for (int j = 0; j < he; j++){
         b.SetPixel(w - 3, j + 2, Color2.FromArgb(pix2[0][j], pix2[1][j], pix2[2][j]));
     }
     pix2 = InterpolateRgb(208, 223, 252, 175, 197, 244, wi);
     for (int i = 0; i < wi; i++){
         b.SetPixel(i + 2, 1, Color2.FromArgb(pix2[0][i], pix2[1][i], pix2[2][i]));
     }
     pix2 = InterpolateRgb(183, 198, 241, 176, 196, 242, wi);
     for (int i = 0; i < wi; i++){
         b.SetPixel(i + 2, h - 3, Color2.FromArgb(pix2[0][i], pix2[1][i], pix2[2][i]));
     }
     pix2 = InterpolateRgb(238, 237, 229, 160, 181, 211, he + 2);
     for (int i = 0; i < he + 2; i++){
         b.SetPixel(w - 1, i, Color2.FromArgb(pix2[0][i], pix2[1][i], pix2[2][i]));
     }
     pix2 = InterpolateRgb(170, 192, 225, 126, 159, 211, w/2);
     for (int i = 1; i <= w/2; i++){
         b.SetPixel(i, h - 1, Color2.FromArgb(pix2[0][i - 1], pix2[1][i - 1], pix2[2][i - 1]));
     }
     pix2 = InterpolateRgb(126, 159, 211, 148, 176, 221, w - 3 - w/2);
     for (int i = w/2 + 1; i <= w - 3; i++){
         b.SetPixel(i, h - 1, Color2.FromArgb(pix2[0][i - w/2 - 1], pix2[1][i - w/2 - 1], pix2[2][i - w/2 - 1]));
     }
 }