本文整理汇总了C#中System.Drawing.Imaging.BitmapData类的典型用法代码示例。如果您正苦于以下问题:C# BitmapData类的具体用法?C# BitmapData怎么用?C# BitmapData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BitmapData类属于System.Drawing.Imaging命名空间,在下文中一共展示了BitmapData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BltBitmap
public static void BltBitmap(IntPtr dstPixels, Size dstSize,
int dstX, int dstY, int width, int height,
BitmapData srcBD, int srcX, int srcY)
{
Debug.Assert(srcBD.PixelFormat == PixelFormat.Format32bppArgb);
Size srcSize = new Size(srcBD.Width, srcBD.Height);
if (!ModifyRectangle(dstSize, ref dstX, ref dstY, ref width, ref height, srcSize, ref srcX, ref srcY))
{
return;
}
unsafe
{
int dstStride = (dstSize.Width * 4 + 3) / 4 * 4;
Debug.Assert(srcBD.Stride % 4 == 0);
int* dst = (int*)dstPixels + dstX + (dstY * dstStride / 4);
int* src = (int*)srcBD.Scan0 + srcX + (srcY * srcBD.Stride / 4);
int paddingDst = dstStride / 4 - width;
int paddingSrc = srcBD.Stride / 4 - width;
Debug.Assert(0 <= paddingDst);
Debug.Assert(0 <= paddingSrc);
for (int j = 0; j < height; j++, dst += paddingDst, src += paddingSrc)
{
for (int i = 0; i < width; i++, dst++, src++)
{
*dst = *src;
}
}
}
}
示例2: drawClearWithBackground
public static unsafe void drawClearWithBackground(Rectangle srcArea, BitmapData srcData, Rectangle dstArea, BitmapData dstData, BitmapData bgData)
{
if (srcData == null)
return;
int stride1 = srcData.Stride;
int num1 = (int)srcData.Scan0 + srcArea.X * 4 + srcArea.Y * stride1;
if (dstData == null)
return;
int stride2 = dstData.Stride;
int num2 = (int)dstData.Scan0 + dstArea.X * 4 + dstArea.Y * stride2;
if (bgData == null)
return;
int stride3 = bgData.Stride;
int num3 = (int)bgData.Scan0 + dstArea.X * 4 + dstArea.Y * stride3;
int width = srcArea.Width;
int height = srcArea.Height;
for (int index1 = 0; index1 < height; ++index1) {
int num4 = num1 + index1 * stride1;
int num5 = num2 + index1 * stride2;
int num6 = num3 + index1 * stride3;
for (int index2 = 0; index2 < width; ++index2) {
*(PixelData*)num5 = PixelData.overlayPixelData(*(PixelData*)num4, *(PixelData*)num6);
num4 += 4;
num5 += 4;
num6 += 4;
}
}
}
示例3: DrawExteriorAll
public static void DrawExteriorAll(BitmapData data_bac)
{
for (int i = 0; i < STATIONS.Count; i++)
{
STATIONS[i].Draw_Exterior(data_bac);
}
}
示例4: Apply
public virtual Bitmap Apply(BitmapData imageData)
{
if (imageData.PixelFormat != PixelFormat.Format24bppRgb &&
imageData.PixelFormat != PixelFormat.Format32bppArgb &&
imageData.PixelFormat != PixelFormat.Format32bppRgb)
{
throw new ArgumentException();
}
int width = imageData.Width;
int height = imageData.Height;
Bitmap bitmap = new Bitmap(
width, height, PixelFormat.Format24bppRgb);
BitmapData bitmapdata = bitmap.LockBits(
new Rectangle(0, 0, width, height),
ImageLockMode.ReadWrite,
PixelFormat.Format24bppRgb);
NativeMethods.memcpy(
bitmapdata.Scan0,
imageData.Scan0,
imageData.Stride * height);
ProcessFilter(bitmapdata);
bitmap.UnlockBits(bitmapdata);
return bitmap;
}
示例5: EmptyAlphaPixel
/// <summary>
/// Returns try if the given pixel is empty (i.e. alpha is zero)
/// </summary>
public static unsafe bool EmptyAlphaPixel(BitmapData bitmapData, int px, int py, byte alphaEmptyPixelTolerance)
{
byte* addr = (byte*)(bitmapData.Scan0) + bitmapData.Stride * py + px * 4;
return (*(addr + 3) <= alphaEmptyPixelTolerance);
}
示例6: EmptyPixel
/// <summary>
/// Returns try if the given pixel is empty (i.e. black)
/// </summary>
public static unsafe bool EmptyPixel(BitmapData bitmapData, int px, int py)
{
byte* addr = (byte*)(bitmapData.Scan0) + bitmapData.Stride * py + px * 3;
return (*addr == 0 && *(addr + 1) == 0 && *(addr + 2) == 0);
}
示例7: Apply
public void Apply(BitmapData tileset, BitmapData background)
{
if (this.chunklist == null)
return;
foreach (TilesetPatchChunk tilesetPatchChunk in this.chunklist)
tilesetPatchChunk.Apply(tileset, background);
}
示例8: Circle
public static void Circle(BitmapData bmpData, int Size, int X, int Y, Color Colour)
{
CacheCircles(Size);
int tempX;
int i = 0;
for (int tempY = Y - Size; tempY < Y + Size; tempY++)
{
if (tempY >= 0)
{
if (tempY >= bmpData.Height)
{
break;
}
tempX = X - CircleCache[Size][i];
while (tempX < CircleCache[Size][i] + X)
{
if (tempX >= 0)
{
if (tempX >= bmpData.Width)
{
break;
}
IntPtr temp = FindPtr(bmpData, tempX, tempY);
System.Runtime.InteropServices.Marshal.WriteInt32(temp, Colour.ToArgb());
}
tempX++;
}
}
i++;
}
}
示例9: ProcessFilter
// Process the filter
private unsafe void ProcessFilter( BitmapData data )
{
int width = data.Width;
int height = data.Height;
int offset = data.Stride - width * 3;
// do the job
byte * ptr = (byte *) data.Scan0.ToPointer( );
byte t;
// for each line
for ( int y = 0; y < height; y++ )
{
// for each pixel
for ( int x = 0; x < width; x++, ptr += 3 )
{
// rotate colors of each pixel
t = ptr[RGB.R];
ptr[RGB.R] = ptr[RGB.G];
ptr[RGB.G] = ptr[RGB.B];
ptr[RGB.B] = t;
}
ptr += offset;
}
}
示例10: Apply
internal static Bitmap Apply(BitmapData bitmapData1)
{
Bitmap returnMap = new Bitmap(bitmapData1.Width, bitmapData1.Height, PixelFormat.Format32bppArgb);
BitmapData bitmapData2 = returnMap.LockBits(new Rectangle(0, 0,
returnMap.Width, returnMap.Height),
ImageLockMode.ReadOnly,
PixelFormat.Format32bppArgb);
unsafe
{
byte* imagePointer1 = (byte*)bitmapData1.Scan0;
byte* imagePointer2 = (byte*)bitmapData2.Scan0;
for (int i = 0; i < bitmapData1.Height; i++)
{
for (int j = 0; j < bitmapData1.Width; j++)
{
// Standard Invert algorithm
imagePointer2[0] = (byte)(255 - imagePointer1[0]);
imagePointer2[1] = (byte)(255 - imagePointer1[1]);
imagePointer2[2] = (byte)(255 - imagePointer1[2]);
imagePointer2[3] = imagePointer1[3];
//4 bytes per pixel
imagePointer1 += 4;
imagePointer2 += 4;
}
//4 bytes per pixel
imagePointer1 += bitmapData1.Stride - (bitmapData1.Width * 4);
imagePointer2 += bitmapData1.Stride - (bitmapData1.Width * 4);
}
}
returnMap.UnlockBits(bitmapData2);
return returnMap;
}
示例11: Smoother
/// <summary>
/// Creates a new instance of Smoother
/// </summary>
public Smoother(BitmapData inBmpData, byte[] inRgbData, IProgressHandler progHandler)
{
_bmpData = inBmpData;
_rgbData = inRgbData;
_result = new byte[inRgbData.Length];
pm = new ProgressMeter(progHandler, "Smoothing Image", inBmpData.Height);
}
示例12: DrawImg
public void DrawImg()
{
imgData = img.LockBits(
new Rectangle(0, 0, Width, Height),
ImageLockMode.ReadWrite,
PixelFormat.Format32bppArgb);
}
示例13: BeginAccess
/// <summary>
/// Bitmap処理の高速化開始
/// </summary>
public void BeginAccess()
{
// Bitmapに直接アクセスするためのオブジェクト取得(LockBits)
_img = _bmp.LockBits(new Rectangle(0, 0, _bmp.Width, _bmp.Height),
System.Drawing.Imaging.ImageLockMode.ReadWrite,
System.Drawing.Imaging.PixelFormat.Format24bppRgb);
}
示例14: Unlock
/// <summary>
/// Required to use the image after editing.
/// </summary>
public void Unlock()
{
System.Runtime.InteropServices.Marshal.Copy(PixelData, 0, BmpData.Scan0, PixelData.Length);
BitmapImage.UnlockBits(BmpData);
BmpData = null;
PixelData = null;
}
示例15: InitializeBuffer
private void InitializeBuffer()
{
bitmapData = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height),
ImageLockMode.WriteOnly, PixelFormat.Format24bppRgb);
imageBuffer = new byte[bitmapData.Stride * bitmap.Height];
}