當前位置: 首頁>>代碼示例>>C#>>正文


C# Point.CopyTo方法代碼示例

本文整理匯總了C#中System.Drawing.Point.CopyTo方法的典型用法代碼示例。如果您正苦於以下問題:C# Point.CopyTo方法的具體用法?C# Point.CopyTo怎麽用?C# Point.CopyTo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Drawing.Point的用法示例。


在下文中一共展示了Point.CopyTo方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ClippedBitmap

        public static Texture2D ClippedBitmap(Texture2D t2d, Point[] pointsArray,  out Point position)
        {
            MemoryStream mStream = new MemoryStream();
            t2d.SaveAsPng(mStream, t2d.Width, t2d.Height);
            Bitmap texture = new Bitmap(mStream);
            int minX = pointsArray.Min(x => x.X);//margin.X >= 0 ? x.X : x.X + margin.X);
            int maxX = pointsArray.Max(x => x.X);//margin.X <= 0 ? x.X : x.X + margin.X);
            int minY = pointsArray.Min(x => x.Y);//margin.Y >= 0 ? x.Y : x.Y + margin.Y);
            int maxY = pointsArray.Max(x => x.Y);//margin.Y <= 0 ? x.X : x.X + margin.X);
            position = new Point(minX, minY);
            if (maxX - minX <= 0 || maxY - minY <= 0) return Assets.textureDict[textures.whitepixel];
            Bitmap bmp = new Bitmap(maxX - minX, maxY - minY);
            Point[] offset = new Point[pointsArray.Length];
            pointsArray.CopyTo(offset, 0);
            offset = Array.ConvertAll(offset, x => x = new Point(x.X - minX, x.Y - minY));
            Graphics g = Graphics.FromImage(bmp);
            TextureBrush tb = new TextureBrush(texture);
            g.FillPolygon(tb, offset);

            Color[] pixels = new Color[bmp.Width * bmp.Height];
            for (int y = 0; y < bmp.Height; y++)
            {
                for (int x = 0; x < bmp.Width; x++)
                {
                    System.Drawing.Color c = bmp.GetPixel(x, y);
                    pixels[(y * bmp.Width) + x] = new Color(c.R, c.G, c.B, c.A);
                }
            }

            Texture2D myTex = new Texture2D(
              OrbIt.game.GraphicsDevice,
              bmp.Width,
              bmp.Height);

            myTex.SetData<Color>(pixels);
            return myTex;
        }
開發者ID:GameMakersUnion,項目名稱:BoulderDash-OrbIt,代碼行數:37,代碼來源:Assets.cs


注:本文中的System.Drawing.Point.CopyTo方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。