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


C# Image.ToBuffer方法代码示例

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


在下文中一共展示了Image.ToBuffer方法的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: 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

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

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

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

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

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

示例10: addToTexture

        private void addToTexture(Image img, Vector2i offset, int[] color)
        {
            data = img.ToBuffer ();

            for (int j=0; j < data.Length/4; j++) {
                if (data[j*4+3] != 0) {
                    if( 255 == data[j*4] && 255 == data[j*4+1] && 255 == data[j*4+2]) {
                        data[j*4] = (Byte)color[0];
                        data[j*4+1] = (Byte)color[1];
                        data[j*4+2] = (Byte)color[2];
                    }
                    var x = j%168 + offset.X;
                    var y = (j-x)/168 - offset.Y;
                    this.TextureInfo.Texture.SetPixels(0,data,PixelFormat.Rgba,j*4,167*4,x,y,1,1);
                }
            }
        }
开发者ID:phoenixperry,项目名称:crystallography,代码行数:17,代码来源:Cube.cs

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

示例12: Sprite

        /// コンストラクタ(文字)
        public Sprite(string text, uint argb, Font font, int positionX, int positionY)
        {
            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();

            SetTexture(texture);
            SetDrawRect(0, 0, texture.Width, texture.Height);

            PositionX = positionX;
            PositionY = positionY;

            CenterX = texture.Width / 2;
            CenterY = texture.Height / 2;
            Degree = 0.0f;

            ScaleX = 1.0f;
            ScaleY = 1.0f;
            Visible = true;
            Alpha	= 1.0f;
        }
开发者ID:hatano0x06,项目名称:Coroppoxus,代码行数:36,代码来源:Sprite.cs

示例13: CreateTextureFromImage

 /// <summary>
 /// imageからテクスチャを生成
 /// </summary>
 /// <returns>
 /// テクスチャ
 /// </returns>
 /// <param name='image'>
 /// image
 /// </param>
 public static Texture2D CreateTextureFromImage(Image image)
 {
     var texture = new Texture2D(image.Size.Width, image.Size.Height, false,	PixelFormat.Rgba);
     texture.SetPixels(0, image.ToBuffer());
     return texture;
 }
开发者ID:noradium,项目名称:Black-Rins-ambition,代码行数:15,代码来源:Convert.cs

示例14: UpdateImage

		public static void UpdateImage(string highScores)
		{
			Image image = new Image(ImageMode.Rgba,new ImageSize(960,544),new ImageColor(0,0,0,0));
			Font font = new Font(FontAlias.System,25,FontStyle.Regular);
			image.DrawText("High Scores: " + highScores,new ImageColor(255,255,255,255),font,new ImagePosition(25,100));
			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,代码来源:LeaderBoard.cs

示例15: UpdateTexture2D

        public void UpdateTexture2D()
        {
            if (null == sm_Texture2D)
            {
                return;
            }
            if (null == Buffer)
            {
                return;
            }
            DateTime now = DateTime.Now;

            long ival_100ns = now.Ticks - m_BaseTime.Ticks;
            int index = (int)((ival_100ns / 10000000.0) / (movie.MicroSecPerFrame / 1000000.0));
            if (movie.TotalFrames <= index) {
                index = movie.TotalFrames -1;
            }

            AviOldIndexEntry entry = movie.VideoEntryList[index];
            int size = entry.Size;
            int offset = entry.Offset;
            BinaryReader reader = new BinaryReader(File.OpenRead(movie.MovieFileDir + "/" + fileName));
            reader.BaseStream.Seek(movie.MoviIndex + 4 + 4 + offset, SeekOrigin.Begin);
            byte[] tmp = reader.ReadBytes(size);
            reader.Close();
            reader.Dispose();

            if (tmp.Length != 0) {
                Image img = new Image(tmp);
                img.Decode();
                Buffer = img.ToBuffer();
                sm_Texture2D.SetPixels(0, Buffer);
                img.Dispose();
            }
        }
开发者ID:khiraiwa,项目名称:psm-avi_movie_player,代码行数:35,代码来源:MoviePlayer.cs


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