/// <summary> /// Extracts an animated image file. Returns true if successful. /// </summary> /// <param name="filePath">The file path the file will be saved to.</param> /// <param name="size">The size of the extracted image.</param> /// <param name="maxSize">The maximum size from the base image. Not the base image size.</param> /// <param name="frames">The amount of frames the animated image has.</param> /// <param name="frameDelay">The amount of delay for each frame.</param> /// <returns></returns> protected bool ExtractAnimatedImageFile(string filePath, Size size, Size maxSize, int frames, int frameDelay) { string fileName = Path.GetFileName(filePath); return(ExtractImageFile(filePath, () => { string textureFilepath = Path.Combine(TexturesPath, fileName); if (FileExists(textureFilepath)) { using (Stream stream = OpenFile(textureFilepath)) { DDSImage image = new DDSImage(stream); PathHelper.FileNameToLower(filePath.AsMemory()); image.SaveAsGif(Path.ChangeExtension(filePath, "gif"), size, maxSize, frames, frameDelay); return true; } } else { FailedFileMessages.Add($"File not found: {fileName}"); return false; } })); }
public void TextureSheetIntoAGifTest() { string file = "storm_emoji_cat_gleam_anim_sheet.dds"; DDSImage image = new DDSImage(file); image.SaveAsGif(Path.ChangeExtension(file, "gif"), new Size(34, 32), new Size(40, 32), 25, 50); Assert.IsTrue(File.Exists(Path.ChangeExtension(file, "gif"))); }
/// <summary> /// Extracts an animated image file. Returns true if successful. /// </summary> /// <param name="filePath">The file path the file will be saved to.</param> /// <param name="image">The image in <see cref="DDSImage"/> format.</param> /// <param name="size">The size of the extracted image.</param> /// <param name="maxSize">The maximum size from the base image. Not the base image size.</param> /// <param name="frames">The amount of frames the animated image has.</param> /// <param name="frameDelay">The amount of delay for each frame.</param> /// <returns></returns> protected bool ExtractAnimatedImageFile(string filePath, DDSImage image, Size size, Size maxSize, int frames, int frameDelay) { return(ExtractImageFile(filePath, () => { PathHelper.FileNameToLower(filePath.AsMemory()); image.SaveAsGif(Path.ChangeExtension(filePath, "gif"), size, maxSize, frames, frameDelay); return true; })); }