TextureProcess.DownloadTexture C# (CSharp) Méthode

DownloadTexture() public méthode

public DownloadTexture ( UUID textureID ) : void
textureID UUID
Résultat void
    public void DownloadTexture(UUID textureID)
    {
        //return;
        if (!textures.ContainsKey(textureID) && !bitmaps.ContainsKey(textureID))
        {
            if (Client.Assets.Cache.HasAsset(textureID))
            {
                //Debug.Log("Cache hits!");
                byte[] jpg = Client.Assets.Cache.GetCachedAssetBytes(textureID);

                Bitmap img = Jpgbytes2Bitmap(jpg);
                if (img == null) return;
                bitmaps[textureID] = img;	//fixme: there may be access violation
            }
            else
            {
                TextureDownloadCallback handler = (state, asset) =>
                {
                    //Debug.Log("state is " + state.ToString());
                    try{
                        switch (state)
                        {
                            case TextureRequestState.Finished:
                            {
                                Bitmap img = Jpgbytes2Bitmap(asset.AssetData);
                                if (img == null) return;
                                bitmaps[textureID] = img;	//fixme: there may be access violation
                                break;
                            }
           						case TextureRequestState.Aborted:
                            case TextureRequestState.NotFound:
                            case TextureRequestState.Timeout:
                                break;
                        }
                    }
                    catch(Exception ex)
                    {
                        Debug.Log("what happened?:" + ex.Message);
                    }
                };

                Client.Assets.RequestImage(textureID, ImageType.Normal, handler);
            }
        }
    }

Usage Example

 void DownloadAVTextures(OpenMetaverse.Avatar a)
 {
     foreach (Primitive.TextureEntryFace TEF in a.Textures.FaceTextures)
     {
         if (TEF == null)
         {
             continue;
         }
         m_textures.DownloadTexture(TEF.TextureID);
     }
 }
All Usage Examples Of TextureProcess::DownloadTexture