我有2个位图,我希望将其覆盖在另一个上,但使用Graphics
或Magick.net
不能达到预期的效果。
图形效果最好,速度最快,但透明度似乎搞得一团糟。
using (Graphics gfcs = Graphics.FromImage(spiral))
{
Point placement = new Point(19,19);
gfcs.DrawImage(astronaut, placement);
}
周边来源:
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
}
答案 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
}