// <summary>
// This method gets the material texture image of a multipatch.
// This method must be called on the MCT. Use QueuedTask.Run.
// </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);
}