示例#1
0
        protected virtual Bitmap CreateImage(Color colour)
        {
            int num;

            if (this.m_text == "Not Set")
            {
                return(null);
            }
            string path = Environment.GetEnvironmentVariable("TEMP") + @"\Aqua\";

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            string str2 = string.Concat(new object[] { path, this.cleanedName, this.width, "x", this.height, "_", colour.ToString(), "-", this.Font.Size, this.m_textColour.ToString(), ".Png" });

            if (File.Exists(str2))
            {
                return(new Bitmap(str2));
            }
            LayeredImage image = new LayeredImage(this.width, this.height);

            image.Layers.Add().Clear(this.CCC);
            if (this.dropshadow)
            {
                Layer layer2 = image.Layers.Add();
                image.ActiveLayer = layer2;
                image.BackColor   = Color.Black;
                image.Selection.SelectEllipse(this.margin, this.margin, this.buttonwidth, this.buttonheight, LFY.Controls.SelectionMode.Replace);
                image.Fill();
                Blur.ApplyTo(layer2.Bitmap, this.blurx, this.blury);
                layer2.OffsetX = this.shadowoffsetx;
                layer2.OffsetY = this.shadowoffsety;
                layer2.Opacity = this.shadowopacity;
            }
            Layer layer3 = image.Layers.Add();

            image.Selection.SelectEllipse(this.margin, this.margin, this.buttonwidth, this.buttonheight, LFY.Controls.SelectionMode.Replace);
            image.ActiveLayer = layer3;
            image.ForeColor   = this.bordercolor;
            image.BackColor   = Color.Black;
            image.Fill(this.borderfillx0, this.borderfilly0, this.borderfillx1, this.borderfilly1, FillType.Radial);
            image.Selection.SelectEllipse(this.buttoncolorx, this.buttoncolory, this.buttoncolorwidth, this.buttoncolorheight, LFY.Controls.SelectionMode.Replace);
            image.BackColor = colour;
            image.Fill();
            Layer layer4 = image.Layers.Add();

            image.ActiveLayer = layer4;
            image.Selection.SelectEllipse(this.buttoncolorx - 2, this.buttoncolory - 2, this.buttoncolorwidth + 4, this.buttoncolorheight + 4, LFY.Controls.SelectionMode.Replace);
            image.Selection.SelectEllipse(this.shadeleftx, this.shadelefty, this.shadeleftwidth, this.shadeleftheight, LFY.Controls.SelectionMode.Subtract);
            image.Selection.Feather(this.featherleft);
            image.BackColor = Color.Black;
            image.Fill();
            layer4.Opacity = this.shadeopacity;
            image.Selection.SelectEllipse(this.buttoncolorx - 2, this.buttoncolory - 2, this.buttoncolorwidth + 4, this.buttoncolorheight + 4, LFY.Controls.SelectionMode.Replace);
            image.Selection.SelectEllipse(this.shadetopx, this.shadetopy, this.shadetopwidth, this.shadetopheight, LFY.Controls.SelectionMode.Subtract);
            image.Selection.Feather(this.feathertop);
            image.Fill();
            FastBitmap bitmap   = new FastBitmap(this.width, this.height, PixelFormat.Format24bppRgb);
            Graphics   graphics = Graphics.FromImage(bitmap._bitmap);

            graphics.SmoothingMode = SmoothingMode.AntiAlias;
            SolidBrush brush  = new SolidBrush(Color.Black);
            SolidBrush brush2 = new SolidBrush(Color.White);

            graphics.FillRectangle(brush, 0, 0, this.width, this.height);
            graphics.FillEllipse(brush2, this.buttoncolorx, this.buttoncolory, this.buttoncolorwidth, this.buttoncolorheight);
            brush2.Dispose();
            brush.Dispose();
            graphics.Dispose();
            layer4.Mask = bitmap;
            Layer     layer5  = image.Layers.Add();
            FontStyle regular = FontStyle.Regular;

            for (num = 0; num < this.fontstyle.Length; num++)
            {
                char ch = this.fontstyle[num];
                if (ch != 'b')
                {
                    switch (ch)
                    {
                    case 'r':
                    {
                        regular = regular;
                        continue;
                    }

                    case 's':
                    {
                        regular |= FontStyle.Strikeout;
                        continue;
                    }

                    case 't':
                    {
                        continue;
                    }

                    case 'u':
                    {
                        regular |= FontStyle.Underline;
                        continue;
                    }

                    case 'i':
                        goto Label_047E;
                    }
                }
                else
                {
                    regular |= FontStyle.Bold;
                }
                continue;
Label_047E:
                regular |= FontStyle.Italic;
            }
            Font         font   = new Font(this.fontface, (float)this.fontsize, regular);
            StringFormat format = new StringFormat();

            format.Alignment     = StringAlignment.Center;
            format.LineAlignment = StringAlignment.Center;
            format.Trimming      = StringTrimming.None;
            SolidBrush    brush3  = new SolidBrush(this.m_textColour);
            StringBuilder builder = new StringBuilder(this.m_text.Length);

            for (num = 0; num < this.m_text.Length; num++)
            {
                if (this.m_text[num] == '\\')
                {
                    if ((num + 1) < this.m_text.Length)
                    {
                        if (this.m_text[num + 1] == 'n')
                        {
                            builder.Append(Environment.NewLine);
                            num++;
                        }
                        else if (this.m_text[num + 1] == '\\')
                        {
                            builder.Append('\\');
                            num++;
                        }
                        else
                        {
                            builder.Append('\\');
                        }
                    }
                    else
                    {
                        builder.Append('\\');
                    }
                }
                else
                {
                    builder.Append(this.m_text[num]);
                }
            }
            layer5.DrawText(0, 0, this.width, this.height, builder.ToString(), base.Font, brush3, format);
            brush3.Dispose();
            font.Dispose();
            layer5.Opacity = 1.0 - this.texttrans;
            Layer layer6 = image.Layers.Add();

            image.ActiveLayer = layer6;
            image.ForeColor   = Color.White;
            image.BackColor   = Color.Transparent;
            image.Selection.SelectEllipse(this.highlightx, this.highlighty, this.highlightwidth, this.highlightheight, LFY.Controls.SelectionMode.Replace);
            image.Fill(0, this.highlightfilly0, 0, this.highlightfilly1, FillType.Linear);
            FastBitmap  bitmap2 = image.Flatten();
            ImageFormat png     = ImageFormat.Png;

            try
            {
                bitmap2.Save(str2, png);
            }
            catch (Exception)
            {
            }
            return(bitmap2._bitmap);
        }
