public void ExportToParadoxTest(string file) { TexImage image = TestTools.Load(library, file); ExportToParadoxRequest request = new ExportToParadoxRequest(); library.Execute(image, request); var pdx = request.PdxImage; Assert.IsTrue(pdx.TotalSizeInBytes == image.DataSize); Assert.IsTrue(pdx.Description.MipLevels == image.MipmapCount); Assert.IsTrue(pdx.Description.Width == image.Width); Assert.IsTrue(pdx.Description.Height == image.Height); image.Dispose(); }
/// <summary> /// Converts to paradox image. /// </summary> /// <param name="image">The image.</param> /// <returns>The converted Paradox <see cref="SiliconStudio.Paradox.Graphics.Image"/>.</returns> /// <remarks>The user is the owner of the returned image, and has to dispose it after he finishes using it</remarks> public SiliconStudio.Paradox.Graphics.Image ConvertToParadoxImage(TexImage image) { var request = new ExportToParadoxRequest(); ExecuteRequest(image, request); return request.PdxImage; }
/// <summary> /// Exports to Paradox <see cref="Image"/>. An instance will be stored in the <see cref="ExportToParadoxRequest"/> instance. /// </summary> /// <param name="image">The image.</param> /// <param name="libraryData">The library data.</param> /// <param name="request">The request.</param> /// <exception cref="System.InvalidOperationException"> /// Image size different than expected. /// or /// Failed to convert texture into Paradox Image. /// </exception> /// <exception cref="System.NotImplementedException"></exception> private void ExportToParadox(TexImage image, ParadoxTextureLibraryData libraryData, ExportToParadoxRequest request) { Log.Info("Exporting to Paradox Image ..."); Image pdxImage = null; switch (image.Dimension) { case TexImage.TextureDimension.Texture1D: pdxImage = Image.New1D(image.Width, image.MipmapCount, image.Format, image.ArraySize); break; case TexImage.TextureDimension.Texture2D: pdxImage = Image.New2D(image.Width, image.Height, image.MipmapCount, image.Format, image.ArraySize); break; case TexImage.TextureDimension.Texture3D: pdxImage = Image.New3D(image.Width, image.Height, image.Depth, image.MipmapCount, image.Format); break; case TexImage.TextureDimension.TextureCube: pdxImage = Image.NewCube(image.Width, image.MipmapCount, image.Format); break; } if (pdxImage == null) { Log.Error("Image could not be created."); throw new InvalidOperationException("Image could not be created."); } if (pdxImage.TotalSizeInBytes != image.DataSize) { Log.Error("Image size different than expected."); throw new InvalidOperationException("Image size different than expected."); } Utilities.CopyMemory(pdxImage.DataPointer, image.Data, image.DataSize); request.PdxImage = pdxImage; }
/// <summary> /// Exports to Paradox <see cref="Image"/>. An instance will be stored in the <see cref="ExportToParadoxRequest"/> instance. /// </summary> /// <param name="image">The image.</param> /// <param name="libraryData">The library data.</param> /// <param name="request">The request.</param> /// <exception cref="System.InvalidOperationException"> /// Image size different than expected. /// or /// Failed to convert texture into Paradox Image. /// </exception> /// <exception cref="System.NotImplementedException"></exception> private void ExportToParadox(TexImage image, ParadoxTextureLibraryData libraryData, ExportToParadoxRequest request) { Log.Debug("Exporting to Paradox Image ..."); Image pdxImage = null; switch (image.Dimension) { case TexImage.TextureDimension.Texture1D: pdxImage = Image.New1D(image.Width, image.MipmapCount, image.Format, image.ArraySize); break; case TexImage.TextureDimension.Texture2D: pdxImage = Image.New2D(image.Width, image.Height, image.MipmapCount, image.Format, image.ArraySize); break; case TexImage.TextureDimension.Texture3D: pdxImage = Image.New3D(image.Width, image.Height, image.Depth, image.MipmapCount, image.Format); break; case TexImage.TextureDimension.TextureCube: pdxImage = Image.NewCube(image.Width, image.MipmapCount, image.Format); break; } if (pdxImage == null) { Log.Error("Image could not be created."); throw new InvalidOperationException("Image could not be created."); } if (pdxImage.TotalSizeInBytes != image.DataSize) { Log.Error("Image size different than expected."); throw new InvalidOperationException("Image size different than expected."); } Utilities.CopyMemory(pdxImage.DataPointer, image.Data, image.DataSize); request.PdxImage = pdxImage; }