Jump to content
  • Advertisement
Sign in to follow this  
devdber

perpixel operations with direct2d

This topic is 2119 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

so, does this api have any means for working with each pixel? Im interested in getpixel/setpixel equivalent. How can i get pointer to d2dbitmap buffer for pixel read/write operations? I tried to implement something like this by means of WIC. But then i need to create d2dbitmap from wic bitmap, i think it's unefficient... is that only possible way i can do it?

 

[spoiler]im sorry for my poor english  sad.png  [/spoiler]

Edited by devdber

Share this post


Link to post
Share on other sites
Advertisement

I haven't worked with D2D yet, but in DX9 you could access the texture data by calling the lock method of its container. There's probably a similar method in the D2D API.

Share this post


Link to post
Share on other sites

Yes, like Khatharr said. That said are you sure you need to have direct per-pixel access? Those kinds of operations are notoriously slow, perhaps you would be better served by using, say, a pixel shader (I assume direct2d can do that too)

Share this post


Link to post
Share on other sites

actually i don't really know the best way i should implement this. I have id2dbitmap. So, how can i apply flood fill algorithm  to this bitmap in pixel shader?

Share this post


Link to post
Share on other sites
You certainly can do flood filling in a pixel shader: Here is a discussion I just found (comes with HLSL snippet). Is it the best approach ? I wonder ... (As an aside: IMO there's rarely "the best", everything has pros and cons).

For a pixel shader you will need so-called ping-pong (using two textures and switching in and output), since one cannot read and write at the same time. I don't know D2D very well, but you will probably have to copy resources back and forth from there, too (pixel shaders operate on D3D10 or D3D11 resources).
 
Since you don't know how "far your flood" will have to go, you can end up with a lot of passes (One could probably use occlusion queries to at least come up with automatic termination). Again I wonder if a CPU approach isn't more practical here (and faster), even if it means copy between CPU and GPU memory.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!