Exemple #1
0
        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);
        }
Exemple #2
0
 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));
 }
Exemple #3
0
 public static HRESULT Decompress(ref DxtImage cImage, DXGI_FORMAT format, ScratchImage image)
 {
     return HandleHRESULT(dxtDecompress(ref cImage, format, image.ptr));
 }
Exemple #4
0
 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));
 }
Exemple #5
0
 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));
 }
Exemple #6
0
        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;
        }
Exemple #7
0
 public HRESULT InitializeFromImage(out DxtImage srcImage, bool allow1D = false)
 {
     return Utilities.HandleHRESULT(dxtInitializeFromImage(ptr, out srcImage, allow1D));
 }
Exemple #8
0
 private extern static uint dxtInitializeFromImage(IntPtr img, out DxtImage srcImage, bool allow1D);
Exemple #9
0
 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)));
 }
Exemple #10
0
 public static HRESULT SaveToDDSFile(ref DxtImage dxtImage, DDS_FLAGS flags, string szFile)
 {
     return(HandleHRESULT(dxtSaveToDDSFile(ref dxtImage, flags, szFile)));
 }
Exemple #11
0
 private extern static uint dxtGenerateMipMaps3D(ref DxtImage baseImage, int depth, TEX_FILTER_FLAGS filter, int levels, IntPtr mipChain);
Exemple #12
0
 private extern static uint dxtGenerateMipMaps(ref DxtImage baseImage, TEX_FILTER_FLAGS filter, int levels, IntPtr mipChain, bool allow1D);
Exemple #13
0
 private extern static uint dxtSaveToDDSFile(ref DxtImage dxtImage, DDS_FLAGS flags, string szFile);
Exemple #14
0
 private extern static uint dxtDecompress(ref DxtImage cImage, DXGI_FORMAT format, IntPtr image);
Exemple #15
0
 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));
 }
Exemple #16
0
 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));
 }
Exemple #17
0
 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)));
 }
Exemple #18
0
 private extern static uint dxtInitializeCubeFromImages(IntPtr img, DxtImage[] dxtImages, int nImages);
Exemple #19
0
 public static HRESULT Decompress(ref DxtImage cImage, DXGI_FORMAT format, ScratchImage image)
 {
     return(HandleHRESULT(dxtDecompress(ref cImage, format, image.ptr)));
 }
Exemple #20
0
 public HRESULT InitializeCubeFromImages(DxtImage[] dxtImages, int nImages)
 {
     return Utilities.HandleHRESULT(dxtInitializeCubeFromImages(ptr, dxtImages, nImages));
 }
Exemple #21
0
 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)));
 }
Exemple #22
0
 private extern static uint dxtCompress(ref DxtImage srcImage, DXGI_FORMAT format, TEX_COMPRESS_FLAGS compress, float alphaRef, IntPtr cImage);
Exemple #23
0
 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)));
 }
Exemple #24
0
 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));
 }
Exemple #25
0
 private extern static uint dxtInitializeFromImage(IntPtr img, out DxtImage srcImage, bool allow1D);
Exemple #26
0
 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));
 }
Exemple #27
0
 public HRESULT InitializeFromImage(out DxtImage srcImage, bool allow1D = false)
 {
     return(Utilities.HandleHRESULT(dxtInitializeFromImage(ptr, out srcImage, allow1D)));
 }
Exemple #28
0
 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));
 }
Exemple #29
0
 private extern static uint dxtGenerateMipMaps(ref DxtImage baseImage, TEX_FILTER_FLAGS filter, int levels, IntPtr mipChain, bool allow1D);
Exemple #30
0
 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));
 }
Exemple #31
0
 private extern static uint dxtGenerateMipMaps3D(ref DxtImage baseImage, int depth, TEX_FILTER_FLAGS filter, int levels, IntPtr mipChain);
Exemple #32
0
 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));
 }
Exemple #33
0
 private extern static uint dxtGenerateMipMaps3DArray(DxtImage[] srcImages, int nimages, ref TexMetadata metadata, TEX_FILTER_FLAGS filter, int levels, IntPtr mipChain );
Exemple #34
0
 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));
 }
Exemple #35
0
 private extern static uint dxtResize(DxtImage[] srcImages, int nimages, ref TexMetadata metadata, int width, int height, TEX_FILTER_FLAGS filter, IntPtr result);
Exemple #36
0
 private extern static uint dxtInitializeArrayFromImages(IntPtr img, DxtImage[] dxtImages, int nImages, bool allow1D );
Exemple #37
0
 private extern static uint dxtComputeNormalMap(DxtImage[] srcImages, int nimages, ref TexMetadata metadata, CNMAP_FLAGS flags, float amplitude, DXGI_FORMAT format, IntPtr normalMaps );
Exemple #38
0
 private extern static uint dxtInitialize3DFromImages(IntPtr img, DxtImage[] dxtImages, int depth);
Exemple #39
0
 private extern static uint dxtPremultiplyAlpha(DxtImage[] srcImages, int nimages, ref TexMetadata metadata, TEX_PREMULTIPLY_ALPHA_FLAGS flags, IntPtr result);
Exemple #40
0
 public HRESULT InitializeFromImages(DxtImage[] dxtImages, int nImages, bool allow1D = false)
 {
     return Utilities.HandleHRESULT(dxtInitializeArrayFromImages(ptr, dxtImages, nImages, allow1D));
 }
Exemple #41
0
 public static HRESULT SaveToDDSFile(ref DxtImage dxtImage, DDS_FLAGS flags, string szFile)
 {
     return HandleHRESULT(dxtSaveToDDSFile(ref dxtImage, flags, szFile));
 }
Exemple #42
0
 public HRESULT Initialize3DFromImages(DxtImage[] dxtImages, int depth)
 {
     return Utilities.HandleHRESULT(dxtInitialize3DFromImages(ptr, dxtImages, depth));
 }
Exemple #43
0
 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));
 }
Exemple #44
0
        /// <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);
        }
Exemple #45
0
 private extern static uint dxtConvert(ref DxtImage srcImage, DXGI_FORMAT format, TEX_FILTER_FLAGS filter, float threshold, IntPtr cImage);