jingwood / jingwood/d2dlib

Direct pixel access to D2DBitmap

Open
#110 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
C#
Stars
261
Forks
48
PR merge metrics
No merged PRs in 30d

Description

Hi, is there a way to directly change byte array of D2DBitmap as it's possible in C++ D2D? Something like this in C++:

```cpp
// Assuming you have a valid ID2D1Bitmap* named bitmap
D2D1_BITMAP_PROPERTIES bitmapProperties;
bitmap->GetDpi(nullptr, nullptr);
bitmap->GetPixelFormat(&bitmapProperties.pixelFormat);

UINT32 width, height;
bitmap->GetSize(&width, &height);

UINT32 pixelSize = bitmapProperties.pixelFormat.GetPixelSize();
UINT32 stride = width * pixelSize;

D2D1_MAPPED_RECT mappedRect;
HRESULT hr = bitmap->Map(D2D1_MAP_OPTIONS_READ | D2D1_MAP_OPTIONS_WRITE, &mappedRect);
if (SUCCEEDED(hr))
{
BYTE* pixelData = mappedRect.bits;
// Now you can access and modify the pixel data here

// Make sure to unmap the bitmap when you're done editing
bitmap->Unmap();
}
```
It could help us improve the performance, since every time we call CreateBitmapFromMemory, a new bitmap is created in memory.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by locating the D2DBitmap API and the CreateBitmapFromMemory path, then compare the library's exposed operations with the Direct2D Map and Unmap behavior shown in the issue. Determine the required API and ownership or synchronization rules for mutable pixel data. Done means the supported access path and its performance implications are implemented or clearly documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
computer-graphics, performance
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.