本文整理汇总了C#中DataStream类的典型用法代码示例。如果您正苦于以下问题:C#DataStream类的具体用法?C#DataStream怎么用?C#DataStream使用的例子?这里精选的类代码示例或许可以为您提供帮助。
示例1:CopyTextureToBitmap
publicstaticImageCopyTextureToBitmap(D3D.Texture2Dtexture)
{
intwidth=texture.Description.Width;
if(width%16!=0)
width=MathExtensions.Round(width,16)+16;
Bitmapbmp=newBitmap(texture.Description.Width,texture.Description.Height,PixelFormat.Format32bppArgb);
BitmapDatabData=bmp.LockBits(newRectangle(0,0,bmp.Width,bmp.Height),ImageLockMode.WriteOnly,bmp.PixelFormat);
using(DataStreamstream=newDataStream(bData.Scan0,bData.Stride*bData.Height,false,true))
{
DataRectanglerect=texture.Map(0,D3D.MapMode.Read,D3D.MapFlags.None);
using(DataStreamtexStream=rect.Data)
{
for(inty=0;y
(4);
if(x(bytes[2]); //DXGIformatisBGRA,GDIformatisRGBA.
stream.Write(bytes[1]);
stream.Write(bytes[0]);
stream.Write(255);
}
}
}
}
bmp.UnlockBits(bData);
returnbmp;
}
原文链接:http://www.jxszl.com/biancheng/C/556884.html