简体   繁体   English

将 animated.gif 文件转换为.bmp 条带

[英]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)

  1. Open.gif - Photoshop will open each frame as a layer Open.gif - Photoshop 将每个帧作为图层打开
  2. Resize canvas to (height of the gif * layers) pixels将 canvas 调整为(gif * 图层的高度)像素
  3. Remove all frame information, keep layers去除所有帧信息,保留图层
  4. Select last layer, and move it to very bottom Select 最后一层,移到最底层
  5. Select all layers and click 'Distribute vertical centers'. Select 所有图层并单击“分布垂直中心”。 Now you have a perfectly arranged strip.现在你有一个完美排列的条带。

If you are using Photoshop, you can just export as BMP.如果您使用的是 Photoshop,则可以导出为 BMP。 Thats it.而已。

The method what works for sure is:肯定有效的方法是:

  1. Download an install Easy GIF Animator下载并安装 Easy GIF Animator
  2. Open tour gif with it and export the frames to separate files用它打开旅游 gif 并将帧导出到单独的文件
  3. Download and install any program which can create the layers (eg. Photoshop CS3 Little)下载并安装任何可以创建图层的程序(例如 Photoshop CS3 Little)
  4. Create a new file width as your picture;创建一个新的文件宽度作为你的图片; Height = Height of Your pic.高度 = 您照片的高度。 X number of pictures X张图片
  5. Copy each pic.复制每张照片。 as a layers in to Your new file and move them one after the other.作为你的新文件的一层,一个接一个地移动它们。
  6. Save it as a.png file保存为.png文件
  7. Download an install iPAQ 31x Image Explorer下载安装 iPAQ 31x Image Explorer
  8. Open Your.png in it在其中打开 Your.png
  9. Save it as aRGB file (normal BMP may don't work)另存为RGB文件(普通BMP可能不行)
  10. DONE!!完毕!!

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM