2 using System.Collections.Generic;
3 using System.ComponentModel;
5 using System.Threading.Tasks;
6 using SiliconStudio.Core.Diagnostics;
7 using SiliconStudio.Paradox.Graphics;
8 using SiliconStudio.Core.Serialization;
9 using SiliconStudio.Core.Serialization.Assets;
10 using SiliconStudio.TextureConverter;
12 namespace SiliconStudio.BuildEngine
14 [Description(
"Process image")]
18 public override string Title {
get {
return "Process image " + (InputUrl ??
"[InputUrl]"); } }
20 public string InputUrl {
get; set; }
21 public string OutputUrl {
get; set; }
23 public float Width {
get; set; }
24 public float Height {
get; set; }
26 public bool IsAbsolute {
get; set; }
30 public bool GenerateMipmaps {
get; set; }
48 var image = assetManager.Load<
Image>(InputUrl);
52 using (var texImage = texTool.Load(image))
54 var outputFormat = Format.HasValue ? Format.Value : image.Description.Format;
57 texTool.Decompress(texImage);
60 texTool.Resize(texImage, (int)Width, (
int)Height, Filter.Rescaling.Lanczos3);
64 texTool.Rescale(texImage, Width / 100.0f, Height / 100.0f, Filter.Rescaling.Lanczos3);
70 texTool.GenerateMipMaps(texImage, Filter.MipMapGeneration.Box);
74 texTool.Compress(texImage, outputFormat);
77 using (var outputImage = texTool.ConvertToParadoxImage(texImage))
79 assetManager.Save(OutputUrl, outputImage);
81 commandContext.Logger.Info(
"Compression successful [{3}] to ({0}x{1},{2})",
82 outputImage.Description.Width,
83 outputImage.Description.Height, outputImage.Description.Format, OutputUrl);
87 return Task.FromResult(ResultStatus.Successful);
92 base.ComputeParameterHash(stream);
96 writer.Write(InputUrl);
97 writer.Write(OutputUrl);
100 writer.Write(IsAbsolute);
101 writer.Write(Format);
102 writer.Write(GenerateMipmaps);
107 return "Process image " + (InputUrl ??
"[InputUrl]") +
" > " + (OutputUrl ??
"[OutputUrl]");
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 ...
Provides method to load images or textures, to modify them and to convert them with different texture...
Provides method to instantiate an image 1D/2D/3D supporting TextureArray and mipmaps on the CPU or to...
Implements SerializationStream as a binary writer.
A Command that reads and/or writes to the index file.
override string ToString()
override void ComputeParameterHash(Stream stream)
PixelFormat
Defines various types of pixel formats.