本文整理汇总了C#中PaintDotNet.Surface.GetRowAddress方法的典型用法代码示例。如果您正苦于以下问题:C# Surface.GetRowAddress方法的具体用法?C# Surface.GetRowAddress怎么用?C# Surface.GetRowAddress使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PaintDotNet.Surface
的用法示例。
在下文中一共展示了Surface.GetRowAddress方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Render
public unsafe override void Render(Surface dst, System.Drawing.Point offset)
{
if (OwnerList.ScaleFactor < new ScaleFactor(2, 1))
{
return;
}
int[] d2SLookupX = OwnerList.Dst2SrcLookupX;
int[] d2SLookupY = OwnerList.Dst2SrcLookupY;
int[] s2DLookupX = OwnerList.Src2DstLookupX;
int[] s2DLookupY = OwnerList.Src2DstLookupY;
ColorBgra[] blackAndWhite = new ColorBgra[2] { ColorBgra.White, ColorBgra.Black };
// draw horizontal lines
int sTop = d2SLookupY[offset.Y];
int sBottom = d2SLookupY[offset.Y + dst.Height];
for (int srcY = sTop; srcY <= sBottom; ++srcY)
{
int dstY = s2DLookupY[srcY];
int dstRow = dstY - offset.Y;
if (dst.IsRowVisible(dstRow))
{
ColorBgra *dstRowPtr = dst.GetRowAddress(dstRow);
ColorBgra *dstRowEndPtr = dstRowPtr + dst.Width;
dstRowPtr += offset.X & 1;
while (dstRowPtr < dstRowEndPtr)
{
*dstRowPtr = ColorBgra.Black;
dstRowPtr += 2;
}
}
}
// draw vertical lines
int sLeft = d2SLookupX[offset.X];
int sRight = d2SLookupX[offset.X + dst.Width];
for (int srcX = sLeft; srcX <= sRight; ++srcX)
{
int dstX = s2DLookupX[srcX];
int dstCol = dstX - offset.X;
if (dst.IsColumnVisible(dstX - offset.X))
{
byte *dstColPtr = (byte *)dst.GetPointAddress(dstCol, 0);
byte *dstColEndPtr = dstColPtr + dst.Stride * dst.Height;
dstColPtr += (offset.Y & 1) * dst.Stride;
while (dstColPtr < dstColEndPtr)
{
*((ColorBgra *)dstColPtr) = ColorBgra.Black;
dstColPtr += 2 * dst.Stride;
}
}
}
}
示例2: SquishSurfaceTo24Bpp
private unsafe void SquishSurfaceTo24Bpp(Surface surface)
{
byte *dst = (byte *)surface.GetRowAddress(0);
int byteWidth = surface.Width * 3;
int stride24bpp = ((byteWidth + 3) / 4) * 4; // round up to multiple of 4
int delta = stride24bpp - byteWidth;
for (int y = 0; y < surface.Height; ++y)
{
ColorBgra *src = surface.GetRowAddress(y);
ColorBgra *srcEnd = src + surface.Width;
while (src < srcEnd)
{
dst[0] = src->B;
dst[1] = src->G;
dst[2] = src->R;
++src;
dst += 3;
}
dst += delta;
}
return;
}
示例3: CopyFromBitmap
/// <summary>
/// Creates a new Surface and copies the pixels from a Bitmap to it.
/// </summary>
/// <param name="bitmap">The Bitmap to duplicate.</param>
/// <returns>A new Surface that is the same size as the given Bitmap and that has the same pixel values.</returns>
public static Surface CopyFromBitmap(Bitmap bitmap)
{
Surface surface = new Surface(bitmap.Width, bitmap.Height);
BitmapData bd = bitmap.LockBits(surface.Bounds, ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
unsafe
{
for (int y = 0; y < bd.Height; ++y)
{
Memory.Copy((void *)surface.GetRowAddress(y),
(byte *)bd.Scan0.ToPointer() + (y * bd.Stride), (ulong)bd.Width * ColorBgra.SizeOf);
}
}
bitmap.UnlockBits(bd);
return surface;
}