示例#2
0
        internal FastBitmap Flatten()
        {
            Layer      layer;
            FastBitmap bitmap = new FastBitmap(this._width, this._height, PixelFormat.Format24bppRgb);

            bitmap.Lock();
            int num = 0;

            while (num < this._layers.Count)
            {
                layer = this._layers[num];
                layer._bitmap.Lock();
                if (layer.Mask != null)
                {
                    layer.Mask.Lock();
                }
                num++;
            }
            for (int i = 0; i < this._height; i++)
            {
                for (int j = 0; j < this._width; j++)
                {
                    Color pixel = this._layers[0]._bitmap.GetPixel(j, i);
                    num = 1;
                    while (num < this._layers.Count)
                    {
                        Layer layer2      = this._layers[num];
                        Color transparent = Color.Transparent;
                        if ((((j >= layer2.OffsetX) && (j <= ((layer2.OffsetX + layer2._bitmap.Width) - 1))) && (i >= layer2.OffsetY)) && (i <= ((layer2.OffsetY + layer2._bitmap.Height) - 1)))
                        {
                            transparent = layer2._bitmap.GetPixel(j - layer2.OffsetX, i - layer2.OffsetY);
                        }
                        if (((transparent.A == 0xff) && (layer2.Opacity == 1.0)) && (layer2.Mask == null))
                        {
                            pixel = transparent;
                        }
                        else
                        {
                            double num7 = (((double)transparent.A) / 255.0) * layer2.Opacity;
                            if (layer2.Mask != null)
                            {
                                num7 *= ((double)layer2.Mask.GetIntensity(j, i)) / 255.0;
                            }
                            double a    = (transparent.R * num7) + (pixel.R * (1.0 - num7));
                            double num5 = (transparent.G * num7) + (pixel.G * (1.0 - num7));
                            double num6 = (transparent.B * num7) + (pixel.B * (1.0 - num7));
                            a     = Math.Round(a);
                            num5  = Math.Round(num5);
                            num6  = Math.Round(num6);
                            a     = Math.Min(a, 255.0);
                            num5  = Math.Min(num5, 255.0);
                            num6  = Math.Min(num6, 255.0);
                            pixel = Color.FromArgb((byte)a, (byte)num5, (byte)num6);
                        }
                        num++;
                    }
                    bitmap.SetPixel(j, i, pixel);
                }
            }
            for (num = 0; num < this._layers.Count; num++)
            {
                layer = this._layers[num];
                layer._bitmap.Unlock();
                if (layer.Mask != null)
                {
                    layer.Mask.Unlock();
                }
            }
            bitmap.Unlock();
            return(bitmap);
        }
