Example #1
0
 /// <summary>
 /// Converts a common image file (<see cref="System.Drawing.Image"/> backend) into a WcgImage.
 /// </summary>
 /// <param name="file">Path to the image file.</param>
 /// <returns>WcgImage representation of the image.s</returns>
 public static WcgImage FromImage(string file)
 {
     using (var img = Image.FromFile(file))
     {
         return(WcgImage.FromImage(img));
     }
 }
Example #2
0
        private static void FillEntry(LwgEntry entry, string path, bool aggressive)
        {
            string[] fileEndings = new string[] { ".wcg", ".msk" };
            entry.Content = new byte[0];

            if (entry.Flag != (byte)LWGFlags.String)
            {
                string ePath = Path.Combine(path, entry.Path);
                if (aggressive && File.Exists(ePath + ".png"))
                {
                    var img = WcgImage.FromImage(ePath + ".png");
                    using (var memory = new MemoryStream())
                    {
                        img.Save(memory);
                        entry.Content = memory.ToArray();
                    }
                }
                else
                {
                    foreach (var ext in fileEndings)
                    {
                        if (File.Exists(ePath + ext))
                        {
                            entry.Content = File.ReadAllBytes(ePath + ext);
                        }
                    }
                }
            }
        }