Nexus.Client.ModManagement.Scripting.XmlScript.UI.Controls.NodeEditors.OptionInfoEditorVM.GetImage C# (CSharp) Method

GetImage() public method

public GetImage ( string p_strImagePath ) : Image
p_strImagePath string
return Image
		public Image GetImage(string p_strImagePath)
		{
			if (ModFiles == null)
				return null;
			VirtualFileSystemItem vfiItem = ModFiles.Find((f) => { return f.Path.Equals(p_strImagePath, StringComparison.OrdinalIgnoreCase); });
			byte[] bteImage = null;
			if (vfiItem != null)
			{
				if (Archive.IsArchivePath(vfiItem.Source))
				{
					KeyValuePair<string, string> kvpArchive = Archive.ParseArchivePath(vfiItem.Source);
					using (Archive arcMod = new Archive(kvpArchive.Key))
					{
						bteImage = arcMod.GetFileContents(kvpArchive.Value);
					}
				}
				else if (File.Exists(vfiItem.Source))
				{
					bteImage = File.ReadAllBytes(vfiItem.Source);
				}
			}
			if (bteImage == null)
				return null;
			using (MemoryStream msmImage = new MemoryStream(bteImage))
			{
				try
				{
					Image imgTmp = Image.FromStream(msmImage);
					return new Bitmap(imgTmp);
				}
				catch (ArgumentException)
				{
				}
			}
			return null;
		}