Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
PvrttNetWrapper.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 using System;
4 using System.Security;
5 using System.Runtime.InteropServices;
6 
7 namespace SiliconStudio.TextureConverter.PvrttWrapper
8 {
9 
10  #region Enum
11  internal enum PixelType
12  {
16  };
17 
18  internal enum EPVRTColourSpace
19  {
23  };
24 
25  internal enum EPVRTVariableType
26  {
39  ePVRTVarTypeSignedFloat, ePVRTVarTypeFloat = ePVRTVarTypeSignedFloat, //the name ePVRTVarTypeFloat is now deprecated.
42  };
43 
44  internal enum ECompressorQuality
45  {
46  ePVRTCFast=0,
48  ePVRTCHigh,
49  ePVRTCBest,
51 
52  eETCFast=0,
54  eETCSlow,
57  };
58 
59  internal enum EResizeMode
60  {
65  };
66 
67  internal enum EChannelName
68  {
69  eNoChannel,
70  eRed,
71  eGreen,
72  eBlue,
73  eAlpha,
74  eLuminance,
75  eIntensity,
78  };
79 
80  internal enum EPVRTAxis
81  {
82  ePVRTAxisX = 0,
83  ePVRTAxisY = 1,
84  ePVRTAxisZ = 2
85  };
86 
87  internal enum EPVRTPixelFormat
88  {
100  ePVRTPF_DXT5,
101 
102  //These formats are identical to some DXT formats.
103  ePVRTPF_BC1 = ePVRTPF_DXT1,
104  ePVRTPF_BC2 = ePVRTPF_DXT3,
105  ePVRTPF_BC3 = ePVRTPF_DXT5,
106 
107  //These are currently unsupported:
108  ePVRTPF_BC4,
109  ePVRTPF_BC5,
110  ePVRTPF_BC6,
111  ePVRTPF_BC7,
112 
113  //These are supported
114  ePVRTPF_UYVY,
115  ePVRTPF_YUY2,
125 
126  //Invalid value
128  };
129 
130  #endregion
131 
132  #region Constants
133  public class Constant
134  {
135  public const uint TOPMIPLEVEL = 0;
136  public const int ALLMIPLEVELS = -1;
137  public const uint PVRTEX3_IDENT = 0x03525650; // 'P''V''R'3
138  public const uint PVRTEX3_PREMULTIPLIED = (1 << 1); // Texture has been premultiplied by alpha value.
139  }
140  #endregion
141 
142 
143 
144 
145  #region public class Utilities
146 
147  /// <summary>
148  /// Provides utilities methods to handle PVR Texture type.
149  /// </summary>
150  internal class Utilities
151  {
152  #region Bindings
153  [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
154  private extern static bool pvrttTranscodeWithNoConversion(IntPtr texture, PixelType ptFormat, EPVRTVariableType eChannelType, EPVRTColourSpace eColourspace, ECompressorQuality eQuality, bool bDoDither);
155 
156  [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
157  private extern static bool pvrttTranscode(IntPtr texture, UInt64 ptFormat, EPVRTVariableType eChannelType, EPVRTColourSpace eColourspace, ECompressorQuality eQuality, bool bDoDither);
158 
159  [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
160  private extern static bool pvrttCopyChannels(IntPtr sTexture, IntPtr sTextureSource, uint uiNumChannelCopies, out EChannelName eChannels, out EChannelName eChannelsSource);
161 
162  [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
163  private extern static bool pvrttResize(IntPtr sTexture, out uint u32NewWidth, out uint u32NewHeight, out uint u32NewDepth, EResizeMode eResizeMode);
164 
165  [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
166  private extern static bool pvrttFlip(IntPtr sTexture, EPVRTAxis eFlipDirection);
167 
168  [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
169  private extern static bool pvrttGenerateNormalMap(IntPtr sTexture, float fScale, string sChannelOrder);
170 
171  [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
172  private extern static UInt64 pvrttConvertPixelType(PixelType pixelFormat);
173 
174  [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
175  private extern static int pvrttDecompressPVRTC(IntPtr pCompressedData, int Do2bitMode, int XDim, int YDim, IntPtr pResultImage);
176 
177  [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
178  private extern static int pvrttDecompressETC(IntPtr pSrcData, uint x, uint y, IntPtr pDestData, int nMode);
179 
180  [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
181  private extern static bool pvrttPreMultipliedAlpha(IntPtr sTexture);
182 
183  #endregion
184 
185  /// <summary>
186  /// Copies a specified channel from one texture to a specified channel in another texture.
187  /// </summary>
188  /// <param name="sTexture">The destination texture.</param>
189  /// <param name="sTextureSource">The source texture.</param>
190  /// <param name="uiNumChannelCopies">The UI num channel copies.</param>
191  /// <param name="eChannels">The destination channel.</param>
192  /// <param name="eChannelsSource">The source channel.</param>
193  /// <returns></returns>
194  public static bool CopyChannels(PVRTexture sTexture, PVRTexture sTextureSource, uint uiNumChannelCopies, out EChannelName eChannels, out EChannelName eChannelsSource)
195  {
196  return pvrttCopyChannels(sTexture.texture, sTextureSource.texture, uiNumChannelCopies, out eChannels, out eChannelsSource);
197  }
198 
199  public static bool Transcode(PVRTexture sTexture, PixelType ptFormat, EPVRTVariableType eChannelType, EPVRTColourSpace eColourspace, ECompressorQuality eQuality = ECompressorQuality.ePVRTCNormal, bool bDoDither = false)
200  {
201  return pvrttTranscodeWithNoConversion(sTexture.texture, ptFormat, eChannelType, eColourspace, eQuality, bDoDither);
202  }
203 
204  public static bool Transcode(PVRTexture sTexture, UInt64 ptFormat, EPVRTVariableType eChannelType, EPVRTColourSpace eColourspace, ECompressorQuality eQuality = ECompressorQuality.ePVRTCNormal, bool bDoDither = false)
205  {
206  return pvrttTranscode(sTexture.texture, ptFormat, eChannelType, eColourspace, eQuality, bDoDither);
207  }
208 
209  /// <summary>
210  /// Resizes the specified texture.
211  /// </summary>
212  /// <param name="sTexture">The texture.</param>
213  /// <param name="u32NewWidth">The new width.</param>
214  /// <param name="u32NewHeight">The new height.</param>
215  /// <param name="u32NewDepth">The new depth.</param>
216  /// <param name="eResizeMode">The resize mode (Filter).</param>
217  /// <returns></returns>
218  public static bool Resize(PVRTexture sTexture, uint u32NewWidth, uint u32NewHeight, uint u32NewDepth, EResizeMode eResizeMode)
219  {
220  return pvrttResize(sTexture.texture, out u32NewWidth, out u32NewHeight, out u32NewDepth, eResizeMode);
221  }
222 
223 
224  /// <summary>
225  /// Flips the specified texture.
226  /// </summary>
227  /// <param name="sTexture">The texture.</param>
228  /// <param name="eFlipDirection">The flip direction.</param>
229  /// <returns></returns>
230  public static bool Flip(PVRTexture sTexture, EPVRTAxis eFlipDirection)
231  {
232  return pvrttFlip(sTexture.texture, eFlipDirection);
233  }
234 
235  public static bool GenerateNormalMap(PVRTexture sTexture, float fScale, string sChannelOrder)
236  {
237  return pvrttGenerateNormalMap(sTexture.texture, fScale, sChannelOrder);
238  }
239 
240  public static UInt64 ConvertPixelType(PixelType pixelFormat)
241  {
242  return pvrttConvertPixelType(pixelFormat);
243  }
244 
245  public static int DecompressPVRTC(IntPtr pCompressedData, int Do2bitMode, int XDim, int YDim, IntPtr pResultImage)
246  {
247  return pvrttDecompressPVRTC(pCompressedData, Do2bitMode, XDim, YDim, pResultImage);
248  }
249 
250  public static int DecompressETC(IntPtr pSrcData, uint x, uint y, IntPtr pDestData, int nMode)
251  {
252  return pvrttDecompressETC(pSrcData, x, y, pDestData, nMode);
253  }
254 
255  public static bool PreMultipliedAlpha(PVRTexture sTexture)
256  {
257  return pvrttPreMultipliedAlpha(sTexture.texture);
258  }
259  }
260  #endregion
261 
262  #region public class CPVRTexture
263  /// <summary>
264  /// Binding class of PVR Texture class PVRTexture.
265  /// </summary>
266  internal class PVRTexture : IDisposable
267  {
268  internal IntPtr texture;
269 
270  #region Constants
271  const uint TOPMIPLEVEL = 0;
272  const int ALLMIPLEVELS = -1;
273  #endregion
274 
275  #region Bindings
276  [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
277  private extern static IntPtr pvrttCreateTexture();
278 
279  [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
280  private extern static IntPtr pvrttCreateTextureFromHeader(IntPtr header, IntPtr data);
281 
282  [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
283  private extern static IntPtr pvrttCreateTextureFromMemory(IntPtr pTexture);
284 
285  [DllImport("PvrttWrapper.dll", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
286  private extern static IntPtr pvrttCreateTextureFromFile(String filePath);
287 
288  [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
289  private extern static void pvrttDestroyTexture(IntPtr texture);
290 
291  [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
292  private extern static bool pvrttSaveFile(IntPtr texture, String filePath);
293 
294  [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
295  private extern static IntPtr pvrttGetHeader(IntPtr texture);
296 
297  [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
298  private extern static IntPtr pvrttGetDataPtr(IntPtr texture, uint uiMIPLevel, uint uiArrayMember, uint uiFaceNumber);
299 
300  [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
301  private extern static bool pvrttGenerateMIPMaps(IntPtr texture, EResizeMode eFilterMode, int uiMIPMapsToDo);
302 
303  #endregion
304 
305  public PVRTexture()
306  {
307  texture = pvrttCreateTexture();
308  }
309 
310  public PVRTexture(IntPtr pTexture)
311  {
312  texture = pvrttCreateTextureFromMemory(pTexture);
313  }
314 
315  public PVRTexture(string filePath)
316  {
317  texture = pvrttCreateTextureFromFile(filePath);
318  }
319 
320  public PVRTexture(PVRTextureHeader headerIn, IntPtr data)
321  {
322  texture = pvrttCreateTextureFromHeader(headerIn.header, data);
323  }
324 
325  public bool Save(string filePath)
326  {
327  return pvrttSaveFile(texture, filePath);
328  }
329 
330  public PVRTextureHeader GetHeader()
331  {
332  return new PVRTextureHeader(pvrttGetHeader(texture));
333  }
334 
335  public IntPtr GetDataPtr(uint uiMIPLevel = 0, uint uiArrayMember = 0, uint uiFaceNumber = 0) {
336  return pvrttGetDataPtr(texture, uiMIPLevel, uiArrayMember, uiFaceNumber);
337  }
338 
339  public bool GenerateMIPMaps(EResizeMode eFilterMode, int uiMIPMapsToDo = ALLMIPLEVELS)
340  {
341  return pvrttGenerateMIPMaps(texture, eFilterMode, uiMIPMapsToDo);
342  }
343 
344 
345  public void Dispose()
346  {
347  pvrttDestroyTexture(texture);
348  }
349  }
350  #endregion
351 
352  #region public class PvrttTextureHeader
353  /// <summary>
354  /// Binding class of PVR Texture class PVRTextureHeader.
355  /// </summary>
356  internal class PVRTextureHeader : IDisposable
357  {
358  public IntPtr header { internal set; get; }
359 
360  #region Bindings
361  [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
362  private extern static IntPtr pvrttCreateTextureHeaderEmpty();
363 
364  [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
365  private extern static IntPtr pvrttCreateTextureHeader(PixelType pixelFormat, int height, int width, int depth, int numMipMaps, int numArrayMembers, int numFaces, EPVRTColourSpace eColourSpace, EPVRTVariableType eChannelType, bool bPreMultiplied);
366 
367  [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
368  private extern static IntPtr pvrttCreateTextureHeaderFromCompressedTexture(UInt64 pixelFormat, int height, int width, int depth, int numMipMaps, int numArrayMembers, int numFaces, EPVRTColourSpace eColourSpace, EPVRTVariableType eChannelType, bool bPreMultiplied);
369 
370  [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
371  private extern static IntPtr pvrttCopyTextureHeader(IntPtr headerIn);
372 
373  [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
374  private extern static UInt32 pvrttGetWidth(IntPtr header, uint uiMipLevel);
375 
376  [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
377  private extern static UInt32 pvrttGetHeight(IntPtr header, uint uiMipLevel);
378 
379  [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
380  private extern static UInt32 pvrttGetNumMIPLevels(IntPtr header);
381 
382  [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
383  private extern static void pvrttSetNumMIPLevels(IntPtr header, int newMipsLevels);
384 
385  [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
386  private extern static void pvrttSetWidth(IntPtr header, uint newWidth);
387 
388  [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
389  private extern static void pvrttSetHeight(IntPtr header, uint newHeight);
390 
391  [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
392  private extern static void pvrttSetPixelFormat(IntPtr header, PixelType pixelType);
393 
394  [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
395  private extern static uint pvrttGetDataSize(IntPtr header, int iMipLevel, bool bAllSurfaces, bool bAllFaces);
396 
397  [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
398  private extern static uint pvrttGetTextureSize(IntPtr header, int iMipLevel, bool bAllSurfaces, bool bAllFaces);
399 
400  [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
401  private extern static uint pvrttGetDepth(IntPtr header, uint uiMipLevel);
402 
403  [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
404  private extern static uint pvrttGetBPP(IntPtr header);
405 
406  [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
407  private extern static uint pvrttGetNumArrayMembers(IntPtr header);
408 
409  [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
410  private extern static uint pvrttGetNumFaces(IntPtr header);
411 
412  [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
413  private extern static bool pvrttIsFileCompressed(IntPtr header);
414 
415  [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
416  private extern static UInt64 pvrttGetPixelType(IntPtr header);
417 
418  [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
419  private extern static UInt32 pvrttGetMetaDataSize(IntPtr header);
420 
421  [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
422  private extern static EPVRTVariableType pvrttGetChannelType(IntPtr header);
423 
424  [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
425  private extern static EPVRTColourSpace pvrttGetColourSpace(IntPtr header);
426 
427  #endregion
428 
429 
430  public PVRTextureHeader()
431  {
433  }
434 
435  public PVRTextureHeader(PixelType pixelFormat, int height=1, int width=1, int depth=1, int numMipMaps=1, int numArrayMembers=1, int numFaces=1, EPVRTColourSpace eColourSpace=EPVRTColourSpace.ePVRTCSpacelRGB, EPVRTVariableType eChannelType=EPVRTVariableType.ePVRTVarTypeUnsignedByteNorm, bool bPreMultiplied=false)
436  {
437  header = pvrttCreateTextureHeader(pixelFormat, height, width, depth, numMipMaps, numArrayMembers, numFaces, eColourSpace, eChannelType, bPreMultiplied);
438  }
439 
440  public PVRTextureHeader(UInt64 pixelFormat, int height=1, int width=1, int depth=1, int numMipMaps=1, int numArrayMembers=1, int numFaces=1, EPVRTColourSpace eColourSpace=EPVRTColourSpace.ePVRTCSpacelRGB, EPVRTVariableType eChannelType=EPVRTVariableType.ePVRTVarTypeUnsignedByteNorm, bool bPreMultiplied=false)
441  {
442  header = pvrttCreateTextureHeaderFromCompressedTexture(pixelFormat, height, width, depth, numMipMaps, numArrayMembers, numFaces, eColourSpace, eChannelType, bPreMultiplied);
443  }
444 
445  public PVRTextureHeader(IntPtr headerPtr)
446  {
447  header = headerPtr;
448  }
449 
450  public PVRTextureHeader Copy()
451  {
452  return new PVRTextureHeader(pvrttCopyTextureHeader(header));
453  }
454 
455  public uint GetWidth(uint uiMipLevel = Constant.TOPMIPLEVEL)
456  {
457  return pvrttGetWidth(header, uiMipLevel);
458  }
459 
460  public uint GetHeight(uint uiMipLevel = Constant.TOPMIPLEVEL)
461  {
462  return pvrttGetHeight(header, uiMipLevel);
463  }
464 
465  public uint GetNumMIPLevels()
466  {
467  return pvrttGetNumMIPLevels(header);
468  }
469 
470  public void SetNumMIPLevels(int newMipsLevels)
471  {
472  pvrttSetNumMIPLevels(header, newMipsLevels);
473  }
474 
475  public void SetPixelFormat(PixelType pixelType)
476  {
477  pvrttSetPixelFormat(header, pixelType);
478  }
479 
480  public void SetWidth(uint newWidth)
481  {
482  pvrttSetWidth(header, newWidth);
483  }
484 
485  public void SetHeight(uint newHeight)
486  {
487  pvrttSetHeight(header, newHeight);
488  }
489 
490  public uint GetDataSize(int iMipLevel = Constant.ALLMIPLEVELS, bool bAllSurfaces = true, bool bAllFaces = true)
491  {
492  return pvrttGetDataSize(header, iMipLevel, bAllSurfaces, bAllFaces);
493  }
494 
495  public uint GetTextureSize(int iMipLevel = Constant.ALLMIPLEVELS, bool bAllSurfaces = true, bool bAllFaces = true)
496  {
497  return pvrttGetTextureSize(header, iMipLevel, bAllSurfaces, bAllFaces);
498  }
499 
500  public uint GetDepth(uint uiMipLevel = Constant.TOPMIPLEVEL)
501  {
502  return pvrttGetDepth(header, uiMipLevel);
503  }
504 
505  public uint GetBPP()
506  {
507  return pvrttGetBPP(header);
508  }
509 
510  public uint GetNumArrayMembers()
511  {
512  return pvrttGetNumArrayMembers(header);
513  }
514 
515 
516  public uint GetNumFaces()
517  {
518  return pvrttGetNumFaces(header);
519  }
520 
521  public uint GetMetaDataSize()
522  {
523  return pvrttGetMetaDataSize(header);
524  }
525 
526  public EPVRTVariableType GetChannelType()
527  {
528  return pvrttGetChannelType(header);
529  }
530 
531  public UInt64 GetPixelType()
532  {
533  return pvrttGetPixelType(header);
534  }
535 
536  public EPVRTColourSpace GetColourSpace()
537  {
538  return pvrttGetColourSpace(header);
539  }
540 
542  {
543  UInt64 format = pvrttGetPixelType(header);
544 
545  switch (format)
546  {
547  case 0:
548  return SiliconStudio.Paradox.Graphics.PixelFormat.PVRTC_2bpp_RGB;
549  case 1:
550  return SiliconStudio.Paradox.Graphics.PixelFormat.PVRTC_2bpp_RGBA;
551  case 2:
552  return SiliconStudio.Paradox.Graphics.PixelFormat.PVRTC_4bpp_RGB;
553  case 3:
554  return SiliconStudio.Paradox.Graphics.PixelFormat.PVRTC_4bpp_RGBA;
555  case 4:
556  return SiliconStudio.Paradox.Graphics.PixelFormat.PVRTC_II_2bpp;
557  case 5:
558  return SiliconStudio.Paradox.Graphics.PixelFormat.PVRTC_II_4bpp;
559  case 6:
560  return SiliconStudio.Paradox.Graphics.PixelFormat.ETC1;
561  case 22:
562  return SiliconStudio.Paradox.Graphics.PixelFormat.ETC2_RGB;
563  case 23:
564  return SiliconStudio.Paradox.Graphics.PixelFormat.ETC2_RGBA;
565  case 24:
566  return SiliconStudio.Paradox.Graphics.PixelFormat.ETC2_RGB_A1;
567  case 25:
568  return SiliconStudio.Paradox.Graphics.PixelFormat.EAC_R11_Unsigned;
569  case 26:
570  return SiliconStudio.Paradox.Graphics.PixelFormat.EAC_R11_Signed;
571  case 27:
572  return SiliconStudio.Paradox.Graphics.PixelFormat.EAC_RG11_Unsigned;
573  case 28:
574  return SiliconStudio.Paradox.Graphics.PixelFormat.EAC_RG11_Signed;
575  /*default:
576  throw new TexLibraryException("Unknown format by PowerVC Texture Tool.");*/
577  }
578 
579  if (format == Utilities.ConvertPixelType(PixelType.Standard8PixelType))
580  return SiliconStudio.Paradox.Graphics.PixelFormat.R8G8B8A8_UNorm;
581  else if (format == Utilities.ConvertPixelType(PixelType.Standard16PixelType))
582  return SiliconStudio.Paradox.Graphics.PixelFormat.R16G16B16A16_UNorm;
583  else if (format == Utilities.ConvertPixelType(PixelType.Standard32PixelType))
584  return SiliconStudio.Paradox.Graphics.PixelFormat.R32G32B32A32_Float;
585  else
586  throw new TextureToolsException("Unknown format by PowerVC Texture Tool.");
587  }
588 
589 
590  public void Dispose()
591  {
592  }
593  }
594  #endregion
595 
596 }
bool pvrttPreMultipliedAlpha(PvrttTexture &sTexture)
pvrtexture::uint64 pvrttGetPixelType(PvrttTextureHeader *header)
pvrtexture::uint64 pvrttConvertPixelType(PvrttPixelType pixelFormat)
bool pvrttTranscode(PvrttTexture &texture, pvrtexture::uint64 ptFormat, const EPVRTVariableType eChannelType, const EPVRTColourSpace eColourspace, const pvrtexture::ECompressorQuality eQuality, const bool bDoDither)
void * pvrttGetDataPtr(PvrttTexture *texture, pvrtexture::uint32 uiMIPLevel=0, pvrtexture::uint32 uiArrayMember=0, pvrtexture::uint32 uiFaceNumber=0)
pvrtexture::uint32 pvrttGetNumFaces(PvrttTextureHeader *header)
HRESULT Resize(_In_ const Image &srcImage, _In_ size_t width, _In_ size_t height, _In_ DWORD filter, _Out_ ScratchImage &image)
EPVRTVariableType pvrttGetChannelType(PvrttTextureHeader *header)
bool pvrttGenerateMIPMaps(PvrttTexture &texture, const pvrtexture::EResizeMode eFilterMode, int uiMIPMapsToDo=PVRTEX_ALLMIPLEVELS)
PvrttTextureHeader * pvrttCreateTextureHeaderEmpty()
bool pvrttFlip(PvrttTexture &sTexture, const EPVRTAxis eFlipDirection)
Interpolates by using constant value between keyframes.
_In_ size_t _In_ DXGI_FORMAT _In_ size_t _In_ float size_t y
Definition: DirectXTexP.h:191
bool pvrttCopyChannels(PvrttTexture &sTexture, const PvrttTexture &sTextureSource, pvrtexture::uint32 uiNumChannelCopies, pvrtexture::EChannelName *eChannels, pvrtexture::EChannelName *eChannelsSource)
void pvrttSetNumMIPLevels(PvrttTextureHeader *header, int newNumMIPLevels)
pvrtexture::uint32 pvrttGetNumMIPLevels(PvrttTextureHeader *header)
bool pvrttGenerateNormalMap(PvrttTexture &sTexture, const float fScale, const char *sChannelOrder)
bool pvrttResize(PvrttTexture &sTexture, const pvrtexture::uint32 &u32NewWidth, const pvrtexture::uint32 &u32NewHeight, const pvrtexture::uint32 &u32NewDepth, const pvrtexture::EResizeMode eResizeMode)
PvrttTexture * pvrttCreateTextureFromHeader(PvrttTextureHeader *sHeader, const void *pData=NULL)
pvrtexture::uint32 pvrttGetDataSize(PvrttTextureHeader *header, int iMipLevel=PVRTEX_ALLMIPLEVELS, bool bAllSurfaces=true, bool bAllFaces=true)
void pvrttSetHeight(PvrttTextureHeader *header, pvrtexture::uint32 newHeight)
PvrttTexture * pvrttCreateTextureFromFile(const char *szFilePath)
const PvrttTextureHeader * pvrttGetHeader(PvrttTexture *texture)
pvrtexture::uint32 pvrttGetHeight(PvrttTextureHeader *header, pvrtexture::uint32 uiMipLevel=PVRTEX_TOPMIPLEVEL)
SiliconStudio.Core.Utilities Utilities
Definition: Texture.cs:29
PvrttTexture * pvrttCreateTexture()
EPVRTColourSpace pvrttGetColourSpace(PvrttTextureHeader *header)
pvrtexture::uint32 pvrttGetBPP(PvrttTextureHeader *header)
void pvrttSetWidth(PvrttTextureHeader *header, pvrtexture::uint32 newWidth)
void pvrttSetPixelFormat(PvrttTextureHeader *header, PvrttPixelType pixelFormat)
void pvrttDestroyTexture(PvrttTexture *texture)
bool pvrttSaveFile(PvrttTexture *texture, const char *filePath)
_In_ size_t _In_ size_t _In_ DXGI_FORMAT format
Definition: DirectXTexP.h:175
pvrtexture::uint32 pvrttGetNumArrayMembers(PvrttTextureHeader *header)
pvrtexture::uint32 pvrttGetWidth(PvrttTextureHeader *header, pvrtexture::uint32 uiMipLevel=PVRTEX_TOPMIPLEVEL)
bool pvrttIsFileCompressed(PvrttTextureHeader *header)
PvrttTextureHeader * pvrttCopyTextureHeader(const PvrttTextureHeader *headerIn)
PvrttTextureHeader * pvrttCreateTextureHeaderFromCompressedTexture(pvrtexture::uint64 pixelFormat, int height=1, int width=1, int depth=1, int numMipMaps=1, int numArrayMembers=1, int numFaces=1, EPVRTColourSpace eColourSpace=ePVRTCSpacelRGB, EPVRTVariableType eChannelType=ePVRTVarTypeUnsignedByteNorm, bool bPreMultiplied=false)
PixelFormat
Defines various types of pixel formats.
Definition: PixelFormat.cs:32
bool pvrttTranscodeWithNoConversion(PvrttTexture &texture, const PvrttPixelType ptFormat, const EPVRTVariableType eChannelType, const EPVRTColourSpace eColourspace, const pvrtexture::ECompressorQuality eQuality=pvrtexture::ePVRTCNormal, const bool bDoDither=false)
pvrtexture::uint32 pvrttGetDepth(PvrttTextureHeader *header, pvrtexture::uint32 uiMipLevel=PVRTEX_TOPMIPLEVEL)
PvrttTexture * pvrttCreateTextureFromMemory(const void *pTexture)
pvrtexture::uint32 pvrttGetTextureSize(PvrttTextureHeader *header, int iMipLevel, bool bAllSurfaces, bool bAllFaces)
PvrttTextureHeader * pvrttCreateTextureHeader(PvrttPixelType pixelFormat, int height=1, int width=1, int depth=1, int numMipMaps=1, int numArrayMembers=1, int numFaces=1, EPVRTColourSpace eColourSpace=ePVRTCSpacelRGB, EPVRTVariableType eChannelType=ePVRTVarTypeUnsignedByteNorm, bool bPreMultiplied=false)
pvrtexture::uint32 pvrttGetMetaDataSize(PvrttTextureHeader *header)