ArcGIS Pro 3.3 API Reference Guide
ArcGIS.Core.Geometry Namespace / Multipatch Class / GetMaterialTextureCompressionType Method
The index of the material. Must be greater than or equal to zero and less than MaterialCount. Get the index for a patch by calling GetPatchMaterialIndex.
Example

In This Topic
    GetMaterialTextureCompressionType Method
    In This Topic
    Gets the compression type of the byte buffer for the texture of the specified material.
    Syntax
    public TextureCompressionType GetMaterialTextureCompressionType( 
       int materialIndex
    )
    Public Function GetMaterialTextureCompressionType( _
       ByVal materialIndex As Integer _
    ) As TextureCompressionType

    Parameters

    materialIndex
    The index of the material. Must be greater than or equal to zero and less than MaterialCount. Get the index for a patch by calling GetPatchMaterialIndex.

    Return Value

    The TextureCompressionType of the byte buffer that is returned from GetMaterialTexture.
    Exceptions
    ExceptionDescription
    The material index must be >= 0.
    The material index must be less than the number of materials in the multipatch.
    Remarks
    If the compression type is TextureCompressionType.CompressionJPEG the buffer is a JPEG image. If the compression type is TextureCompressionType.CompressionNone the buffer is a pointer to a raw buffer containing image pixels starting from the top left corner in the row major order. The pixel size depends on the GetMaterialTextureBytesPerPixel value.
    Example
    Multipatch Properties
    // standard geometry properties
    bool hasZ = multipatch.HasZ;
    bool hasM = multipatch.HasM;
    bool hasID = multipatch.HasID;
    bool isEmpty = multipatch.IsEmpty;
    var sr = multipatch.SpatialReference;
    
    // number of patches (parts)
    int patchCount = multiPatch.PartCount;
    // number of points
    int pointCount = multiPatch.PointCount;
    
    // retrieve the points as MapPoints
    ReadOnlyPointCollection points = multipatch.Points;
    // or as 3D Coordinates
    IReadOnlyList<Coordinate3D> coordinates = multipatch.Copy3DCoordinatesToList();
    
    
    // multipatch materials
    bool hasMaterials = multiPatch.HasMaterials;
    int materialCount = multiPatch.MaterialCount;
    
    
    // multipatch textures
    bool hasTextures = multiPatch.HasTextures;
    int textureVertexCount = multiPatch.TextureVertexCount;
    
    // normals
    bool hasNormals = multiPatch.HasNormals;
    
    
    // properties for an individual patch (if multipatch.PartCount > 0)
    int patchPriority = multiPatch.GetPatchPriority(patchIndex);
    PatchType patchType = multiPatch.GetPatchType(patchIndex);
    
    // patch points
    int patchPointCount = multiPatch.GetPatchPointCount(patchIndex);
    int pointStartIndex = multiPatch.GetPatchStartPointIndex(patchIndex);
    // the patch Points are then the points in multipatch.Points from pointStartIndex to pointStartIndex + patchPointCount 
    
    // if the multipatch has materials 
    if (hasMaterials)
    {
      // does the patch have a material?  
      //   materialIndex = -1 if the patch does not have a material; 
      //   0 <= materialIndex < materialCount if the patch does have materials
      int materialIndex = multipatch.GetPatchMaterialIndex(patchIndex);
    
    
      // properties for an individual material (if multipatch.MaterialCount > 0)
      var color = multipatch.GetMaterialColor(materialIndex);
      var edgeColor = multipatch.GetMaterialEdgeColor(materialIndex);
      var edgeWidth = multipatch.GetMaterialEdgeWidth(materialIndex);
      var shiness = multipatch.GetMaterialShininess(materialIndex);
      var percent = multipatch.GetMaterialTransparencyPercent(materialIndex);
      var cullBackFace = multipatch.IsMaterialCullBackFace(materialIndex);
    
      // texture properties
      bool isTextured = multipatch.IsMaterialTextured(materialIndex);
      if (isTextured)
      {
        int columnCount = multipatch.GetMaterialTextureColumnCount(materialIndex);
        int rowCount = multipatch.GetMaterialTextureRowCount(materialIndex);
        int bpp = multipatch.GetMaterialTextureBytesPerPixel(materialIndex);
        TextureCompressionType compressionType = multipatch.GetMaterialTextureCompressionType(materialIndex);
        var texture = multipatch.GetMaterialTexture(materialIndex);
      }
    }
    
    // texture coordinates (if multipatch.HasTextures = true)
    if (hasTextures)
    {
      int numPatchTexturePoints = multiPatch.GetPatchTextureVertexCount(patchIndex);
      var coordinate2D = multiPatch.GetPatchTextureCoordinate(patchIndex, 0);
    
      ICollection<Coordinate2D> textureCoordinates = new List<Coordinate2D>(numPatchTexturePoints);
      multiPatch.GetPatchTextureCoordinates(patchIndex, ref textureCoordinates);
    }
    
    
    // patch normals (if multipatch.HasNormals = true)
    if (hasNormals)
    {
      //  number of normal coordinates = multipatch.GetPatchPointCount(patchIndex)
      Coordinate3D patchNormal = multipatch.GetPatchNormal(patchIndex, 0);
      ICollection<Coordinate3D> normalCoordinates = new List<Coordinate3D>(patchPointCount);
      multipatch.GetPatchNormals(patchIndex, ref normalCoordinates);
    }
    
    
    Get the texture image of a multipatch
    // <summary>
    // This method gets the material texture image of a multipatch.
    // </summary>
    // <param name="multipatch">The input multipatch.</param>
    // <param name="patchIndex">The index of the patch (part) for which to get the material texture.</param>
    public void GetMultipatchTextureImage(Multipatch multipatch, int patchIndex)
    {
      int materialIndex = multipatch.GetPatchMaterialIndex(patchIndex);
      if (!multipatch.IsMaterialTextured(materialIndex))
        return;
    
      TextureCompressionType compressionType = 
        multipatch.GetMaterialTextureCompressionType(materialIndex);
    
      string ext = compressionType == TextureCompressionType.CompressionJPEG ? ".jpg" : ".dat";
      byte[] textureBuffer = multipatch.GetMaterialTexture(materialIndex);
    
      Stream imageStream = new MemoryStream(textureBuffer);
      System.Drawing.Image image = System.Drawing.Image.FromStream(imageStream);
      image.Save(@"C:\temp\myImage" + ext);
    }
    
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also