public static bool GenerateNormalMap(PVRTexture sTexture, float fScale, string sChannelOrder) { return pvrttGenerateNormalMap(sTexture.texture, fScale, sChannelOrder); }
public static bool PreMultipliedAlpha(PVRTexture sTexture) { return pvrttPreMultipliedAlpha(sTexture.texture); }
/// <summary> /// Resizes the specified texture. /// </summary> /// <param name="sTexture">The texture.</param> /// <param name="u32NewWidth">The new width.</param> /// <param name="u32NewHeight">The new height.</param> /// <param name="u32NewDepth">The new depth.</param> /// <param name="eResizeMode">The resize mode (Filter).</param> /// <returns></returns> public static bool Resize(PVRTexture sTexture, uint u32NewWidth, uint u32NewHeight, uint u32NewDepth, EResizeMode eResizeMode) { return pvrttResize(sTexture.texture, out u32NewWidth, out u32NewHeight, out u32NewDepth, eResizeMode); }
/// <summary> /// Flips the specified texture. /// </summary> /// <param name="sTexture">The texture.</param> /// <param name="eFlipDirection">The flip direction.</param> /// <returns></returns> public static bool Flip(PVRTexture sTexture, EPVRTAxis eFlipDirection) { return pvrttFlip(sTexture.texture, eFlipDirection); }
/// <summary> /// Copies a specified channel from one texture to a specified channel in another texture. /// </summary> /// <param name="sTexture">The destination texture.</param> /// <param name="sTextureSource">The source texture.</param> /// <param name="uiNumChannelCopies">The UI num channel copies.</param> /// <param name="eChannels">The destination channel.</param> /// <param name="eChannelsSource">The source channel.</param> /// <returns></returns> public static bool CopyChannels(PVRTexture sTexture, PVRTexture sTextureSource, uint uiNumChannelCopies, out EChannelName eChannels, out EChannelName eChannelsSource) { return pvrttCopyChannels(sTexture.texture, sTextureSource.texture, uiNumChannelCopies, out eChannels, out eChannelsSource); }
public static bool Transcode(PVRTexture sTexture, UInt64 ptFormat, EPVRTVariableType eChannelType, EPVRTColourSpace eColourspace, ECompressorQuality eQuality = ECompressorQuality.ePVRTCNormal, bool bDoDither = false) { return pvrttTranscode(sTexture.texture, ptFormat, eChannelType, eColourspace, eQuality, bDoDither); }
public static bool GenerateNormalMap(PVRTexture sTexture, float fScale, string sChannelOrder) { return(pvrttGenerateNormalMap(sTexture.texture, fScale, sChannelOrder)); }
public static bool PreMultipliedAlpha(PVRTexture sTexture) { return(pvrttPreMultipliedAlpha(sTexture.texture)); }
/// <summary> /// Flips the specified texture. /// </summary> /// <param name="sTexture">The texture.</param> /// <param name="eFlipDirection">The flip direction.</param> /// <returns></returns> public static bool Flip(PVRTexture sTexture, EPVRTAxis eFlipDirection) { return(pvrttFlip(sTexture.texture, eFlipDirection)); }
/// <summary> /// Rotates a texture by 90 degrees around the given axis. bForward controls direction of rotation. /// </summary> /// <param name="sTexture">The texture.</param> /// <param name="eRotationAxis">Rotation axis</param> /// <param name="bForward">Direction of rotation; 1 = clockwise, 0 = anti-clockwise </param> /// <returns>True if the method succeeds or not.</returns> public static bool Rotate90(PVRTexture sTexture, EPVRTAxis eRotationAxis, bool bForward = true) { return(pvrttRotate90(sTexture.texture, eRotationAxis, bForward)); }
/// <summary> /// Resizes the specified texture. /// </summary> /// <param name="sTexture">The texture.</param> /// <param name="u32NewWidth">The new width.</param> /// <param name="u32NewHeight">The new height.</param> /// <param name="u32NewDepth">The new depth.</param> /// <param name="eResizeMode">The resize mode (Filter).</param> /// <returns></returns> public static bool Resize(PVRTexture sTexture, uint u32NewWidth, uint u32NewHeight, uint u32NewDepth, EResizeMode eResizeMode) { return(pvrttResize(sTexture.texture, out u32NewWidth, out u32NewHeight, out u32NewDepth, eResizeMode)); }
public static bool Transcode(PVRTexture sTexture, UInt64 ptFormat, EPVRTVariableType eChannelType, EPVRTColourSpace eColourspace, ECompressorQuality eQuality = ECompressorQuality.ePVRTCNormal, bool bDoDither = false) { return(pvrttTranscode(sTexture.texture, ptFormat, eChannelType, eColourspace, eQuality, bDoDither)); }
/// <summary> /// Copies a specified channel from one texture to a specified channel in another texture. /// </summary> /// <param name="sTexture">The destination texture.</param> /// <param name="sTextureSource">The source texture.</param> /// <param name="uiNumChannelCopies">The UI num channel copies.</param> /// <param name="eChannels">The destination channel.</param> /// <param name="eChannelsSource">The source channel.</param> /// <returns></returns> public static bool CopyChannels(PVRTexture sTexture, PVRTexture sTextureSource, uint uiNumChannelCopies, out EChannelName eChannels, out EChannelName eChannelsSource) { return(pvrttCopyChannels(sTexture.texture, sTextureSource.texture, uiNumChannelCopies, out eChannels, out eChannelsSource)); }
/// <summary> /// Switches the channels R and B. /// </summary> /// <param name="image">The image.</param> /// <param name="libraryData">The library data.</param> /// <param name="request">The request.</param> /// <exception cref="TexLibraryException">Unsuported format for channel switching.</exception> private void SwitchChannels(TexImage image, PvrTextureLibraryData libraryData, SwitchingBRChannelsRequest request) { Log.Info("Switching channels B and R ..."); switch (image.Format) { case SiliconStudio.Paradox.Graphics.PixelFormat.B8G8R8A8_UNorm: image.Format = SiliconStudio.Paradox.Graphics.PixelFormat.R8G8B8A8_UNorm; break; case SiliconStudio.Paradox.Graphics.PixelFormat.B8G8R8A8_Typeless: image.Format = SiliconStudio.Paradox.Graphics.PixelFormat.R8G8B8A8_Typeless; break; case SiliconStudio.Paradox.Graphics.PixelFormat.B8G8R8A8_UNorm_SRgb: image.Format = SiliconStudio.Paradox.Graphics.PixelFormat.R8G8B8A8_UNorm_SRgb; break; case SiliconStudio.Paradox.Graphics.PixelFormat.R8G8B8A8_Typeless: image.Format = SiliconStudio.Paradox.Graphics.PixelFormat.B8G8R8A8_Typeless; break; case SiliconStudio.Paradox.Graphics.PixelFormat.R8G8B8A8_UNorm: image.Format = SiliconStudio.Paradox.Graphics.PixelFormat.B8G8R8A8_UNorm; break; case SiliconStudio.Paradox.Graphics.PixelFormat.R8G8B8A8_UNorm_SRgb: image.Format = SiliconStudio.Paradox.Graphics.PixelFormat.B8G8R8A8_UNorm_SRgb; break; default: Log.Error("Unsuported format for channel switching."); throw new TextureToolsException("Unsuported format for channel switching."); } PVRTexture textureTemp = new PVRTexture(libraryData.Header, libraryData.Texture.GetDataPtr()); EChannelName e1 = EChannelName.eBlue; EChannelName e2 = EChannelName.eRed; Utilities.CopyChannels(libraryData.Texture, textureTemp, 1, out e1, out e2); Utilities.CopyChannels(libraryData.Texture, textureTemp, 1, out e2, out e1); textureTemp.Dispose(); UpdateImage(image, libraryData); }
/// <summary> /// Exports the specified image. /// </summary> /// <param name="image">The image.</param> /// <param name="libraryData">The library data.</param> /// <param name="export">The export request.</param> private void Export(TexImage image, PvrTextureLibraryData libraryData, ExportRequest request) { Log.Info("Exporting to " + request.FilePath + " ..."); if (request.MinimumMipMapSize > 1) // if a mimimun mipmap size was requested { int newMipMapCount = image.MipmapCount; for (int i = image.MipmapCount - 1; i > 0; --i) // looking for the mipmap level corresponding to the minimum size requeted. { if (libraryData.Header.GetWidth((uint)i) >= request.MinimumMipMapSize || libraryData.Header.GetHeight((uint)i) >= request.MinimumMipMapSize) { break; } --newMipMapCount; } // Creating a new texture corresponding to the requested mipmap levels PVRTextureHeader header = new PVRTextureHeader(RetrieveNativeFormat(image.Format), image.Height, image.Width, image.Depth, newMipMapCount, image.ArraySize, image.FaceCount); PVRTexture texture = new PVRTexture(header, IntPtr.Zero); try { for (uint i = 0; i < image.FaceCount; ++i) { for (uint j = 0; j < image.ArraySize; ++j) { for (uint k = 0; k < newMipMapCount; ++k) { Core.Utilities.CopyMemory(texture.GetDataPtr(k, j, i), libraryData.Texture.GetDataPtr(k, j, i), (int)libraryData.Header.GetDataSize((int)k, false, false)); } } } } catch (AccessViolationException e) { texture.Dispose(); Log.Error("Failed to export texture with the mipmap minimum size request. ", e); throw new TextureToolsException("Failed to export texture with the mipmap minimum size request. ", e); } // Saving the texture into a file and deleting it texture.Save(request.FilePath); texture.Dispose(); } else { libraryData.Texture.Save(request.FilePath); } image.Save(request.FilePath); }