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


C# Texture2D.Save方法代码示例

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


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

示例1: MakeScreenshot

        /// <summary>
        /// Make screenshot
        /// </summary>
        private void MakeScreenshot()
        {
            try
            {
                //NOTE: This doesn't always work on all cards, especially if
                // desktop mode switches in fullscreen mode!

                screenshotNum++;
                // Make sure screenshots directory exists
                if (Directory.Exists(Directories.ScreenshotsDirectory) == false)
                    Directory.CreateDirectory(Directories.ScreenshotsDirectory);

                using (Texture2D dstTexture = new Texture2D(
                    BaseGame.Device,
                    BaseGame.Width, BaseGame.Height, 1,
                    ResourceUsage.ResolveTarget,
                    SurfaceFormat.Color,
                    ResourceManagementMode.Manual))
                {
                    // Get data with help of the resolve method
                    BaseGame.Device.ResolveBackBuffer(dstTexture);

                    dstTexture.Save(
                        ScreenshotNameBuilder(screenshotNum),
                        ImageFileFormat.Jpg);
                } // using
            } // try
            catch (Exception ex)
            {
                Log.Write("Failed to save Screenshot: " + ex.ToString());
            } // catch (ex)
        }
开发者ID:kiichi7,项目名称:SpeedyRacerContentAndSourceCode,代码行数:35,代码来源:ScreenshotCapturer.cs

示例2: DumpPickingBuffer_DEBUG

 public void DumpPickingBuffer_DEBUG(string path, ImageFileFormat format)
 {
     Texture2D tex = new Texture2D(base.ScreenMgr.GraphicsDevice, 800, 600);
     Color[] clrs = new Color[800 * 600];
     for (int i = 0; i < 800; i++)
         for (int j = 0; j < 600; j++)
             clrs[i * 600 + j] = myPickingTexture[i, j];
     tex.SetData<Color>(clrs);
     tex.Save(path, format);
 }
开发者ID:pepster98,项目名称:Project-Dollhouse,代码行数:10,代码来源:IsometricView.cs

示例3: DrawReflectionMap

		private void DrawReflectionMap() {
			Vector3 planeNormalDirection = new Vector3( 0, 1, 0 );
			planeNormalDirection.Normalize();
			Vector4 planeCoefficients = new Vector4( planeNormalDirection, -waterHeight );

			Matrix camMatrix = camera.reflectionView * camera.projection;
			Matrix invCamMatrix = Matrix.Invert( camMatrix );
			invCamMatrix = Matrix.Transpose( invCamMatrix );

			planeCoefficients = Vector4.Transform( planeCoefficients, invCamMatrix );
			Plane reflectionClipPlane = new Plane( planeCoefficients );

			graphics.GraphicsDevice.ClipPlanes[ 0 ].Plane = reflectionClipPlane;
			graphics.GraphicsDevice.ClipPlanes[ 0 ].IsEnabled = true;

			graphics.GraphicsDevice.SetRenderTarget( 0, reflectionRenderTarg );
			graphics.GraphicsDevice.Clear( ClearOptions.Target | ClearOptions.DepthBuffer, Color.Black, 1.0f, 0 );

			if( skybox != null )
				skybox.Draw( camera.reflectionView, camera.projection );

			if( heightmap != null )
				heightmap.Draw( camera.reflectionView, camera.projection );

			graphics.GraphicsDevice.SetRenderTarget( 0, null );
			reflectionMap = reflectionRenderTarg.GetTexture();

			graphics.GraphicsDevice.ClipPlanes[ 0 ].IsEnabled = false;

			if( bSaveReflection ) {
				reflectionMap.Save( "reflectionMap.jpg", ImageFileFormat.Jpg );
				Editor.console.Add( "Reflection jpeg saved." );
				bSaveReflection = false;
			}
		}
开发者ID:GodLesZ,项目名称:svn-dump,代码行数:35,代码来源:Editor.cs

示例4: GenerateSpriteSheet


