/// <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> /// 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)); }
private extern static bool pvrttCopyChannels(IntPtr sTexture, IntPtr sTextureSource, uint uiNumChannelCopies, out EChannelName eChannels, out EChannelName eChannelsSource);
/// <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); }