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


C# Image.Crop方法代码示例

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


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

示例1: InitRayer

		public static void InitRayer()
		{
			CharacterStackTexture = new Texture2D[5];
			CharacterStackTextureInfo = new TextureInfo[5];
			
			var image0 = new Image("/Application/resourses/myCharacterStack.png");
			var image04 = image0.Crop(new ImageRect(0,0,128,32));
			var image03 = image0.Crop(new ImageRect(0,32,128,32));
			var image02 = image0.Crop(new ImageRect(0,64,128,32));
			var image01 = image0.Crop(new ImageRect(0,96,128,32));
			var image00 = image0.Crop(new ImageRect(0,128,128,32));
			
			CharacterStackTexture[0] = Convert.CreateTextureFromImage(image00);
			CharacterStackTextureInfo[0] = new TextureInfo(CharacterStackTexture[0]);
			CharacterStackTexture[1] = Convert.CreateTextureFromImage(image01);
			CharacterStackTextureInfo[1] = new TextureInfo(CharacterStackTexture[1]);
			CharacterStackTexture[2] = Convert.CreateTextureFromImage(image02);
			CharacterStackTextureInfo[2] = new TextureInfo(CharacterStackTexture[2]);
			CharacterStackTexture[3] = Convert.CreateTextureFromImage(image03);
			CharacterStackTextureInfo[3] = new TextureInfo(CharacterStackTexture[3]);
			CharacterStackTexture[4] = Convert.CreateTextureFromImage(image04);
			CharacterStackTextureInfo[4] = new TextureInfo(CharacterStackTexture[4]);
			
			image0.Dispose();
			image00.Dispose();
			image01.Dispose();
			image02.Dispose();
			image03.Dispose();
			image04.Dispose();
		}
开发者ID:noradium,项目名称:Black-Rins-ambition,代码行数:30,代码来源:Rayer.cs

示例2: InitEnemyBullet

        public static void InitEnemyBullet()
        {
            BulletList = new ArrayList();
            BulletTexture = new Texture2D[4];
            BulletTextureInfo = new TextureInfo[4];

            var image2 = new Image("/Application/resourses/Bullet01_16x16.png");
            var image20 = image2.Crop(new ImageRect(0,0,16,16));
            var image21 = image2.Crop(new ImageRect(0,16,16,16));
            var image22 = image2.Crop(new ImageRect(0,32,16,16));
            var image23 = image2.Crop(new ImageRect(0,48,16,16));

            BulletTexture[0] = Convert.CreateTextureFromImage(image20);
            BulletTextureInfo[0] = new TextureInfo(BulletTexture[0]);
            BulletTexture[1] = Convert.CreateTextureFromImage(image21);
            BulletTextureInfo[1] = new TextureInfo(BulletTexture[1]);
            BulletTexture[2] = Convert.CreateTextureFromImage(image22);
            BulletTextureInfo[2] = new TextureInfo(BulletTexture[2]);
            BulletTexture[3] = Convert.CreateTextureFromImage(image23);
            BulletTextureInfo[3] = new TextureInfo(BulletTexture[3]);
            image2.Dispose();
            image20.Dispose();
            image21.Dispose();
            image22.Dispose();
            image23.Dispose();
        }
开发者ID:noradium,项目名称:Black-Rins-ambition,代码行数:26,代码来源:Bullet.cs

示例3: Render

        public void Render(Image image, Drawable drawable)
        {
            var src = new PixelRgn(drawable, false, false);
              PixelRgn.Register(src);

              var trimColor = GetTrimColor(src, drawable);

              var tb = GetLowerUpper(trimColor, src.Rows, "top", "bottom");
              var lr = GetLowerUpper(trimColor, src.Columns, "left", "right");

              var croppingArea = new Rectangle(lr.Item1, tb.Item1, lr.Item2, tb.Item2);
              if (croppingArea != image.Bounds)
            {
              image.Crop(croppingArea);
            }
        }
开发者ID:unhammer,项目名称:gimp-sharp,代码行数:16,代码来源:Renderer.cs

示例4: CutTexture

        private Texture2D CutTexture(string path, BoundBox rectangle)
        {
            ImageRect imageRect = new ImageRect ((int)rectangle.X, (int)rectangle.Y, (int)rectangle.Width, (int)rectangle.Height);
            if(System.IO.File.Exists(@"/Application/Content/Pic/" + path))
            {
                Image image = new Image (@"/Application/Content/Pic/" + path);
                image.Decode ();

            texture = new Texture2D ((int)rectangle.Width, (int)rectangle.Height, false, PixelFormat.Rgba);
            texture.SetPixels (0, image.Crop (imageRect).ToBuffer ());
            image.Dispose ();
            }
            else
                DebugScene.Instance.WriteLine("未找到文件:Pic/" + path);
            return texture;
        }
