Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
ImportImageCommand.cs
Go to the documentation of this file.
1 using System;
2 using System.Collections.Generic;
3 using System.ComponentModel;
4 using System.IO;
5 using SiliconStudio.Paradox.Graphics;
6 using SiliconStudio.Core.Serialization;
7 using SiliconStudio.Core.Serialization.Assets;
8 using System.Threading.Tasks;
9 
10 namespace SiliconStudio.BuildEngine
11 {
12  [Description("Import image")]
14  {
15  /// <inheritdoc/>
16  public override string Title { get { string title = "Import Image "; try { title += Path.GetFileName(SourcePath) ?? "[File]"; } catch { title += "[INVALID PATH]"; } return title; } }
17 
18  protected override Task<ResultStatus> DoCommandOverride(ICommandContext commandContext)
19  {
20  var assetManager = new AssetManager();
21 
22  Image image;
23  using (var fileStream = new FileStream(SourcePath, FileMode.Open, FileAccess.Read))
24  {
25  image = Image.Load(fileStream);
26  }
27  assetManager.Save(Location, image);
28  image.Dispose();
29 
30  return Task.FromResult(ResultStatus.Successful);
31  }
32 
33  protected override void ComputeParameterHash(Stream stream)
34  {
35  base.ComputeParameterHash(stream);
36 
37  var writer = new BinarySerializationWriter(stream);
38  writer.Write(SourcePath);
39  writer.Write(Location);
40  }
41 
43  {
44  yield return new ObjectUrl(UrlType.File, SourcePath);
45  }
46 
47  public override string ToString()
48  {
49  return "Import image " + (SourcePath ?? "[File]") + " > " + (Location ?? "[Location]");
50  }
51  }
52 }
Provides method to instantiate an image 1D/2D/3D supporting TextureArray and mipmaps on the CPU or to...
Definition: Image.cs:88
System.IO.FileMode FileMode
Definition: ScriptSync.cs:33
Implements SerializationStream as a binary writer.
override IEnumerable< ObjectUrl > GetInputFiles()
Gets the list of input files (that can be deduced without running the command, only from command para...
override Task< ResultStatus > DoCommandOverride(ICommandContext commandContext)
The method to override containing the actual command code. It is called by the DoCommand function ...
override void ComputeParameterHash(Stream stream)