private void DrawCursorShape(Texture2D texture, OutputDuplicatePointerShapeInformation info, byte[] buffer, int offsetX, int offsetY) { using (var surface = texture.QueryInterface <Surface>()) { //Maps the surface, indicating that the CPU needs access to the data. var rect = surface.Map(SharpDX.DXGI.MapFlags.Write); //Cursors can be divided into 3 types: switch (info.Type) { //Masked monochrome, a cursor which reacts with the background. case (int)OutputDuplicatePointerShapeType.Monochrome: DrawMonochromeCursor(offsetX, offsetY, info.Width, info.Height, rect, info.Pitch, buffer); break; //Color, a colored cursor which supports transparency. case (int)OutputDuplicatePointerShapeType.Color: DrawColorCursor(offsetX, offsetY, info.Width, info.Height, rect, info.Pitch, buffer); break; //Masked color, a mix of both previous types. case (int)OutputDuplicatePointerShapeType.MaskedColor: DrawMaskedColorCursor(offsetX, offsetY, info.Width, info.Height, rect, info.Pitch, buffer); break; } surface.Unmap(); } }
public MaskedColorPointerShape(IntPtr ShapeBuffer, OutputDuplicatePointerShapeInformation ShapeInfo, Direct2DEditorSession EditorSession) : base(ShapeInfo.Width, ShapeInfo.Height, EditorSession) { _maskedShapeBuffer = new byte[Width * Height * 4]; Marshal.Copy(ShapeBuffer, _maskedShapeBuffer, 0, _maskedShapeBuffer.Length); }
public ColorPointerShape(IntPtr ShapeBuffer, OutputDuplicatePointerShapeInformation ShapeInfo, RenderTarget RenderTarget) { _bmp = new Bitmap(RenderTarget, new Size2(ShapeInfo.Width, ShapeInfo.Height), new DataPointer(ShapeBuffer, ShapeInfo.Height * ShapeInfo.Pitch), ShapeInfo.Pitch, new BitmapProperties(new PixelFormat(Format.B8G8R8A8_UNorm, AlphaMode.Premultiplied))); }
public MonochromePointerShape(IntPtr ShapeBuffer, OutputDuplicatePointerShapeInformation ShapeInfo, Direct2DEditorSession EditorSession) : base(ShapeInfo.Width, ShapeInfo.Height / 2, EditorSession) { _andMaskBuffer = new byte[Width * Height / 8]; Marshal.Copy(ShapeBuffer, _andMaskBuffer, 0, _andMaskBuffer.Length); _xorMaskBuffer = new byte[Width * Height / 8]; Marshal.Copy(ShapeBuffer + _andMaskBuffer.Length, _xorMaskBuffer, 0, _xorMaskBuffer.Length); }