本文整理汇总了C#中System.Windows.Media.Imaging.BitmapImage.CopyTo方法的典型用法代码示例。如果您正苦于以下问题:C# BitmapImage.CopyTo方法的具体用法?C# BitmapImage.CopyTo怎么用?C# BitmapImage.CopyTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.Imaging.BitmapImage
的用法示例。
在下文中一共展示了BitmapImage.CopyTo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConvertBitmapToTexture
public static Texture2D ConvertBitmapToTexture(BitmapImage bs)
{
var texture2D = new Texture2D(GraphicsDeviceManager.Current.GraphicsDevice, bs.PixelWidth, bs.PixelHeight, false, SurfaceFormat.Color);
bs.CopyTo(texture2D);
return texture2D;
}
示例2: LoadBitmapFromApplicationResources
public static Texture2D LoadBitmapFromApplicationResources(string imageName)
{
var sr = Application.GetResourceStream(new Uri(imageName, UriKind.Relative));
var bs = new BitmapImage();
bs.SetSource(sr.Stream);
var texture2D = new Texture2D(GraphicsDeviceManager.Current.GraphicsDevice, bs.PixelWidth, bs.PixelHeight, false, SurfaceFormat.Color);
bs.CopyTo(texture2D);
return texture2D;
}
示例3: LoadNormalTexture
private void LoadNormalTexture()
{
Debug.Assert( TextureType == TextureType.OneD || TextureType == TextureType.TwoD );
if ( Root.Instance.RenderSystem.ConfigOptions[ "Use Content Pipeline" ].Value == "Yes" )
{
var acm = new AxiomContentManager( (XnaRenderSystem)Root.Instance.RenderSystem, "Content" );
_normTexture = acm.Load<Texture2D>( Name );
_texture = _normTexture;
Width = _normTexture.Width;
Height = _normTexture.Height;
internalResourcesCreated = true;
}
#if !( XBOX || XBOX360 )
else
{
Stream stream;
if ( Name.EndsWith( ".dds" ) )
{
stream = ResourceGroupManager.Instance.OpenResource( Name );
// use Xna to load the image directly from the stream
//XFG.TextureCreationParameters tcp = new XFG.TextureCreationParameters();
//tcp.Filter = Microsoft.Xna.Framework.Graphics.FilterOptions.Triangle;
//tcp.MipLevels = MipmapCount;
//Not sure how to set MipLevels. _normTexture.LevelCount is get-only...
#if SILVERLIGHT
var im = new BitmapImage();
im.SetSource(stream);
_normTexture = new Texture2D(_device, im.PixelWidth, im.PixelHeight, false, SurfaceFormat.Color);
im.CopyTo(_normTexture);
#else
_normTexture = Texture2D.FromStream( _device, stream ); //.FromFile( _device, stream, tcp );
#endif
// store a ref for the base texture interface
_texture = _normTexture;
//reset stream position to read Texture information
////stream.Position = 0;
// set the image data attributes
//Not sure if these lines accomplish the same thing as the below commented-out ones.
SetSrcAttributes( _normTexture.Width, _normTexture.Height, 1,
XnaHelper.Convert( _normTexture.Format ) );
SetFinalAttributes( _normTexture.Width, _normTexture.Height, 1,
XnaHelper.Convert( _normTexture.Format ) );
//XFG.TextureInformation info = XFG.Texture2D.GetTextureInformation( stream );
//SetSrcAttributes( info.Width, info.Height, 1, XnaHelper.Convert( info.Format ) );
//SetFinalAttributes( info.Width, info.Height, 1, XnaHelper.Convert( info.Format ) );
internalResourcesCreated = true;
}
else
{
// find & load resource data intro stream to allow resource group changes if required
stream = ResourceGroupManager.Instance.OpenResource( Name, Group, true, this );
//#if SILVERLIGHT
// if (stream == null)
// {
// Name += ".png";
// stream = ResourceGroupManager.Instance.OpenResource( Name, Group, true, this );
// }
//#endif
var pos = Name.LastIndexOf( "." );
var ext = Name.Substring( pos + 1 );
// Call internal LoadImages, not LoadImage since that's external and
// will determine load status etc again
var image = Image.FromStream( stream, ext );
LoadImages( new[]
{
image
} );
image.Dispose();
}
if (stream != null)
stream.Close();
}
#endif
}