public static D2D_POINT_2U Point2U([NativeTypeName("UINT32")] uint x = 0, [NativeTypeName("UINT32")] uint y = 0) { D2D_POINT_2U point = new D2D_POINT_2U { x = x, y = y, }; return(point); }
/// <summary> /// Creates an <see cref="ID2D1Bitmap1"/> instance and copies data from a source bitmap. /// </summary> /// <param name="d2D1DeviceContext">The input <see cref="ID2D1DeviceContext"/> instance to use to create the bitmap.</param> /// <param name="d2D1Bitmap">The input <see cref="ID2D1Bitmap1"/> to read data from.</param> /// <param name="d2D1MappedRect">The resulting <see cref="D2D1_MAPPED_RECT"/> for the bitmap.</param> /// <returns>A new <see cref="ID2D1Bitmap1"/> instance.</returns> public static unsafe ComPtr <ID2D1Bitmap1> CreateD2D1Bitmap1Buffer(ID2D1DeviceContext *d2D1DeviceContext, ID2D1Bitmap *d2D1Bitmap, out D2D1_MAPPED_RECT d2D1MappedRect) { D2D_SIZE_U d2DSize = d2D1Bitmap->GetPixelSize(); D2D1_BITMAP_PROPERTIES1 d2DBitmapProperties1Buffer = default; d2DBitmapProperties1Buffer.pixelFormat.format = DXGI_FORMAT.DXGI_FORMAT_B8G8R8A8_UNORM; d2DBitmapProperties1Buffer.pixelFormat.alphaMode = D2D1_ALPHA_MODE.D2D1_ALPHA_MODE_PREMULTIPLIED; d2DBitmapProperties1Buffer.bitmapOptions = D2D1_BITMAP_OPTIONS.D2D1_BITMAP_OPTIONS_CPU_READ | D2D1_BITMAP_OPTIONS.D2D1_BITMAP_OPTIONS_CANNOT_DRAW; using ComPtr <ID2D1Bitmap1> d2D1Bitmap1Buffer = default; // Create a buffer D2D1 bitmap d2D1DeviceContext->CreateBitmap( size: d2DSize, sourceData: null, pitch: 0, bitmapProperties: &d2DBitmapProperties1Buffer, bitmap: d2D1Bitmap1Buffer.GetAddressOf()).Assert(); D2D_POINT_2U d2DPointDestination = default; D2D_RECT_U d2DRectSource = new(0, 0, d2DSize.width, d2DSize.height); // Copy the image from the target to the readback bitmap d2D1Bitmap1Buffer.Get()->CopyFromBitmap( destPoint: &d2DPointDestination, bitmap: d2D1Bitmap, srcRect: &d2DRectSource); fixed(D2D1_MAPPED_RECT *d2D1MappedRectPtr = &d2D1MappedRect) { // Map the buffer bitmap d2D1Bitmap1Buffer.Get()->Map( options: D2D1_MAP_OPTIONS.D2D1_MAP_OPTIONS_READ, mappedRect: d2D1MappedRectPtr).Assert(); } return(d2D1Bitmap1Buffer.Move()); }
public HRESULT Draw(ID2D1Bitmap1 *target, [NativeTypeName("const D2D1_RECT_L *")] RECT *drawRect, [NativeTypeName("D2D1_POINT_2U")] D2D_POINT_2U targetOrigin) { return(((delegate * unmanaged <ID2D1SourceTransform *, ID2D1Bitmap1 *, RECT *, D2D_POINT_2U, int>)(lpVtbl[8]))((ID2D1SourceTransform *)Unsafe.AsPointer(ref this), target, drawRect, targetOrigin)); }