示例#3
0
 public Selection(int width, int height)
 {
     this._bitmap = new FastBitmap(width, height, PixelFormat.Format24bppRgb);
     this.Clear();
 }
示例#4
0
文件: Blur.cs 项目: rcw0125/vehic
        public static void ApplyTo(FastBitmap bitmap, int horz, int vert)
        {
            float      num;
            int        num8;
            int        num9;
            int        num10;
            float      num11;
            float      num13;
            int        num15;
            byte       num17;
            byte       num18;
            byte       num19;
            byte       num20;
            FastBitmap bitmap2 = (FastBitmap)bitmap.Clone();

            bitmap.Lock();
            bitmap2.Lock();
            int    width    = bitmap.Width;
            int    height   = bitmap.Height;
            double a        = 0.0;
            double num5     = 0.0;
            double num6     = 0.0;
            double num7     = 0.0;
            bool   hasAlpha = bitmap.HasAlpha;

            float[] numArray = new float[(horz * 2) + 1];
            numArray[horz] = 1f;
            int index = 0;

            while (index < horz)
            {
                num13           = Sigmoid((float)index, 0f, (float)((horz + 1) / 2), (float)(horz + 1));
                numArray[index] = num13;
                numArray[(horz * 2) - index] = num13;
                index++;
            }
            int y = 0;

            while (y < bitmap.Height)
            {
                num15 = 0;
                while (num15 < bitmap.Width)
                {
                    a    = 0.0;
                    num5 = 0.0;
                    num6 = 0.0;
                    num7 = 0.0;
                    num  = 0f;
                    for (index = 0; index < ((horz * 2) + 1); index++)
                    {
                        int x = (num15 - horz) + index;
                        if (x < 0)
                        {
                            index += -x;
                            x      = 0;
                        }
                        if (x > (width - 1))
                        {
                            break;
                        }
                        num8  = bitmap.GetPixelInt32(x, y);
                        num11 = numArray[index];
                        a    += ((num8 >> 0x10) & 0xff) * num11;
                        num5 += ((num8 >> 8) & 0xff) * num11;
                        num6 += (num8 & 0xff) * num11;
                        if (hasAlpha)
                        {
                            num10 = (num8 >> 0x18) & 0xff;
                            a    /= 255.0 * num10;
                            num5 /= 255.0 * num10;
                            num6 /= 255.0 * num10;
                            num7 += num10 * num11;
                        }
                        num += num11;
                    }
                    a    /= (double)num;
                    num5 /= (double)num;
                    num6 /= (double)num;
                    num7 /= (double)num;
                    num17 = (byte)Math.Round(a);
                    num18 = (byte)Math.Round(num5);
                    num19 = (byte)Math.Round(num6);
                    num20 = (byte)Math.Round(num7);
                    if (num17 > 0xff)
                    {
                        num17 = 0xff;
                    }
                    if (num18 > 0xff)
                    {
                        num18 = 0xff;
                    }
                    if (num19 > 0xff)
                    {
                        num19 = 0xff;
                    }
                    if (num20 > 0xff)
                    {
                        num20 = 0xff;
                    }
                    num9  = num20;
                    num9  = num9 << 8;
                    num9 |= num17;
                    num9  = num9 << 8;
                    num9 |= num18;
                    num9  = num9 << 8;
                    num9 |= num19;
                    bitmap2.SetPixelInt32(num15, y, num9);
                    num15++;
                }
                y++;
            }
            numArray       = new float[(vert * 2) + 1];
            numArray[vert] = 1f;
            index          = 0;
            while (index < vert)
            {
                num13           = Sigmoid((float)index, 0f, (float)((vert + 1) / 2), (float)(vert + 1));
                numArray[index] = num13;
                numArray[(vert * 2) - index] = num13;
                index++;
            }
            for (num15 = 0; num15 < bitmap.Width; num15++)
            {
                for (y = 0; y < bitmap.Height; y++)
                {
                    a    = 0.0;
                    num5 = 0.0;
                    num6 = 0.0;
                    num7 = 0.0;
                    num  = 0f;
                    for (index = 0; index < ((vert * 2) + 1); index++)
                    {
                        int num21 = (y - vert) + index;
                        if (num21 < 0)
                        {
                            index += -num21;
                            num21  = 0;
                        }
                        if (num21 > (height - 1))
                        {
                            break;
                        }
                        num8  = bitmap2.GetPixelInt32(num15, num21);
                        num11 = numArray[index];
                        a    += ((num8 >> 0x10) & 0xff) * num11;
                        num5 += ((num8 >> 8) & 0xff) * num11;
                        num6 += (num8 & 0xff) * num11;
                        if (hasAlpha)
                        {
                            num10 = (num8 >> 0x18) & 0xff;
                            a    /= 255.0 * num10;
                            num5 /= 255.0 * num10;
                            num6 /= 255.0 * num10;
                            num7 += num10 * num11;
                        }
                        num += num11;
                    }
                    a    /= (double)num;
                    num5 /= (double)num;
                    num6 /= (double)num;
                    num7 /= (double)num;
                    num17 = (byte)Math.Round(a);
                    num18 = (byte)Math.Round(num5);
                    num19 = (byte)Math.Round(num6);
                    num20 = (byte)Math.Round(num7);
                    if (num17 > 0xff)
                    {
                        num17 = 0xff;
                    }
                    if (num18 > 0xff)
                    {
                        num18 = 0xff;
                    }
                    if (num19 > 0xff)
                    {
                        num19 = 0xff;
                    }
                    if (num20 > 0xff)
                    {
                        num20 = 0xff;
                    }
                    num9  = num20;
                    num9  = num9 << 8;
                    num9 |= num17;
                    num9  = num9 << 8;
                    num9 |= num18;
                    num9  = num9 << 8;
                    num9 |= num19;
                    bitmap.SetPixelInt32(num15, y, num9);
                }
            }
            bitmap2.Dispose();
            bitmap.Unlock();
        }
示例#5
0
 public Layer(int width, int height)
 {
     this._bitmap = new FastBitmap(width, height, PixelFormat.Format32bppArgb);
     this.Clear(Color.Transparent);
     this._opacity = 1.0;
 }
示例#6
0
 public Layer(FastBitmap bitmap)
 {
     this._bitmap  = bitmap;
     this._opacity = 1.0;
 }