//.........这里部分代码省略.........
            XnaColor baseColor = XnaColor.Black;
            if (overrideTransColor == true)
            {
                baseColor = new XnaColor(this.BaseTextureColor.R,
                    this.BaseTextureColor.G, this.BaseTextureColor.B, 0);
            }
            uint[] destinationData = new uint[width * height];
            for (int i = 0; i < destinationData.Length; i++)
            {
                destinationData[i] = baseColor.PackedValue;
            }            
            Texture2D spriteSheet = new Texture2D(IceCream.Drawing.DrawingManager.GraphicsDevice,
                width, height);
            foreach (SpriteInfo sprite in this.Sprites)
            {
                Texture2D source = sprite.Texture2D;
                int x = sprite.X;
                int y = sprite.Y;

                int w = source.Width;
                int h = source.Height;

                int b = safeBorderSize;

                int sourceSize = sprite.Texture2D.Width;
                int destSize = width;                
                
                // Copy the main sprite data to the output sheet.
                sprite.CopyPixels(sprite.PixelData, sourceSize, new Rectangle(0, 0, w, h),
                    ref destinationData, destSize, new Point(x + b, y + b),
                    baseColor.PackedValue, overrideTransColor);
                
                // Copy a border strip from each edge of the sprite, creating
                // a padding area to avoid filtering problems if the
                // sprite is scaled or rotated.
                for (int i = 0; i < safeBorderSize; i++)
                {
                    sprite.CopyPixels(sprite.PixelData, sourceSize, new Rectangle(0, 0, 1, h),
                                       ref destinationData, destSize, new Point(x + i, y + b),
                                       baseColor.PackedValue, overrideTransColor);

                    sprite.CopyPixels(sprite.PixelData, sourceSize, new Rectangle(w - 1, 0, 1, h),
                                       ref destinationData, destSize,
                                       new Point(x + w + i + b, y + b), baseColor.PackedValue, overrideTransColor);

                    sprite.CopyPixels(sprite.PixelData, sourceSize, new Rectangle(0, 0, w, 1),
                                       ref destinationData, destSize,
                                       new Point(x + b, y + i), baseColor.PackedValue, overrideTransColor);

                    sprite.CopyPixels(sprite.PixelData, sourceSize, new Rectangle(0, h - 1, w, 1),
                                       ref destinationData, destSize,
                                       new Point(x + b, y + h + i + b), baseColor.PackedValue, overrideTransColor);
                    
                    // Copy a single pixel from each corner of the sprite,
                    // filling in the corners of the padding area.                    
                    for (int j = 0; j < b; j++)
                    {
                        sprite.CopyPixels(sprite.PixelData, sourceSize, new Rectangle(0, 0, 1, 1),
                                           ref destinationData, destSize, new Point(x + j, y + i), baseColor.PackedValue, 
                                           overrideTransColor);
                        sprite.CopyPixels(sprite.PixelData, sourceSize, new Rectangle(0, 0, 1, 1),
                                           ref destinationData, destSize, new Point(x + i, y + j), baseColor.PackedValue,
                                           overrideTransColor);

                        sprite.CopyPixels(sprite.PixelData, sourceSize, new Rectangle(w - 1, 0, 1, 1),
                                       ref destinationData, destSize, new Point(x + w + b + i, y + j),
                                       baseColor.PackedValue, overrideTransColor);
                        sprite.CopyPixels(sprite.PixelData, sourceSize, new Rectangle(w - 1, 0, 1, 1),
                                       ref destinationData, destSize, new Point(x + w + b + j, y + i), baseColor.PackedValue,
                                       overrideTransColor);

                        sprite.CopyPixels(sprite.PixelData, sourceSize, new Rectangle(0, h - 1, 1, 1),
                                       ref destinationData, destSize, new Point(x + i, y + h + b + j), baseColor.PackedValue, 
                                       overrideTransColor);
                        sprite.CopyPixels(sprite.PixelData, sourceSize, new Rectangle(0, h - 1, 1, 1),
                                       ref destinationData, destSize, new Point(x + j, y + h + b + i), baseColor.PackedValue,
                                       overrideTransColor);

                        sprite.CopyPixels(sprite.PixelData, sourceSize, new Rectangle(w - 1, h - 1, 1, 1),
                                           ref destinationData, destSize, new Point(x + w + b + i, y + h + b + j),
                                           baseColor.PackedValue, overrideTransColor);
                        sprite.CopyPixels(sprite.PixelData, sourceSize, new Rectangle(w - 1, h - 1, 1, 1),
                                           ref destinationData, destSize, new Point(x + w + b + j, y + h + b + i), 
                                           baseColor.PackedValue, overrideTransColor);
                    }                 
                }
                sprite.Area = new Rectangle(x + safeBorderSize, y + safeBorderSize, 
                    sprite.Texture2D.Width, sprite.Texture2D.Height);                 
                 
            }
            if (checkBoxAlphaCorrection.Checked == true)
            {
                CorrectAlphaBorders(destinationData, width, height, 2);
            }
            spriteSheet.SetData<uint>(destinationData);
            ImageFileFormat format = (ImageFileFormat)comboBoxFileFormat.SelectedIndex;
            String outputFilename = Path.Combine(outputPath, sheetName + "." + format.ToString().ToLowerInvariant());
            spriteSheet.Save(outputFilename, format);
            ExportXML(Path.Combine(outputPath, sheetName + ".xml"));
        }
开发者ID:schminitz,项目名称:IceCreamXNA,代码行数:101,代码来源:SpriteSheetGenerator.cs


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