具有透明度的复合位图

时间:2016-10-12 15:38:42

标签: c# bitmap

我有2个位图,我希望将其覆盖在另一个上,但使用GraphicsMagick.net不能达到预期的效果。

图形效果最好,速度最快,但透明度似乎搞得一团糟。

using (Graphics gfcs = Graphics.FromImage(spiral))
{
   Point placement = new Point(19,19);
   gfcs.DrawImage(astronaut, placement);
}

我想结合:
Yellow BG Spiral& Astronaut

创建:
enter image description here

但我明白了:
enter image description here enter image description here
图形| Magick.net

周边来源:

    public static void generateGIF()
    {
        int smileyID = 71;
        int goldBorder = 1;

        List<Bitmap> images = new List<Bitmap>();
        Bitmap aura = new Bitmap(Image.FromFile("1511_Player_Aura.png"));
        Bitmap smilies = new Bitmap(Image.FromFile("1559_items.ItemManager_smiliesBM.png"));
        Bitmap smiley = new Bitmap(26, 26);

        for (int y = 0; y < 26; y++)
        {
            for (int x = 0; x < 26; x++)
            {
                smiley.SetPixel(x, y, smilies.GetPixel(smileyID * 26 + x, goldBorder * 26 + y));
            }
        }
        int i = 0;
        for (int j = 9; j < 15; j++)
        {
            Bitmap tmp = new Bitmap(64, 64);
            for (int y = 0; y < 64; y++)
            {
                for (int x = 0; x < 64; x++)
                {
                    tmp.SetPixel(x * zoom, y * zoom, aura.GetPixel(i * 64 + x, j * 64 + y));
                    using (Graphics gfcs = Graphics.FromImage(tmp)) //this ---v
                    {
                        smiley.PixelFormat = PixelFormat.
                        Point placement = new Point(19, 19);
                        gfcs.DrawImage(smiley, placement);
                    }
                }
            }
            // ^--- should be here
            images.Add(tmp);
            tmp.Save($"{j}.png");
        }
        //GIF stuff
    }

1 个答案:

答案 0 :(得分:-1)

我正在将宇航员写入图像4096次,看起来透明度正在变得混乱。

    public static void generateGIF()
    {
        int zoom = 1;
        int smileyID = 71;
        int goldBorder = 1;

        Console.WriteLine("Starting");
        List<Bitmap> images = new List<Bitmap>();
        Bitmap aura = new Bitmap(Image.FromFile("1511_Player_Aura.png"));
        Bitmap smilies = new Bitmap(Image.FromFile("1559_items.ItemManager_smiliesBM.png"));
        Bitmap smiley = new Bitmap(26, 26);

        using (Graphics gfcs = Graphics.FromImage(smiley))
        {
            Point placement = new Point(smileyID * -26, goldBorder * -26);
            gfcs.DrawImage(smilies, placement);
        }
        int i = 0;
        for (int j = 9; j < 15; j++)
        {
            Bitmap tmp = new Bitmap(64, 64);
            using (Graphics gfcs = Graphics.FromImage(tmp))
            {
                Point placement = new Point(i * -64, j * -64);
                gfcs.DrawImage(aura, placement);
            }
            using (Graphics gfcs = Graphics.FromImage(tmp))
            {
                Point placement = new Point(19, 19);
                gfcs.DrawImage(smiley, placement);
            }
            images.Add(tmp);
        }
        //GIF stuff
    }