public static ImageSequence LoadFromTgas(String pathName) { // First we load up the Data In the Serialization file. String gameDataObjectXMLPath = Path.Combine(pathName, "ImageSequence"); ImageSequence sequenceLoaded = new ImageSequence(); // Now lets look for and load up any images that we find. String[] tgaFilesArray = Directory.GetFiles(pathName, "*.tga"); List <String> sortedTgaFiles = new List <string>(tgaFilesArray); // Make sure they are sorted. sortedTgaFiles.Sort(); sequenceLoaded.imageList = new List <ImageBuffer>(); int imageIndex = 0; foreach (String tgaFile in sortedTgaFiles) { sequenceLoaded.AddImage(new ImageBuffer(new BlenderPreMultBGRA())); Stream imageStream = File.Open(tgaFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); ImageTgaIO.LoadImageData(sequenceLoaded.imageList[imageIndex], imageStream, 32); imageIndex++; } return(sequenceLoaded); }
public virtual bool LoadImageData(String pathToGifFile, ImageSequence destImageSequence) { if (File.Exists(pathToGifFile)) { using (Stream stream = new StreamReader(pathToGifFile).BaseStream) { return LoadImageData(stream, destImageSequence); } } return false; }
public static ImageSequence LoadFromTgas(string pathName) { var sequenceLoaded = new ImageSequence(); // Now lets look for and load up any images that we find. var sortedTgaFiles = Directory.GetFiles(pathName, "*.tga").OrderBy(s => s); foreach (string tgaFile in sortedTgaFiles) { using (var imageStream = File.OpenRead(tgaFile)) { var imageBuffer = new ImageBuffer(new BlenderPreMultBGRA()); ImageTgaIO.LoadImageData(imageBuffer, imageStream, 32); sequenceLoaded.AddImage(imageBuffer); } } return(sequenceLoaded); }
public bool LoadImageData(Stream stream, ImageSequence destImageSequence) { var gifImg = System.Drawing.Image.FromStream(stream); if (gifImg != null) { FrameDimension dimension = new FrameDimension(gifImg.FrameDimensionsList[0]); // Number of frames int frameCount = gifImg.GetFrameCount(dimension); for (int i = 0; i < frameCount; i++) { // Return an Image at a certain index gifImg.SelectActiveFrame(dimension, i); using (var bitmap = new Bitmap(gifImg)) { var frame = new ImageBuffer(); ConvertBitmapToImage(frame, bitmap); destImageSequence.AddImage(frame); } } try { PropertyItem item = gifImg.GetPropertyItem(0x5100); // FrameDelay in libgdiplus // Time is in 1/100th of a second destImageSequence.SecondsPerFrame = (item.Value[0] + item.Value[1] * 256) / 100.0; } catch (Exception e) { Debug.Print(e.Message); GuiWidget.BreakInDebugger(); destImageSequence.SecondsPerFrame = 2; } return(true); } return(false); }
public override bool LoadImageData(String pathToGifFile, ImageSequence destImageSequence) { if (File.Exists(pathToGifFile) && Path.GetExtension(pathToGifFile).ToUpper() == ".GIF") { System.Drawing.Image gifImg = System.Drawing.Image.FromFile(pathToGifFile); if (gifImg != null) { FrameDimension dimension = new FrameDimension(gifImg.FrameDimensionsList[0]); // Number of frames int frameCount = gifImg.GetFrameCount(dimension); for (int i = 0; i < frameCount; i++) { // Return an Image at a certain index gifImg.SelectActiveFrame(dimension, i); ImageBuffer frame = new ImageBuffer(); ConvertBitmapToImage(frame, new Bitmap(gifImg)); destImageSequence.AddImage(frame); } try { PropertyItem item = gifImg.GetPropertyItem(0x5100); // FrameDelay in libgdiplus // Time is in 1/100th of a second destImageSequence.SecondsPerFrame = (item.Value[0] + item.Value[1] * 256) / 100.0; } catch { destImageSequence.SecondsPerFrame = 2; } return true; } } return false; }
public override bool LoadImageData(String pathToGifFile, ImageSequence destImageSequence) { if (File.Exists(pathToGifFile) && Path.GetExtension(pathToGifFile).ToUpper() == ".GIF") { System.Drawing.Image gifImg = System.Drawing.Image.FromFile(pathToGifFile); if (gifImg != null) { FrameDimension dimension = new FrameDimension(gifImg.FrameDimensionsList[0]); // Number of frames int frameCount = gifImg.GetFrameCount(dimension); for (int i = 0; i < frameCount; i++) { // Return an Image at a certain index gifImg.SelectActiveFrame(dimension, i); ImageBuffer frame = new ImageBuffer(); ConvertBitmapToImage(frame, new Bitmap(gifImg)); destImageSequence.AddImage(frame); } try { PropertyItem item = gifImg.GetPropertyItem(0x5100); // FrameDelay in libgdiplus // Time is in 1/100th of a second destImageSequence.SecondsPerFrame = (item.Value[0] + item.Value[1] * 256) / 100.0; } catch { destImageSequence.SecondsPerFrame = 2; } return(true); } } return(false); }
public override bool LoadImageData(Stream stream, ImageSequence destImageSequence) { System.Drawing.Image gifImg = System.Drawing.Image.FromStream(stream); if (gifImg != null) { FrameDimension dimension = new FrameDimension(gifImg.FrameDimensionsList[0]); // Number of frames int frameCount = gifImg.GetFrameCount(dimension); for (int i = 0; i < frameCount; i++) { // Return an Image at a certain index gifImg.SelectActiveFrame(dimension, i); ImageBuffer frame = new ImageBuffer(); ConvertBitmapToImage(frame, new Bitmap(gifImg)); destImageSequence.AddImage(frame); } try { PropertyItem item = gifImg.GetPropertyItem(0x5100); // FrameDelay in libgdiplus // Time is in 1/100th of a second destImageSequence.SecondsPerFrame = (item.Value[0] + item.Value[1] * 256) / 100.0; } catch (Exception e) { Debug.Print(e.Message); GuiWidget.BreakInDebugger(); destImageSequence.SecondsPerFrame = 2; } return true; } return false; }
public void LoadSequence(string pathToImages, ImageSequence sequence) { if (DirectoryExists(pathToImages)) { string propertiesPath = Path.Combine(pathToImages, "properties.json"); if (FileExists(propertiesPath)) { string jsonData = ReadAllText(propertiesPath); ImageSequence.Properties properties = JsonConvert.DeserializeObject<ImageSequence.Properties>(jsonData); sequence.FramePerSecond = properties.FramePerFrame; sequence.Looping = properties.Looping; } string[] pngFilesIn = GetFiles(pathToImages).Where(fileName => Path.GetExtension(fileName).ToUpper() == ".PNG").ToArray(); List<string> pngFiles = new List<string>(pngFilesIn); pngFiles.Sort(); foreach (string pngFile in pngFiles) { ImageBuffer image = new ImageBuffer(); LoadImage(pngFile, image); sequence.AddImage(image); } } }
public static bool LoadImageData(Stream stream, ImageSequence sequence) { // if (AggContext.OperatingSystem == OSType.Mac) #if OSX SixLabors.ImageSharp.Image image; try { image = SixLabors.ImageSharp.Image.Load(stream); } catch { return(false); } sequence.Frames.Clear(); sequence.FrameTimesMs.Clear(); if (image.Frames.Count > 1) { var minFrameTimeMs = int.MaxValue; for (var i = 0; i < image.Frames.Count; i++) { // Return an Image at a certain index var imageBuffer = new ImageBuffer(); ConvertImageToImageBuffer(imageBuffer, image.Frames.CloneFrame(i)); var frameData = image.Frames[i].Metadata.GetGifMetadata(); var frameDelay = frameData.FrameDelay * 10; sequence.AddImage(imageBuffer, frameDelay); minFrameTimeMs = Math.Max(10, Math.Min(frameDelay, minFrameTimeMs)); } sequence.SecondsPerFrame = minFrameTimeMs / 1000.0; } else { var imageBuffer = new ImageBuffer(); if (ImageIO.ConvertImageToImageBuffer(imageBuffer, image)) { sequence.AddImage(imageBuffer); } } Configuration.Default.MemoryAllocator.ReleaseRetainedResources(); return(true); #else Image <Rgba32> image; try { image = Image <Rgba32> .Load <Rgba32>(stream); } catch { return(false); } sequence.Frames.Clear(); sequence.FrameTimesMs.Clear(); if (image.Frames.Count > 1) { var minFrameTimeMs = int.MaxValue; for (var i = 0; i < image.Frames.Count; i++) { // Return an Image at a certain index ImageBuffer imageBuffer = new ImageBuffer(); ConvertImageToImageBuffer(imageBuffer, image.Frames[i]); var frameData = image.Frames[i].Metadata.GetGifMetadata(); var frameDelay = frameData.FrameDelay * 10; sequence.AddImage(imageBuffer, frameDelay); minFrameTimeMs = Math.Max(10, Math.Min(frameDelay, minFrameTimeMs)); } sequence.SecondsPerFrame = minFrameTimeMs / 1000.0; } else { ImageBuffer imageBuffer = new ImageBuffer(); if (ImageIO.ConvertImageToImageBuffer(imageBuffer, image)) { sequence.AddImage(imageBuffer); } } return(true); #endif }
static public bool LoadImageData(Stream steam, ImageSequence destImageSequence) { return AvailableImageIOPlugin.LoadImageData(steam, destImageSequence); }
static public bool LoadImageData(String pathToGifFile, ImageSequence destImageSequence) { return AvailableImageIOPlugin.LoadImageData(pathToGifFile, destImageSequence); }
public ImageSequenceWidget(ImageSequence initialImageSequence) : this(initialImageSequence.Width, initialImageSequence.Height) { ImageSequence = initialImageSequence; }
public static ImageSequence LoadFromTgas(String pathName) { // First we load up the Data In the Serialization file. String gameDataObjectXMLPath = Path.Combine(pathName, "ImageSequence"); ImageSequence sequenceLoaded = new ImageSequence(); // Now lets look for and load up any images that we find. String[] tgaFilesArray = Directory.GetFiles(pathName, "*.tga"); List<String> sortedTgaFiles = new List<string>(tgaFilesArray); // Make sure they are sorted. sortedTgaFiles.Sort(); sequenceLoaded.imageList = new List<ImageBuffer>(); int imageIndex = 0; foreach (String tgaFile in sortedTgaFiles) { sequenceLoaded.AddImage(new ImageBuffer(new BlenderPreMultBGRA())); Stream imageStream = File.Open(tgaFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); ImageTgaIO.LoadImageData(sequenceLoaded.imageList[imageIndex], imageStream, 32); imageIndex++; } return sequenceLoaded; }
public virtual bool LoadImageData(Stream stream, ImageSequence destImageSequence) { return false; }
public virtual bool LoadImageData(String pathToGifFile, ImageSequence destImageSequence) { throw new Exception("You must implement this in an inherited class."); }