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


C# TileSet.IsCached方法代码示例

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


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

示例1: GetCompositeImage

        /// <summary>
        /// Create an image for this layer by stitching together tile images.
        /// </summary>
        /// <param name="oLayerBoundingBox">
        /// The bounding box for the layer. Tiles outside this bounding box will not be drawn.
        /// </param>
        /// <param name="oViewBoundingBox">
        /// The bounding box of the view. The resulting image will be scaled and
        /// cropped to fill this view.
        /// </param>
        /// <returns>The raw data of the composed image.</returns>
        public byte[] GetCompositeImage(BoundingBox oLayerBoundingBox, BoundingBox oViewBoundingBox)
        {
            if (!oLayerBoundingBox.Intersects(oViewBoundingBox))
                return BlankImageBytes();

            BoundingBox visibleDataBounds = oLayerBoundingBox.IntersectWith(oViewBoundingBox);

            //bool moreDataComing = false;
            TileSet oRequiredTiles = new TileSet(visibleDataBounds, TileSet.GetLevel(oViewBoundingBox));
            TileSet oServiceTiles = oRequiredTiles;

            // --- Keep going to lower-levelled tiles until we can service the request ---

            System.Diagnostics.Debug.WriteLine("Requesting composite image at level " + oServiceTiles.Level);
            while (oServiceTiles.Level > 0 && !oServiceTiles.IsCached(this, oLayerBoundingBox))
            {
                oRequiredTiles = oServiceTiles;
                oServiceTiles = new TileSet(visibleDataBounds, oServiceTiles.Level - 1);
                //moreDataComing = true;
                System.Diagnostics.Debug.WriteLine("Decrementing level to " + oServiceTiles.Level);
            }

            // --- Queue up the other images for the request ---

            if (!oRequiredTiles.IsCached(this, oLayerBoundingBox))
            {
                DownloadSet oRequiredDownloads = new DownloadSet(this, oRequiredTiles, oLayerBoundingBox);
                oRequiredDownloads.DownloadAsync(new EventHandler(oRequiredDownloads_DownloadComplete));
            }

            // --- Compose image tiles to master tile ---

            Bitmap composite = ComposeImageFromTileCache(oServiceTiles);
            BoundingBox compositeBounds = oServiceTiles.Bounds;
            double degreesPerPixel = TileInfo.GetTileSize(oServiceTiles.Level) / TileInfo.TileSizePixels;

            // --- Render the image for the tile level requested ---

            Bitmap result = new Bitmap((int)((oViewBoundingBox.MaxX - oViewBoundingBox.MinX) / degreesPerPixel), (int)((oViewBoundingBox.MaxY - oViewBoundingBox.MinY) / degreesPerPixel));
            BoundingBox resultBounds = new BoundingBox(oViewBoundingBox);

            using (Graphics g = Graphics.FromImage(result))
            {
                g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;

                g.DrawImage(composite, new PointF((float)((compositeBounds.MinX - resultBounds.MinX) / degreesPerPixel), (float)((resultBounds.MaxY - compositeBounds.MaxY) / degreesPerPixel)));

                //if (moreDataComing)
                //   g.FillRectangle(new System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.Percent05, Color.Green, Color.Transparent), 0, 0, result.Width, result.Height);
            }

            result.Save("C:/documents and settings/chrismac/desktop/sent.png", System.Drawing.Imaging.ImageFormat.Png);

            MemoryStream buffer = new MemoryStream();
            result.Save(buffer, System.Drawing.Imaging.ImageFormat.Png);
            return buffer.ToArray();
        }
开发者ID:paladin74,项目名称:Dapple,代码行数:68,代码来源:LayerInfo.cs


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