Direct2D: How to get part of a client area as a ID2D1Bitmap

thebluetropics 1,046 Reputation points
2022-10-04T06:34:35.297+00:00

I need to get part of a window's client area as ID2D1Bitmap in Direct2D application.
For example, if a the client area size is 420x320px, how can I get the 100x100px part of the client area? (crop effect)

Also, if this seems impossible with Direct2D, it is okay to use GDI as long as it is compatible with Direct2D (e.g Bitmap can be converted to ID2D1Bitmap afaik)

Regards, @thebluetropics

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,429 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,544 questions
0 comments No comments
{count} votes

Accepted answer
  1. Castorix31 81,831 Reputation points
    2022-10-04T07:01:23.6+00:00

    You can use CreateEffect with CLSID_D2D1Crop, then with GetOutput you get a ID2D1Image that you can draw with DrawImage

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. thebluetropics 1,046 Reputation points
    2022-10-04T12:30:26.633+00:00

    As stated in this thread by Castorix, use CreateCompatibleRenderTarget() and use ID2D1BitmapRenderTarget::GetBitmap()

    0 comments No comments