mirror of
https://github.com/storytold/LiveScan3D.git
synced 2026-10-09 00:09:58 +00:00
81 lines
2.7 KiB
C++
81 lines
2.7 KiB
C++
//------------------------------------------------------------------------------
|
|
// <copyright file="ImageRenderer.h" company="Microsoft">
|
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
// </copyright>
|
|
//------------------------------------------------------------------------------
|
|
|
|
// Manages the drawing of image data
|
|
|
|
#pragma once
|
|
|
|
#include <d2d1.h>
|
|
#include "iCapture.h"
|
|
|
|
class ImageRenderer
|
|
{
|
|
public:
|
|
/// <summary>
|
|
/// Constructor
|
|
/// </summary>
|
|
ImageRenderer();
|
|
|
|
/// <summary>
|
|
/// Destructor
|
|
/// </summary>
|
|
virtual ~ImageRenderer();
|
|
|
|
/// <summary>
|
|
/// Set the window to draw to as well as the video format
|
|
/// Implied bits per pixel is 32
|
|
/// </summary>
|
|
/// <param name="hWnd">window to draw to</param>
|
|
/// <param name="pD2DFactory">already created D2D factory object</param>
|
|
/// <param name="sourceWidth">width (in pixels) of image data to be drawn</param>
|
|
/// <param name="sourceHeight">height (in pixels) of image data to be drawn</param>
|
|
/// <param name="sourceStride">length (in bytes) of a single scanline</param>
|
|
/// <returns>indicates success or failure</returns>
|
|
HRESULT Initialize(HWND hwnd, ID2D1Factory* pD2DFactory, int sourceWidth, int sourceHeight, int sourceStride);
|
|
|
|
/// <summary>
|
|
/// Draws a 32 bit per pixel image of previously specified width, height, and stride to the associated hwnd
|
|
/// </summary>
|
|
/// <param name="pImage">image data in RGBX format</param>
|
|
/// <param name="cbImage">size of image data in bytes</param>
|
|
/// <returns>indicates success or failure</returns>
|
|
HRESULT Draw(BYTE* pImage, unsigned long cbImage, std::vector<Body> &bodies);
|
|
|
|
private:
|
|
HWND m_hWnd;
|
|
|
|
// Format information
|
|
UINT m_sourceHeight;
|
|
UINT m_sourceWidth;
|
|
LONG m_sourceStride;
|
|
|
|
// Direct2D
|
|
ID2D1Factory* m_pD2DFactory;
|
|
ID2D1HwndRenderTarget* m_pRenderTarget;
|
|
ID2D1Bitmap* m_pBitmap;
|
|
|
|
/// <summary>
|
|
/// Ensure necessary Direct2d resources are created
|
|
/// </summary>
|
|
/// <returns>indicates success or failure</returns>
|
|
HRESULT EnsureResources();
|
|
|
|
/// <summary>
|
|
/// Dispose of Direct2d resources
|
|
/// </summary>
|
|
void DiscardResources();
|
|
|
|
//void DrawBody(Body &body);
|
|
//void DrawBone(Body &body, JointType joint0, JointType joint1);
|
|
|
|
ID2D1SolidColorBrush* m_pBrushJointTracked;
|
|
ID2D1SolidColorBrush* m_pBrushJointInferred;
|
|
ID2D1SolidColorBrush* m_pBrushBoneTracked;
|
|
ID2D1SolidColorBrush* m_pBrushBoneInferred;
|
|
ID2D1SolidColorBrush* m_pBrushHandClosed;
|
|
ID2D1SolidColorBrush* m_pBrushHandOpen;
|
|
ID2D1SolidColorBrush* m_pBrushHandLasso;
|
|
}; |