本文整理汇总了C#中System.Drawing.UnlockBits方法的典型用法代码示例。如果您正苦于以下问题:C# Drawing.UnlockBits方法的具体用法?C# Drawing.UnlockBits怎么用?C# Drawing.UnlockBits使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing
的用法示例。
在下文中一共展示了Drawing.UnlockBits方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Texture
public Texture(Sdx.Bitmap bmp)
{
// Variables
Sdx.Imaging.BitmapData bmpdata= bmp.LockBits(new Sdx.Rectangle(0, 0, bmp.Width, bmp.Height), Sdx.Imaging.ImageLockMode.ReadOnly, Sdx.Imaging.PixelFormat.Format32bppArgb);
int tid= GL.GenTexture();
GL.BindTexture(TextureTarget.Texture2D, tid);
GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, bmp.Width, bmp.Height, 0, PixelFormat.Bgra, PixelType.UnsignedByte, bmpdata.Scan0);
bmp.UnlockBits(bmpdata);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int) TextureMinFilter.Linear);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int) TextureMagFilter.Linear);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int) TextureWrapMode.Repeat);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int) TextureWrapMode.Repeat);
ID= tid;
bitmap= bmp;
}
示例2: SetImageDataToRawImg
private static void SetImageDataToRawImg(sdr.Bitmap png, RawImgClass p3img)
{
sdr.Imaging.BitmapData bmpData;
p3img.imgData = new byte[(int)(p3img.Width * p3img.Height * ((float)p3img.BitCount / 8))];
bmpData = png.LockBits(new sdr.Rectangle(0, 0, png.Width, png.Height), sdr.Imaging.ImageLockMode.ReadOnly, png.PixelFormat);
sirs.Marshal.Copy(bmpData.Scan0, p3img.imgData, 0, p3img.imgData.Length);
png.UnlockBits(bmpData);
}
示例3: GetTexture
/// <summary>
/// Bitmap → Texture形式に変換する
/// </summary>
/// <param name="dev">XNAのGraphicsDevice</param>
/// <param name="bmp">Bitmap形式の元画像</param>
/// <returns>Texture2D形式の画像</returns>
private static Texture2D GetTexture(GraphicsDevice dev, SD.Bitmap bmp)
{
int[] imgData = new int[bmp.Width * bmp.Height];
Texture2D texture = new Texture2D(dev, bmp.Width, bmp.Height);
unsafe
{
// lock bitmap
SDI.BitmapData origdata =
bmp.LockBits(new SD.Rectangle(0, 0, bmp.Width, bmp.Height), SDI.ImageLockMode.ReadOnly, bmp.PixelFormat);
uint* byteData = (uint*)origdata.Scan0;
// copy data
Marshal.Copy(origdata.Scan0, imgData, 0, bmp.Width * bmp.Height);
byteData = null;
// unlock bitmap
bmp.UnlockBits(origdata);
}
texture.SetData(imgData);
return texture;
}