1

In stead of directly drawing on the screen, I first want to get the pixels which are going to get drawn. Before the drawing, I want to do something with them. So, how can I get an array of those pixels? Will I have to write my own algorithms?

I am trying to make an effect, where polygons intersect. The new polygons resulting from the intersections need to be painted a specific way. Now, you could say, that I need to try to find them, however once the new polygons are drawn, I am not using them for anything else. So, I want to find which pixels are going to be drawn for the first polygons, so I can set the colors of the new polygons pixel by pixel, avoiding the trouble of having to calculate the intersecting areas (as I have searched for algorithms on that, they are hard to implement and kinda slow) - after all, only pixels are going to be drawn.

AlexSavAlexandrov
  • 858
  • 2
  • 13
  • 34
  • Not really possible. You will need to calculate the pixels from the polygon data. – TaW Oct 13 '16 at 17:45
  • You can query the pixels in the graphic and do a double buffer before sending the image to be rendered... but you will only have raster data not polygons when using GDI+. – Matthew Whited Oct 13 '16 at 17:46
  • 1
    If you want better performance you will want to use `.LockBits()` and `.UnlockBits()` and work from the byte array instead of the get/set pixel methods. – Matthew Whited Oct 13 '16 at 17:48
  • 1
    Let me expand on @Matthew's suggestion: You can draw the polygon into a helper bitmap. Then you can access the target and the helper bitmaps in a LockBits routine that loops over the helper, recognizing the coordinates of the drawn pixels and uses them to modify the target. – TaW Oct 13 '16 at 17:54

0 Answers0