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


C# Image.Dispose方法代码示例

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


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

示例1: Render


//.........这里部分代码省略.........

                }

                if(dead[i].On)
                    dead[i].Render(scene);

            }

            //	   		Image img = new Image(ImageMode.Rgba, new ImageSize(width,height),
            //	                         new ImageColor(255,0,0,0));
            //	   		img.DrawText("Hello World",
            //	                new ImageColor(255,0,0,255),
            //	                new Font(FontAlias.System,170,FontStyle.Regular),
            //	                new ImagePosition(0,150));
            //
            //	   		Texture2D texture = new Texture2D(width,height,false,
            //	                                     PixelFormat.Rgba);
            //	   		texture.SetPixels(0,img.ToBuffer());
            //	   		img.Dispose();
            //
            //	   		Image img1 = new Image(ImageMode.Rgba, new ImageSize(width/5,height/10),
            //	                         new ImageColor(255,0,0,0));
            //	   		img1.DrawText(scene.Camera.CalcBounds().Center.ToString(),
            //	                new ImageColor(0,0,255,255),
            //	                new Font(FontAlias.System,20,FontStyle.Regular),
            //	                new ImagePosition(0,0));
            //
            //	   		Texture2D texture1 = new Texture2D(width/5,height/10,false,
            //	                                     PixelFormat.Rgba);
            //	   		texture1.SetPixels(0,img1.ToBuffer());
            //	   		img1.Dispose();
            //
            //
            //	   		TextureInfo ti1 = new TextureInfo();
            //	   		ti1.Texture = texture1;
            //
            //	   		SpriteUV sprite1 = new SpriteUV();
            //	   		sprite1.TextureInfo = ti1;
            //
            //	   		sprite1.Quad.S = ti1.TextureSizef;
            //	   		sprite1.CenterSprite();
            //	   		sprite1.Position = new Vector2(100,100);// scene.Camera.CalcBounds().Center;
            //
            //	   		scene.AddChild(sprite1);
            //
            //
            //	   		TextureInfo ti = new TextureInfo();
            //	   		ti.Texture = texture;
            //
            //	   		SpriteUV sprite = new SpriteUV();
            //	   		sprite.TextureInfo = ti;
            //
            //	   		sprite.Quad.S = ti.TextureSizef;
            //	   		sprite.CenterSprite();
            //	   		sprite.Position = new Vector2(100,100);
            //
               		//scene.AddChild(sprite);

            if(altimer.Milliseconds() > 800){
                alpha-=.1f;
                altimer.Reset();
            }

            counter++;

            if(timer1.Milliseconds() >= 1000){
                timer1.Reset();
                FPS=counter;
                counter=0;

            img = new Image(ImageMode.Rgba, new ImageSize(width/2,height/10),
                         new ImageColor(255,255,0,0));
               			img.DrawText("Score: "+score.ToString()+"\nHighscore: "+highscore.ToString()+ " " + (FPS).ToString(),
                new ImageColor(255,0,0,255),
                new Font(FontAlias.System,20,FontStyle.Bold),
                new ImagePosition(0,0));

              			texturet = new Texture2D(width/2,height/10,false,
                                     PixelFormat.Rgba);

               			texturet.SetPixels(0,img.ToBuffer());
               			img.Dispose();

            }

               			TextureInfo ti = new TextureInfo();
               			ti.Texture = texturet;

               			SpriteUV sprite = new SpriteUV();
               			sprite.TextureInfo = ti;

               			sprite.Quad.S = ti.TextureSizef;
               			//sprite.CenterSprite();
               			sprite.Position = uppercorner;
            scene.AddChild(sprite);

            Director.Instance.Render();
            Director.Instance.GL.Context.SwapBuffers();
            Director.Instance.PostSwap();
        }
开发者ID:cytricks,项目名称:PSMSS,代码行数:101,代码来源:SurvivalMode.cs

