public DxtImage[] GetImages() { IntPtr imagesPtr = dxtGetImages(ptr); int imagenb = imageCount; DxtImage[] dxtImages = new DxtImage[imagenb]; for (int i = 0; i < imagenb; ++i) { dxtImages[i] = (DxtImage)Marshal.PtrToStructure(imagesPtr + i * Marshal.SizeOf(dxtImages[0]), typeof(DxtImage)); } return(dxtImages); }
public static HRESULT GenerateMipMaps(ref DxtImage baseImage, TEX_FILTER_FLAGS filter, int levels, ScratchImage mipChain, bool allow1D = false) { return HandleHRESULT(dxtGenerateMipMaps(ref baseImage, filter, levels, mipChain.ptr, allow1D)); }
public static HRESULT Decompress(ref DxtImage cImage, DXGI_FORMAT format, ScratchImage image) { return HandleHRESULT(dxtDecompress(ref cImage, format, image.ptr)); }
public static HRESULT Compress(ref DxtImage srcImage, DXGI_FORMAT format, TEX_COMPRESS_FLAGS compress, float alphaRef, ScratchImage cImage) { return HandleHRESULT(dxtCompress(ref srcImage, format, compress, alphaRef, cImage.ptr)); }
public static HRESULT Convert(ref DxtImage srcImage, DXGI_FORMAT format, TEX_FILTER_FLAGS filter, float threshold, ScratchImage cImage) { return HandleHRESULT(dxtConvert(ref srcImage, format, filter, threshold, cImage.ptr)); }
public DxtImage[] GetImages() { IntPtr imagesPtr = dxtGetImages(ptr); int imagenb = imageCount; DxtImage[] dxtImages = new DxtImage[imagenb]; for(int i=0;i<imagenb;++i) { dxtImages[i] = (DxtImage)Marshal.PtrToStructure(imagesPtr + i * Marshal.SizeOf(dxtImages[0]), typeof(DxtImage)); } return dxtImages; }
public HRESULT InitializeFromImage(out DxtImage srcImage, bool allow1D = false) { return Utilities.HandleHRESULT(dxtInitializeFromImage(ptr, out srcImage, allow1D)); }
private extern static uint dxtInitializeFromImage(IntPtr img, out DxtImage srcImage, bool allow1D);
public static HRESULT Convert(ref DxtImage srcImage, DXGI_FORMAT format, TEX_FILTER_FLAGS filter, float threshold, ScratchImage cImage) { return(HandleHRESULT(dxtConvert(ref srcImage, format, filter, threshold, cImage.ptr))); }
public static HRESULT SaveToDDSFile(ref DxtImage dxtImage, DDS_FLAGS flags, string szFile) { return(HandleHRESULT(dxtSaveToDDSFile(ref dxtImage, flags, szFile))); }
private extern static uint dxtGenerateMipMaps3D(ref DxtImage baseImage, int depth, TEX_FILTER_FLAGS filter, int levels, IntPtr mipChain);
private extern static uint dxtGenerateMipMaps(ref DxtImage baseImage, TEX_FILTER_FLAGS filter, int levels, IntPtr mipChain, bool allow1D);
private extern static uint dxtSaveToDDSFile(ref DxtImage dxtImage, DDS_FLAGS flags, string szFile);
private extern static uint dxtDecompress(ref DxtImage cImage, DXGI_FORMAT format, IntPtr image);
public static HRESULT GenerateMipMaps3D(DxtImage[] srcImages, int nimages, ref TexMetadata metadata, TEX_FILTER_FLAGS filter, int levels, ScratchImage mipChain) { return HandleHRESULT(dxtGenerateMipMaps3DArray(srcImages, nimages, ref metadata, filter, levels, mipChain.ptr)); }
public static HRESULT ComputeNormalMap(DxtImage[] srcImages, int nimages, ref TexMetadata metadata, CNMAP_FLAGS flags, float amplitude, DXGI_FORMAT format, ScratchImage normalMaps) { return HandleHRESULT(dxtComputeNormalMap(srcImages, nimages, ref metadata, flags, amplitude, format, normalMaps.ptr)); }
public static HRESULT Compress(ref DxtImage srcImage, DXGI_FORMAT format, TEX_COMPRESS_FLAGS compress, float alphaRef, ScratchImage cImage) { return(HandleHRESULT(dxtCompress(ref srcImage, format, compress, alphaRef, cImage.ptr))); }
private extern static uint dxtInitializeCubeFromImages(IntPtr img, DxtImage[] dxtImages, int nImages);
public static HRESULT Decompress(ref DxtImage cImage, DXGI_FORMAT format, ScratchImage image) { return(HandleHRESULT(dxtDecompress(ref cImage, format, image.ptr))); }
public HRESULT InitializeCubeFromImages(DxtImage[] dxtImages, int nImages) { return Utilities.HandleHRESULT(dxtInitializeCubeFromImages(ptr, dxtImages, nImages)); }
public static HRESULT GenerateMipMaps(ref DxtImage baseImage, TEX_FILTER_FLAGS filter, int levels, ScratchImage mipChain, bool allow1D = false) { return(HandleHRESULT(dxtGenerateMipMaps(ref baseImage, filter, levels, mipChain.ptr, allow1D))); }
private extern static uint dxtCompress(ref DxtImage srcImage, DXGI_FORMAT format, TEX_COMPRESS_FLAGS compress, float alphaRef, IntPtr cImage);
public static HRESULT GenerateMipMaps3D(ref DxtImage baseImage, int depth, TEX_FILTER_FLAGS filter, int levels, ScratchImage mipChain) { return(HandleHRESULT(dxtGenerateMipMaps3D(ref baseImage, depth, filter, levels, mipChain.ptr))); }
public static HRESULT Convert(DxtImage[] srcImages, int nimages, ref TexMetadata metadata, DXGI_FORMAT format, TEX_FILTER_FLAGS filter, float threshold, ScratchImage cImages) { return HandleHRESULT(dxtConvertArray(srcImages, nimages, ref metadata, format, filter, threshold, cImages.ptr)); }
public static HRESULT Compress(DxtImage[] srcImages, int nimages, ref TexMetadata metadata, DXGI_FORMAT format, TEX_COMPRESS_FLAGS compress, float alphaRef, ScratchImage cImages) { return HandleHRESULT(dxtCompressArray(srcImages, nimages, ref metadata, format, compress, alphaRef, cImages.ptr)); }
public HRESULT InitializeFromImage(out DxtImage srcImage, bool allow1D = false) { return(Utilities.HandleHRESULT(dxtInitializeFromImage(ptr, out srcImage, allow1D))); }
public static HRESULT Decompress(DxtImage[] cImages, int nimages, ref TexMetadata metadata, DXGI_FORMAT format, ScratchImage images) { return HandleHRESULT(dxtDecompressArray(cImages, nimages, ref metadata, format, images.ptr)); }
public static HRESULT GenerateMipMaps3D(ref DxtImage baseImage, int depth, TEX_FILTER_FLAGS filter, int levels, ScratchImage mipChain) { return HandleHRESULT(dxtGenerateMipMaps3D(ref baseImage, depth, filter, levels, mipChain.ptr)); }
public static HRESULT Resize(DxtImage[] srcImages, int nimages, ref TexMetadata metadata, int width, int height, TEX_FILTER_FLAGS filter, ScratchImage result) { return HandleHRESULT(dxtResize(srcImages, nimages, ref metadata, width, height, filter, result.ptr)); }
private extern static uint dxtGenerateMipMaps3DArray(DxtImage[] srcImages, int nimages, ref TexMetadata metadata, TEX_FILTER_FLAGS filter, int levels, IntPtr mipChain );
public static HRESULT PremultiplyAlpha(DxtImage[] srcImages, int nimages, ref TexMetadata metadata, TEX_PREMULTIPLY_ALPHA_FLAGS flags, ScratchImage result) { return HandleHRESULT(dxtPremultiplyAlpha(srcImages, nimages, ref metadata, flags, result.ptr)); }
private extern static uint dxtResize(DxtImage[] srcImages, int nimages, ref TexMetadata metadata, int width, int height, TEX_FILTER_FLAGS filter, IntPtr result);
private extern static uint dxtInitializeArrayFromImages(IntPtr img, DxtImage[] dxtImages, int nImages, bool allow1D );
private extern static uint dxtComputeNormalMap(DxtImage[] srcImages, int nimages, ref TexMetadata metadata, CNMAP_FLAGS flags, float amplitude, DXGI_FORMAT format, IntPtr normalMaps );
private extern static uint dxtInitialize3DFromImages(IntPtr img, DxtImage[] dxtImages, int depth);
private extern static uint dxtPremultiplyAlpha(DxtImage[] srcImages, int nimages, ref TexMetadata metadata, TEX_PREMULTIPLY_ALPHA_FLAGS flags, IntPtr result);
public HRESULT InitializeFromImages(DxtImage[] dxtImages, int nImages, bool allow1D = false) { return Utilities.HandleHRESULT(dxtInitializeArrayFromImages(ptr, dxtImages, nImages, allow1D)); }
public static HRESULT SaveToDDSFile(ref DxtImage dxtImage, DDS_FLAGS flags, string szFile) { return HandleHRESULT(dxtSaveToDDSFile(ref dxtImage, flags, szFile)); }
public HRESULT Initialize3DFromImages(DxtImage[] dxtImages, int depth) { return Utilities.HandleHRESULT(dxtInitialize3DFromImages(ptr, dxtImages, depth)); }
public static HRESULT SaveToDDSFile(DxtImage[] dxtImages, int nimages, ref TexMetadata metadata, DDS_FLAGS flags, string szFile) { return HandleHRESULT(dxtSaveToDDSFileArray(dxtImages, nimages, ref metadata, flags, szFile)); }
/// <summary> /// Exports the specified image. /// </summary> /// <param name="image">The image.</param> /// <param name="libraryData">The library data.</param> /// <param name="request">The request.</param> /// <exception cref="TexLibraryException"> /// Exporting texture failed /// </exception> private void Export(TexImage image, DxtTextureLibraryData libraryData, ExportRequest request) { Log.Info("Exporting to " + request.FilePath + " ..."); if (request.MinimumMipMapSize > 1 && request.MinimumMipMapSize <= libraryData.Metadata.Width && request.MinimumMipMapSize <= libraryData.Metadata.Height) // if a mimimun mipmap size was requested { TexMetadata metadata = libraryData.Metadata; DxtImage[] dxtImages; if (image.Dimension == TexImage.TextureDimension.Texture3D) { int newMipMapCount = 0; // the new mipmap count int ct = 0; // ct will contain the number of SubImages per array element that we need to keep int curDepth = image.Depth << 1; for (int i = 0; i < image.MipmapCount; ++i) { curDepth = curDepth > 1 ? curDepth >>= 1 : curDepth; if (libraryData.DxtImages[ct].Width <= request.MinimumMipMapSize || libraryData.DxtImages[ct].Height <= request.MinimumMipMapSize) { ct += curDepth; ++newMipMapCount; break; } ++newMipMapCount; ct += curDepth; } int SubImagePerArrayElement = image.SubImageArray.Length / image.ArraySize; // number of SubImage in each texture array element. // Initializing library native data according to the new mipmap level metadata.MipLevels = newMipMapCount; dxtImages = new DxtImage[metadata.ArraySize * ct]; int ct2 = 0; for (int i = 0; i < image.ArraySize; ++i) { for (int j = 0; j < ct; ++j) { dxtImages[ct2] = libraryData.DxtImages[j + i * SubImagePerArrayElement]; ++ct2; } } } else { int newMipMapCount = libraryData.Metadata.MipLevels; for (int i = libraryData.Metadata.MipLevels - 1; i > 0; --i) // looking for the mipmap level corresponding to the minimum size requeted. { if (libraryData.DxtImages[i].Width >= request.MinimumMipMapSize || libraryData.DxtImages[i].Height >= request.MinimumMipMapSize) { break; } --newMipMapCount; } // Initializing library native data according to the new mipmap level metadata.MipLevels = newMipMapCount; dxtImages = new DxtImage[metadata.ArraySize * newMipMapCount]; // Assigning the right sub images for the texture to be exported (no need for memory to be adjacent) int gap = libraryData.Metadata.MipLevels - newMipMapCount; int j = 0; for (int i = 0; i < dxtImages.Length; ++i) { if (i == newMipMapCount || (i > newMipMapCount && i%newMipMapCount == 0)) j += gap; dxtImages[i] = libraryData.DxtImages[j]; ++j; } } HRESULT hr = Utilities.SaveToDDSFile(dxtImages, dxtImages.Length, ref metadata, DDS_FLAGS.DDS_FLAGS_NONE, request.FilePath); if (hr != HRESULT.S_OK) { Log.Error("Exporting texture failed: " + hr); throw new TextureToolsException("Exporting texture failed: " + hr); } } else { HRESULT hr = Utilities.SaveToDDSFile(libraryData.DxtImages, libraryData.DxtImages.Length, ref libraryData.Metadata, DDS_FLAGS.DDS_FLAGS_NONE, request.FilePath); if (hr != HRESULT.S_OK) { Log.Error("Exporting texture failed: " + hr); throw new TextureToolsException("Exporting texture failed: " + hr); } } image.Save(request.FilePath); }
private extern static uint dxtConvert(ref DxtImage srcImage, DXGI_FORMAT format, TEX_FILTER_FLAGS filter, float threshold, IntPtr cImage);