本文整理汇总了C#中Android.Graphics.Bitmap.LockPixels方法的典型用法代码示例。如果您正苦于以下问题:C# Bitmap.LockPixels方法的具体用法?C# Bitmap.LockPixels怎么用?C# Bitmap.LockPixels使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android.Graphics.Bitmap
的用法示例。
在下文中一共展示了Bitmap.LockPixels方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CopyPixelDataToBitmap
/// <summary>
/// Copies the pixel data to bitmap, data assumed to be in ARGB format so it will be trasformed to the internal Android ABGR format that bitmaps use while copying.
/// </summary>
/// <param name="targetBitmap">The target bitmap.</param>
/// <param name="data">The data.</param>
/// <param name="stride">The stride, bitmap width in pixels.</param>
public static void CopyPixelDataToBitmap(Bitmap targetBitmap, int[] data, int stride)
{
if (targetBitmap != null)
{
IntPtr ptr = targetBitmap.LockPixels();
unchecked
{
int value;
int[] strideArray = new int[stride];
for (int i = 0; i < data.Length; i += stride)
{
for (int j = 0, k = i; j < stride; ++j, ++k)
{
value = data[k];
strideArray[j] =
(int)
((0xFF000000) | ((value & 0xFF) << 16) | (value & 0x0000FF00) | ((value >> 16) & 0xFF));
}
Marshal.Copy(strideArray, 0, ptr + (i << 2), stride);
}
}
targetBitmap.UnlockPixels();
}
}
示例2: FastBitmap
public FastBitmap(Bitmap bitmap, bool cleanSlate = false)
{
int byteCount = bitmap.Width * bitmap.Height * bpp;
_bytes = new byte[byteCount];
_bitmap = bitmap;
_scan0 = bitmap.LockPixels();
if (!cleanSlate)
Marshal.Copy(_scan0, _bytes, 0, byteCount);
}
示例3: FixSize
private void FixSize()
{
int width, height;
GetPlatformWindowSize(out width, out height);
if (Width == width && Height == height)
return;
Width = width;
Height = height;
if (Surface != null)
{
Surface.Dispose();
}
if (_bitmap != null)
{
_bitmap.Dispose();
}
_bitmap = Bitmap.CreateBitmap(width, height, Bitmap.Config.Argb8888);
Surface = SKSurface.Create(width, height, SKImageInfo.PlatformColorType, SKAlphaType.Premul, _bitmap.LockPixels(), width * 4);
}