示例2: DrawSprite

        /// <summary>
        /// Draws the sprite. and Add the scene.
        /// 文字列(のsprite)を作成するメソッド
        /// </summary>
        /// <returns>
        /// The sprite.
        /// </returns>
        /// <param name='drawStr'>
        /// Draw string.
        /// </param>
        /// <param name='positionX'>
        /// Position x.
        /// </param>
        /// <param name='positionY'>
        /// Position y.
        /// </param>
        /// <param name='fontSize'>
        /// Font size.
        /// </param>
        /// <param name='fontColor'>
        /// Font color.
        /// </param>
        public static SpriteUV DrawSprite(String drawStr,float positionX, float positionY,
		                                   int fontSize,ImageColor fontColor)
        {
            //Director.Initialize(); //重要なんで最初にinitializeしようね。GameEngine2Dのために必要(たぶんほかにも)
            //Scene  //Sce.Pss.HighLevel.GameEngine2DのScene()
            //scene.Camera.SetViewFromViewport(); //CameraをDisplayで使う たぶん画面サイズ -> 3DCGソフトでいうところのカメラ。それの移してる範囲=画面サイズ
            positionX = Const.DISPLAY_WIDTH - Const.DISPLAY_WIDTH*(Const.GRID_NUM_X-positionX)/Const.GRID_NUM_X;
            positionY = Const.DISPLAY_HEIGHT - Const.DISPLAY_HEIGHT*(Const.GRID_NUM_Y-positionY)/Const.GRID_NUM_Y;
            //the Director's OpenGL context たぶん画面サイズの幅
            //var width = (int)Const.getVITA_DISPLAY_WIDTH();
            //var height = (int)Const.getVITA_DISPLAY_HEIGHT();

            //Font font = new Font(FontAlias.System, fontSize, FontStyle.Regular);
            Font font = new Font(Const.DEFAULT_FONT, fontSize, FontStyle.Regular); //日本語使う
            var width = font.GetTextWidth(drawStr);
            var height = font.GetTextWidth("oo");
            //Console.WriteLine(width + " : " + height);

            //Image classはimageデータを保つよ~。 PNG or JPGなど
            //今回はblankのnew Image でも、これ作らないと img.DrawTextが使えない
            Image img = new Image(ImageMode.Rgba,
                                  new ImageSize(width,height), //固定で。たぶん描画範囲
                                  new ImageColor(255,0,0,0));//blankなので変更しても意味なし
            //ここで文字を作ってる
            img.DrawText(drawStr,
                         fontColor,
                         font,
                         new ImagePosition(0, 0)); //画面の位置

            //textureを作る
            Texture2D texture = new Texture2D(width,
                                              height,
                                              false,
                                              PixelFormat.Rgba);

            //Texture2D を使うためにimageからpixelデータに変換(img.ToBuffer())
            //それをtexture.SetPixelsでtextureにPixcelデータを貼り付け
            texture.SetPixels(0, img.ToBuffer());
            //で一覧のimgの処理を実行
            img.Dispose();

            //新しいTexture作るときはTextureInfoも作らないとね
            TextureInfo ti = new TextureInfo();
            ti.Texture = texture;

            //スプライト(イメージパターン)を作る。まぁ、テクスチャだし
            SpriteUV sprite = new SpriteUV();
            sprite.TextureInfo = ti;

            //テクスチャーの貼り付けられた長方形(quad.S)を作成。サイズはImage img = new Imageのとこ。たぶん
            sprite.Quad.S = ti.TextureSizef;
            sprite.CenterSprite();
            //sprite.Position = scene.Camera.CalcBounds().Center;

            positionX = positionX + sprite.Quad.S.X/2;
            positionY = Const.DISPLAY_HEIGHT- positionY - sprite.Quad.S.Y;

            sprite.Position = new Vector2(positionX,positionY);

            return sprite;
        }
开发者ID:k2wanko,项目名称:PSMGameJamWinter,代码行数:83,代码来源:WriteString.cs

