[英]Converting animated .gif file into a .bmp strip
I was wondering if someone can direct me or guide me in order to use a.gif image and convert it into a.bmp strip image file.我想知道是否有人可以指导或指导我使用 a.gif 图像并将其转换为 a.bmp 条带图像文件。
First, you need to get the gif's size.首先,您需要获取 gif 的大小。 Then you need to find out how many frames there are.
然后你需要找出有多少帧。
After that you need to create a new image with Height = original height, and Width = Frames * Gif Width.之后,您需要创建一个新图像,其高度 = 原始高度,宽度 = 帧 * Gif 宽度。
Then you must paste the original Gif's frames into the strip like so: Frame N starts at pixel N*Width.然后,您必须像这样将原始 Gif 的帧粘贴到条带中:第 N 帧从像素 N*Width 开始。
That is if you're making a horizontal strip.也就是说,如果您要制作水平条带。
And here is the complete code for a console application:这是控制台应用程序的完整代码:
using System.Drawing;
using System.Drawing.Imaging;
foreach (var arg in args)
{
Image gif = Image.FromFile(arg);
FrameDimension dim = new FrameDimension(gif.FrameDimensionsList[0]);
int frames = gif.GetFrameCount(dim);
Bitmap resultingImage = new Bitmap(gif.Width * frames, gif.Height);
for (int i = 0; i < frames; i++)
{
gif.SelectActiveFrame(dim, i);
Rectangle destRegion = new Rectangle(gif.Width * i, 0, gif.Width, gif.Height);
Rectangle srcRegion = new Rectangle(0, 0, gif.Width, gif.Height);
using (Graphics grD = Graphics.FromImage(resultingImage))
{
grD.DrawImage(gif, destRegion, srcRegion, GraphicsUnit.Pixel);
}
}
resultingImage.Save("res.png", ImageFormat.Png);
}
The resulting image is saved in the compiled console app binary file directory under the name res.png
.生成的图像以名称
res.png
保存在已编译的控制台应用程序二进制文件目录中。 You can make the app save the resulting image right where the source file is, ask whether to make a horizontal or vertical strip, etc.您可以让应用程序将生成的图像保存在源文件所在的位置,询问是制作水平条带还是垂直条带等。
Making an image strip can be easily done with Photoshop (you can get a free trial version, or Elements)使用 Photoshop 可以轻松制作图像条(您可以获得免费试用版或 Elements)
If you are using Photoshop, you can just export as BMP.如果您使用的是 Photoshop,则可以导出为 BMP。 Thats it.
而已。
The method what works for sure is:肯定有效的方法是:
Maybe it's not the easiest method but it gives the possibility of precise editing and allows you to make strips of icons that are on a transparent background (but not limited to icons)也许这不是最简单的方法,但它提供了精确编辑的可能性,并允许您制作透明背景上的图标条(但不限于图标)
Just load.gif in Bitmap and save it in.bmp.只需加载Bitmap中的.gif并保存为.bmp。 If you want to export the frames of.gif I have no idea how to do this.
如果您想导出.gif 的帧,我不知道该怎么做。 You can have look at this www.eggheadcafe.com/articles/stripimagefromanimatedgif.asp , it seems to be what what you're looking for.
你可以看看这个www.eggheadcafe.com/articles/stripimagefromanimatedgif.asp ,它似乎就是你要找的东西。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.