开发者ID:PssProgram,项目名称:Lost-In-Trek,代码行数:16,代码来源:SptireX.cs

示例5: WriteSlice

 public void WriteSlice(Image image, string path, string name, 
     bool useGlobalExtension)
 {
     var clone = new Image(image);
       clone.Crop(Width, Height, X1, Y1);
       string filename = path + System.IO.Path.DirectorySeparatorChar +
     GetFilename(name, useGlobalExtension);
       clone.Save(RunMode.Noninteractive, filename, filename);
       clone.Delete();
 }
开发者ID:unhammer,项目名称:gimp-sharp,代码行数:10,代码来源:Rectangle.cs

示例6: SkillUseEffect

        /// <summary>
        /// スキル使用時エフェクト
        /// </summary>
        /// <param name='mySpritePosition'>
        /// 自機スプライトの位置
        /// </param>
        public static void SkillUseEffect(Vector2 mySpritePosition)
        {
            var image1 = new Image("/Application/resourses/Bullet01_64x64.png");
            image1 = image1.Crop(new ImageRect(0,0,64,64));
            var image2 = new Image("/Application/resourses/effect1.png");
            image2 = image2.Resize(new ImageSize(960,180));

            var waveTexture = Convert.CreateTextureFromImage(image1);
            image2.Decode();
            var bgTexture = Convert.CreateTextureFromImage(image2);

            image1.Dispose();
            image2.Dispose();

            var skillName = "";
            switch(Global.setSkill){
            case SkillID.Default :
                skillName = "The WORLD";
                break;
            case SkillID.Skill1 :
                skillName = "Refrection";
                break;
            case SkillID.Skill2 :
                skillName = "";
                break;
            case SkillID.Skill3 :
                skillName = "";
                break;
            }
            var textTexture = Convert.CreateTextureFromText(skillName,new Font(FontAlias.System,120,FontStyle.Bold | FontStyle.Italic),0xFFFFFF00) ;

            waveTextureInfo = new TextureInfo(waveTexture);
            textTextureInfo = new TextureInfo(textTexture);
            bgTextureInfo = new TextureInfo(bgTexture);

            waveSprite = new SpriteUV(){TextureInfo = waveTextureInfo};
            textSprite = new SpriteUV(){TextureInfo = textTextureInfo};
            bgSprite = new SpriteUV(){TextureInfo = bgTextureInfo};

            waveSprite.Quad.S = waveTextureInfo.TextureSizef;
            textSprite.Quad.S = textTextureInfo.TextureSizef;
            bgSprite.Quad.S = bgTextureInfo.TextureSizef;

            waveSprite.CenterSprite();
            textSprite.CenterSprite();
            bgSprite.CenterSprite();

            waveSprite.Position = mySpritePosition;
            textSprite.Position = new Vector2(1500,272);
            bgSprite.Position = new Vector2(1500,272);

            Scenes.sceneOnGame.AddChild(waveSprite);
            Scenes.sceneOnGame.AddChild(bgSprite);
            Scenes.sceneOnGame.AddChild(textSprite);

            var seq0 = new Sequence();
            seq0.Add(new MoveTo(new Vector2(480,272),1));
            seq0.Add(new DelayTime(1.0f));
            seq0.Add(new MoveTo(new Vector2(-500,272),1));

            var seq1 = new Sequence();
            seq1.Add(new MoveTo(new Vector2(480,272),1));
            seq1.Add(new DelayTime(1.0f));
            seq1.Add(new MoveTo(new Vector2(-500,272),1));

            var seq2 = new Sequence();
            seq2.Add(new DelayTime(3.5f));
            seq2.Add(new CallFunc(()=>{Sounds.PlaySkill2();}));
            seq2.Add(new ScaleTo(new Vector2(40,40),3));

            Sounds.PlaySkill1();
            bgSprite.RunAction(seq0);
            textSprite.RunAction(seq1);
            waveSprite.RunAction(seq2);
        }
开发者ID:noradium,项目名称:Black-Rins-ambition,代码行数:81,代码来源:Effect.cs


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