OpenMetaverse.AssetManager.RequestImage C# (CSharp) Метод

RequestImage() публичный Метод

Overload: Request a texture asset from the simulator using the TexturePipeline system to manage the requests and re-assemble the image from the packets received from the simulator
public RequestImage ( UUID textureID, ImageType imageType, TextureDownloadCallback callback ) : void
textureID UUID The of the texture asset to download
imageType ImageType The of the texture asset. /// Use for most textures, or for baked layer texture assets
callback TextureDownloadCallback The callback to fire when the image is retrieved. The callback /// will contain the result of the request and the texture asset data
Результат void
        public void RequestImage(UUID textureID, ImageType imageType, TextureDownloadCallback callback)
        {
            RequestImage(textureID, imageType, 101300.0f, 0, 0, callback, false);
        }

Same methods

AssetManager::RequestImage ( UUID textureID, ImageType imageType, TextureDownloadCallback callback, bool progress ) : void
AssetManager::RequestImage ( UUID textureID, ImageType imageType, float priority, int discardLevel, uint packetStart, TextureDownloadCallback callback, bool progress ) : void
AssetManager::RequestImage ( UUID textureID, TextureDownloadCallback callback ) : void

Usage Example

        public static void SaveAssets(AssetManager assetManager, AssetType assetType, IList<UUID> assets, string assetsPath)
        {
            int count = 0;

            List<UUID> remainingTextures = new List<UUID>(assets);
            AutoResetEvent AllPropertiesReceived = new AutoResetEvent(false);
            for (int i = 0; i < assets.Count; i++)
            {
                UUID texture = assets[i];
                if(assetType == AssetType.Texture)
                {
                    assetManager.RequestImage(texture, (state, assetTexture) =>
                    {
                        string extension = string.Empty;

                        if (assetTexture == null)
                        {
                            Console.WriteLine("Missing asset " + texture);
                            return;
                        }

                        if (ArchiveConstants.ASSET_TYPE_TO_EXTENSION.ContainsKey(assetType))
                            extension = ArchiveConstants.ASSET_TYPE_TO_EXTENSION[assetType];

                        File.WriteAllBytes(Path.Combine(assetsPath, texture.ToString() + extension), assetTexture.AssetData);
                        remainingTextures.Remove(assetTexture.AssetID);
                        if (remainingTextures.Count == 0)
                            AllPropertiesReceived.Set();
                        ++count;
                    });
                }
                else
                {
                    assetManager.RequestAsset(texture, assetType, false, (transfer, asset) =>
                    {
                        string extension = string.Empty;

                        if (asset == null)
                        {
                            Console.WriteLine("Missing asset " + texture);
                            return;
                        }

                        if (ArchiveConstants.ASSET_TYPE_TO_EXTENSION.ContainsKey(assetType))
                            extension = ArchiveConstants.ASSET_TYPE_TO_EXTENSION[assetType];

                        File.WriteAllBytes(Path.Combine(assetsPath, texture.ToString() + extension), asset.AssetData);
                        remainingTextures.Remove(asset.AssetID);
                        if (remainingTextures.Count == 0)
                            AllPropertiesReceived.Set();
                        ++count;
                    });
                }

                Thread.Sleep(200);
                if (i % 5 == 0)
                    Thread.Sleep(250);
            }
            AllPropertiesReceived.WaitOne(5000 + 350 * assets.Count);

            Logger.Log("Copied " + count + " textures to the asset archive folder", Helpers.LogLevel.Info);
        }