示例3: Main

        /*private static GraphicsContext graphics;

        public static void Main (string[] args)
        {
            Initialize ();

            while (true) {
                SystemEvents.CheckEvents ();
                Update ();
                Render ();
            }
        }

        public static void Initialize ()
        {
            // Set up the graphics system
            graphics = new GraphicsContext ();
        }

        public static void Update ()
        {
            // Query gamepad for current state
            var gamePadData = GamePad.GetData (0);
        }

        public static void Render ()
        {
            // Clear the screen
            graphics.SetClearColor (0.0f, 0.0f, 0.0f, 0.0f);
            graphics.Clear ();

            // Present the screen
            graphics.SwapBuffers ();
        }*/
        public static void Main(string[] args)
        {
            //JP: initialize GameEngine2D singletion that handles loop
            Director.Initialize();
            //JP: New 2D scene (graph) container (and camera alignment to orthogonal view
            Scene scene = new Scene();
            scene.Camera.SetViewFromViewport();
            //JP: Get width and height to local variables (optimization)
            var width = Director.Instance.GL.Context.GetViewport().Width;
            var height = Director.Instance.GL.Context.GetViewport().Height;
            //JP: Create new image
            Image img = new Image(ImageMode.Rgba, new ImageSize(width,height),
                                  new ImageColor(255,0,0,0));
            img.DrawText("Dream-Gin",
                         new ImageColor(255,0,0,255),
                         new Font(FontAlias.System,170,FontStyle.Regular),
                         new ImagePosition(0,150));
            //JP: Create hax0r frame buffer and add our img to it's buffer (and consequently kill img content)
            Texture2D texture = new Texture2D(width,height,false,
                                              PixelFormat.Rgba);
            texture.SetPixels(0,img.ToBuffer());
            img.Dispose();
            //JP: Texture info needed for SpriteUV
            TextureInfo ti = new TextureInfo();
            ti.Texture = texture;
            //JP: Add ti to SpriteUV
            SpriteUV sprite = new SpriteUV();
            sprite.TextureInfo = ti;
            //JP: resize sprite and center
            sprite.Quad.S = ti.TextureSizef;
            sprite.CenterSprite();
            sprite.Position = scene.Camera.CalcBounds().Center;
            //JP: Add to Scene
            scene.AddChild(sprite);
            //JP: execute loop shit
            Director.Instance.RunWithScene(scene, true);

            bool gameOver = false;

            while(!gameOver)
            {
                Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.Update();
                if(Input2.GamePad.GetData(0).Left.Release)
                {
                    sprite.Rotate(Sce.PlayStation.HighLevel.GameEngine2D.Base.Math.Deg2Rad(90));
                }
                if(Input2.GamePad0.Right.Release)
                {
                    sprite.Rotate(Sce.PlayStation.HighLevel.GameEngine2D.Base.Math.Deg2Rad(-90));
                }
                if((Sce.PlayStation.Core.Input.GamePad.GetData(0).Buttons & GamePadButtons.Up) == GamePadButtons.Up)
                {
                    sprite.Quad.S = new Vector2(sprite.Quad.S.X += 10.0f,sprite.Quad.S.Y += 10.0f);
                    sprite.CenterSprite();
                }
                if((Sce.PlayStation.Core.Input.GamePad.GetData(0).Buttons & GamePadButtons.Down) == GamePadButtons.Down)
                {
                    sprite.Quad.S = new Vector2(sprite.Quad.S.X -= 10.0f,sprite.Quad.S.Y -= 10.0f);
                    sprite.CenterSprite();
                }
                if(Input2.GamePad0.Circle.Press == true)
                    gameOver = true;

                Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.Render();
                Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.GL.Context.SwapBuffers();
                Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.PostSwap();
//.........这里部分代码省略.........
开发者ID:dreammjpr,项目名称:DreamGin,代码行数:101,代码来源:AppMain.cs

示例4: 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

示例5: 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

示例6: PostImage

 public void PostImage(Image<Bgr, byte> image)
 {
     if (image != null) // null sometimes while doing thresholding
     {
         PiBroker.Instance.ImageReceived(image);
         image.Dispose();
     }
 }
开发者ID:neutmute,项目名称:PiCamCV,代码行数:8,代码来源:PiController.cs

示例7: UpdateImage

        private void UpdateImage()
        {
            Image image = new Image(ImageMode.Rgba,new ImageSize(110,100),new ImageColor(0,0,0,0));
            Font font = new Font(FontAlias.System,50,FontStyle.Regular);
            image.DrawText(playerScore + " - " + aiScore,new ImageColor(255,255,255,255),font,new ImagePosition(0,0));
            image.Decode();

            var texture  = new Texture2D(110,100,false,PixelFormat.Rgba);
            if(this.TextureInfo.Texture != null)
                this.TextureInfo.Texture.Dispose();
            this.TextureInfo.Texture = texture;
            texture.SetPixels(0,image.ToBuffer());
            font.Dispose();
            image.Dispose();
        }
开发者ID:simar7,项目名称:playstation-sandbox,代码行数:15,代码来源:Scoreboard.cs

示例8: Main

        public static void Main(string[] args)
        {
            Director.Initialize();

            //Initialize ();

            Scene scene = new Scene();
            scene.Camera.SetViewFromViewport();

            var width = Director.Instance.GL.Context.GetViewport().Width;
            var height = Director.Instance.GL.Context.GetViewport().Height;

            /* Color Matrix Values
             * Unfortunately C# doesn't allow the regular #define usage,
             * See: The #define directive cannot be used to declare constant values
             * as is typically done in C and C++. Constants in C# are best defined as static members of a
             * class or struct. If you have several such constants, consider creating a separate "Constants"
             * class to hold them.
             *
             */
            const int RED = 255;
            const int BLUE = 0;
            const int GREEN = 0;
            const int ALPHA = 0;

            Image img = new Image(ImageMode.Rgba, new ImageSize(width, height), new ImageColor(RED,GREEN,BLUE,ALPHA));

            img.DrawText("Hello World", new ImageColor(RED,GREEN,BLUE,ALPHA+255),
            new Font(FontAlias.System,170,FontStyle.Regular), new ImagePosition(0,150));

            Texture2D texture = new Texture2D(width,height,false,PixelFormat.Rgba);
            texture.SetPixels(0,img.ToBuffer());
            img.Dispose();

            TextureInfo ti = new TextureInfo();
            ti.Texture = texture;

            SpriteUV sprite = new SpriteUV();
            sprite.TextureInfo = ti;

            sprite.Quad.S = ti.TextureSizef;
            sprite.CenterSprite();
            sprite.Position = scene.Camera.CalcBounds().Center;

            scene.AddChild(sprite);

            Director.Instance.RunWithScene(scene);
        }
开发者ID:simar7,项目名称:playstation-sandbox,代码行数:48,代码来源:AppMain.cs

示例9: setText

        public void setText(string text)
        {
            var width = 200;
            var height = 60;
            Image img = new Image(ImageMode.Rgba, new ImageSize(width,height),
                                     new ImageColor(255,0,0,0));
               img.DrawText("" + text,
                            new ImageColor(255,0,0,255),
                            new Font(FontAlias.System,170,FontStyle.Regular),
                            new ImagePosition(100,100));

               texture2d = new Texture2D(width,height,false,
                                                 PixelFormat.Rgba);
                texture2d.SetPixels(0,img.ToBuffer());
                img.Dispose();
                Sce.PlayStation.HighLevel.GameEngine2D.Base.TextureInfo ti = new Sce.PlayStation.HighLevel.GameEngine2D.Base.TextureInfo(texture2d);
                this.TextureInfo = ti;
        }
开发者ID:k2wanko,项目名称:PSMGameJamWinter,代码行数:18,代码来源:TextLabel.cs

示例10: CreateTextureFromText

        /// <summary>
        /// 文字列からテクスチャ作成
        /// </summary>
        /// <returns>
        /// テクスチャ
        /// </returns>
        /// <param name='text'>
        /// 文字列
        /// </param>
        /// <param name='font'>
        /// フォント
        /// </param>
        /// <param name='argb'>
        /// ARGB
        /// </param>
        public static Texture2D CreateTextureFromText(string text, Font font, uint argb)
        {
            int width = font.GetTextWidth(text, 0, text.Length);
            int height = font.Metrics.Height;

            var image = new Image(ImageMode.Rgba, new ImageSize(width,height),new ImageColor(0,0,0,0));

            image.DrawText(text,new ImageColor((int)((argb >> 16) & 0xff),
                                               (int)((argb >> 8) & 0xff),
                                               (int)((argb >> 0) & 0xff),
                                               (int)((argb >> 24) & 0xff)),font,new ImagePosition(0,0));

            var texture = new Texture2D(width,height,false, PixelFormat.Rgba);
            texture.SetPixels(0, image.ToBuffer());

            image.Dispose();
            font.Dispose();
            return texture;
        }
开发者ID:noradium,项目名称:Black-Rins-ambition,代码行数:34,代码来源:Convert.cs

示例11: TextLabel

        //public Image img = null;
        //public ImageColor rgb = null;
        //public ImageSize size = null;
        public TextLabel(string text)
        {
            ImageColor rgb = new ImageColor(255,255,255,255);
            ImageSize size = new ImageSize(200,100);
            Image img = new Image(ImageMode.Rgba, size,
                        rgb);
            img.DrawText (text,
                          new ImageColor(255,255,255,255),
                          new Font(FontAlias.System,120,FontStyle.Regular),
                          new ImagePosition(300,200));
            texture2d = new Texture2D(size.Width, size.Height, false, PixelFormat.Rgba);

            texture2d.SetPixels(0,img.ToBuffer());

            img.Dispose();

            Sce.PlayStation.HighLevel.GameEngine2D.Base.TextureInfo ti = new Sce.PlayStation.HighLevel.GameEngine2D.Base.TextureInfo(texture2d);

            this.TextureInfo = ti;
        }
开发者ID:k2wanko,项目名称:PSMGameJamWinter,代码行数:23,代码来源:TextLabel.cs

示例12: Load

 public override Image Load(Stream s)
 {
     Tiff tif = Tiff.Open(s);
     FieldValue[] value = tif.GetField(TiffTag.ImageWidth);
     int width = value[0].ToInt();
     value = tif.GetField(TiffTag.ImageLength);
     int height = value[0].ToInt();
     int[] raster = new int[height * width];
     tif.ReadRGBAImage(width, height, raster);
     Image i = new Image(width, height);
     int rgba, rasterOffset;
     byte r, g, b, a;
     for (uint y = 0; y < i.Height; y++)
     {
         rasterOffset = (int)(y * i.Width);
         for (uint x = 0; x < i.Width; x++)
         {
             rgba = raster[rasterOffset++];
             r = (byte)(rgba & 0xff);
             g = (byte)((rgba >> 8) & 0xff);
             b = (byte)((rgba >> 16) & 0xff);
             a = (byte)((rgba >> 24) & 0xff);
             i.SetPixel(x, y, new Pixel(r, g, b, a));
         }
     }
     // Need to flip the image.
     Image i2 = new Image(width, height);
     uint y2 = 0;
     for (uint y = (uint)(i.Height - 1); y >= 0 && y < i.Height; y--)
     {
         for (uint x = 0; x < i.Width; x++)
         {
             i2.SetPixel(x, y2, i.GetPixel(x, y));
         }
         y2++;
     }
     i.Dispose();
     return i2;
 }
开发者ID:Orvid,项目名称:Cosmos,代码行数:39,代码来源:TiffSupport.cs

示例13: Render

        public void Render(Scene scene, int width, int height)
        {
            Image img1 = new Image(ImageMode.Rgba, new ImageSize(width/5,height/10),
                             new ImageColor(255,0,0,0));
               		img1.DrawText(RotationAngle.ToString()+" "+currentAngle.ToString(),
                    new ImageColor(0,0,255,255),
                    new Font(FontAlias.System,20,FontStyle.Regular),
                    new ImagePosition(0,0));

               		Texture2D texture1 = new Texture2D(width/5,height/10,false,
                                         PixelFormat.Rgba);
               		texture1.SetPixels(0,img1.ToBuffer());
               		img1.Dispose();

               		TextureInfo ti1 = new TextureInfo();

            //			if(timer.Milliseconds()>100){
            //				flip = !flip;
            //				timer.Reset();
            //			}

              		//if(flip) {
                ti1.Texture = shipTexture;
                //flip= !flip;
            //	}
            //	else {

            //		ti1.Texture = shipTexture1;
                //flip = !flip;

            //	}

            //	else
            //		ti1.Texture = texture1;

               		SpriteUV sprite1 = new SpriteUV();
               		sprite1.TextureInfo = ti1;

               		sprite1.Quad.S = ti1.TextureSizef.Multiply(.3f);
               		sprite1.CenterSprite();
               		sprite1.Position = position;// scene.Camera.CalcBounds().Center;

            sprite1.Rotate(-RotationAngle);//*Sce.PlayStation.HighLevel.GameEngine2D.Base.Math.Pi/180);

               		scene.AddChild(sprite1);
        }
开发者ID:cytricks,项目名称:PSMSS,代码行数:46,代码来源:PlayerClass.cs

示例14: validateBuffer

        public override void validateBuffer()
        {
            if (texture != null){
                texture.Dispose();
                texture = null;
            }

            if (vertexBuffer != null){
                vertexBuffer.Dispose();
                vertexBuffer = null;
            }

            if (textfield.text == null || textfield.text.Length == 0){
                dirtyBuffer = false;
                return;
            }

            updateSize();

            float[] verts = new float[8];
            float[] uvs = new float[8];

            int maxWidth = (int) textWidth;
            if (textfield.defaultTextFormat.align == "right"){
                maxWidth = textfield.width;
            }

            verts[0] = (float) OFFSET_X;
            verts[1] = (float) OFFSET_Y;

            verts[2] = (float) OFFSET_X;
            verts[3] = (float) OFFSET_Y + textHeight;

            verts[6] = (float) OFFSET_X + maxWidth;
            verts[7] = (float) OFFSET_Y;

            verts[4] = (float) OFFSET_X + maxWidth;
            verts[5] = (float) OFFSET_Y + textHeight;

            uvs[0] = 0;
            uvs[1] = 0;

            uvs[2] = 0;
            uvs[3] = 1;

            uvs[6] = 1;
            uvs[7] = 0;

            uvs[4] = 1;
            uvs[5] = 1;

            vertexBuffer = new VertexBuffer(4, VertexFormat.Float2, VertexFormat.Float2);
            vertexBuffer.SetVertices(0, verts);
            vertexBuffer.SetVertices(1, uvs);

            int argb = textfield.defaultTextFormat.color;

            var image = new Image(	ImageMode.Rgba,
                                    new ImageSize((int)maxWidth, (int)textHeight),
                                    new ImageColor(0, 0, 0, 0));

            ImagePosition pos = new ImagePosition(0, 0);
            for (int i = 0; i < textLines.Length; i++){
                pos.X = 0;
                pos.Y = i * font.Metrics.Height;

                if (textfield.defaultTextFormat.align == "right"){
                    pos.X = (int) maxWidth - font.GetTextWidth(textLines[i]);
                }

                image.DrawText(
                    textLines[i],
                    new ImageColor((int)((argb >> 16) & 0xff),
                    (int)((argb >> 8) & 0xff),
                    (int)((argb >> 0) & 0xff),
                    255),
                    font,
                    pos
                );
            }

            texture = new Texture2D((int)maxWidth, (int)textHeight, false, PixelFormat.Rgba);
            texture.SetPixels(0, image.ToBuffer());
            texture.SetFilter(TextureFilterMode.Disabled);
            texture.SetWrap(TextureWrapMode.ClampToEdge);
            texture.SetMaxAnisotropy(0);
            image.Dispose();

            dirtyBuffer = false;

            //Console.WriteLine("buffer validated: " + renderable.commands.length);
        }
开发者ID:JimmyDeemo,项目名称:openfl-psm,代码行数:92,代码来源:RendererTextfield.cs

示例15: UpdateImage

		public static void UpdateImage(int score)
		{
			Image image = new Image(ImageMode.Rgba,new ImageSize(960,544),new ImageColor(0,0,0,0));
			Font font = new Font(FontAlias.System,20,FontStyle.Regular);
			image.DrawText("Your Total Score: " + score,new ImageColor(255,255,255,255),font,new ImagePosition(25,125));
			image.Decode();

			//var texture  = new Texture2D(960,544,false,PixelFormat.Rgba);
			//if(textInfo.Texture != null)
				//textInfo.Texture.Dispose();
			//textInfo.Texture = texture;
			//texture.SetPixels(0,image.ToBuffer());
			font.Dispose();
			image.Dispose();
		}
开发者ID:Darth-Arminius,项目名称:Client-Server-Network,代码行数:15,代码来源:SubmitScore.cs


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