当前位置: 首页>>代码示例>>C#>>正文


C# IAssetService.GetData方法代码示例

本文整理汇总了C#中IAssetService.GetData方法的典型用法代码示例。如果您正苦于以下问题:C# IAssetService.GetData方法的具体用法?C# IAssetService.GetData怎么用?C# IAssetService.GetData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IAssetService的用法示例。


在下文中一共展示了IAssetService.GetData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReadAssetAsString

 public static string ReadAssetAsString(IAssetService assetService, UUID uuid)
 {            
     byte[] assetData = assetService.GetData(uuid.ToString());
     return Encoding.ASCII.GetString(assetData);
 }
开发者ID:phantasmagoric,项目名称:InfiniteGrid-Opensim,代码行数:5,代码来源:AssetHelpers.cs

示例2: Splat

        /// <summary>
        ///     Builds a composited terrain texture given the region texture
        ///     and heightmap settings
        /// </summary>
        /// <param name="heightmap">Terrain heightmap</param>
        /// <param name="textureIDs"></param>
        /// <param name="startHeights"></param>
        /// <param name="heightRanges"></param>
        /// <param name="regionPosition"></param>
        /// <param name="assetService"></param>
        /// <param name="textureTerrain"></param>
        /// <returns>A composited 256x256 RGB texture ready for rendering</returns>
        /// <remarks>
        ///     Based on the algorithm described at http://opensimulator.org/wiki/Terrain_Splatting
        /// </remarks>
        public static Bitmap Splat(ITerrainChannel heightmap, UUID[] textureIDs, float[] startHeights,
            float[] heightRanges, Vector3d regionPosition, IAssetService assetService,
            bool textureTerrain)
        {
            Debug.Assert(textureIDs.Length == 4);
            Debug.Assert(startHeights.Length == 4);
            Debug.Assert(heightRanges.Length == 4);

            Bitmap[] detailTexture = new Bitmap[4];
            int outWidth = heightmap.Width;
            int outHeight = heightmap.Height;
            IJ2KDecoder m_imgDecoder;

            if (textureTerrain)
            {
                // Swap empty terrain textureIDs with default IDs
                for (int i = 0; i < textureIDs.Length; i++)
                {
                    if (textureIDs[i] == UUID.Zero)
                        textureIDs[i] = DEFAULT_TERRAIN_DETAIL[i];
                }

                #region Texture Fetching

                if (assetService != null)
                {
                    m_imgDecoder =  heightmap.Scene.RequestModuleInterface<IJ2KDecoder>();

                    for (int i = 0; i < 4; i++)
                    {
                        UUID cacheID = UUID.Combine(TERRAIN_CACHE_MAGIC, textureIDs[i]);
                        AssetBase asset = assetService.Get(cacheID.ToString(),false);           // ignore warnings here as the cached texture may not exist

                        if ((asset != null) && (asset.Data != null) && (asset.Data.Length != 0))
                        {
                            try
                            {
                                using (MemoryStream stream = new MemoryStream(asset.Data))
                                    detailTexture[i] = (Bitmap) Image.FromStream(stream);
                            }
                            catch (Exception ex)
                            {
                                MainConsole.Instance.Warn("Failed to decode cached terrain texture " + cacheID +
                                                          " (textureID: " + textureIDs[i] + "): " + ex.Message);
                            }
                        }

                        if (detailTexture[i] == null)
                        {
                            // Try to fetch the original JPEG2000 texture, resize if needed, and cache as PNG
                            byte[] assetData = assetService.GetData(textureIDs[i].ToString());
                            if (assetData != null)
                            {
                                try
                                {
                                    detailTexture[i] = (Bitmap)m_imgDecoder.DecodeToImage(assetData);
                                }
                                catch (Exception ex)
                                {
                                    MainConsole.Instance.Warn("Failed to decode terrain texture " + textureIDs[i] + ": " +
                                                              ex.Message);
                                }
                            }

                            if (detailTexture[i] != null)
                            {
                                Bitmap bitmap = detailTexture[i];

                                // Make sure this texture is the correct size, otherwise resize
                                if (bitmap.Width != outWidth || bitmap.Height != outHeight)
                                    bitmap = ImageUtils.ResizeImage(bitmap, outWidth, outHeight);

                                // Save the decoded and resized texture to the cache
                                byte[] data;
                                using (MemoryStream stream = new MemoryStream())
                                {
                                    bitmap.Save(stream, ImageFormat.Png);
                                    data = stream.ToArray();
                                }

                                // Cache a PNG copy of this terrain texture
                                AssetBase newAsset = new AssetBase
                                                         {
                                                             Data = data,
                                                             Description = "PNG",
//.........这里部分代码省略.........
开发者ID:emperorstarfinder,项目名称:Virtual-Universe,代码行数:101,代码来源:TerrainSplat.cs


注:本文中的IAssetService.GetData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。