yup. Any idea if the function could be fooled into thinking another
graphics object is the screen?
Doubtful. Especially if you are already shy about mixing managed and
unmanaged rendering. Even if possible, I would guess that somehow
impersonating the display video buffer would be orders of magnitude more
difficult than just using unmanaged GDI/GDI+ to do your rendering.
I am using a BufferedGraphicsContext, so I am doing off-screen rendering.
Any particular reason you're doing the double-buffering explicitly? I
have found that simply setting the Control's rendering style to
double-buffered works fine.
In any case, there should be very little difference between using the
BufferedGraphicsContext and simply creating an intermediate bitmap, at
least from an API point of view. I admit, since I'm happy using the
built-in double-buffering, I have basically no experience with the
BufferedGraphicsContext, but I suspect that if it has any advantage over
simply drawing to an intermediate Bitmap instance, it's that it somehow
uses video memory for the frame buffer, rather than system memory.
//BufferedGraphicsContext.Allocate Method (Graphics, Rectangle)
// Allocates a graphics buffer using the pixel format
// of the specified Graphics object.
grafx = appDomainBufferedGraphicsContext.Allocate(this.CreateGraphics(),
new Rectangle( 0, 0, screenHeight, screenWidth*2 ));
// Now you're twice as big
Okay...so you have a Graphics instance that does not actually represent
the screen, which you are drawing to.
Is your reasoning behind expanding the BufferedGraphicsContext that you
can use CopyFromScreen without incurring the video-memory-to-system-memory
performance hit? If so: have you confirmed that there is a significant
performance hit for your usage? and have you confirmed that using
BufferedGraphicsContext avoids that?
In particular, if BufferedGraphicsContext doesn't actually allow you to do
a video-memory-to-video-memory copy, then it's not really getting you
anything except more complication. Even if it does do that, keep in mind
that with PCI-E, there is no longer the terrible asymmetric data bandwidth
going from the video to system memory versus the other direction.
Basically, it seems like you've created a fairly complicated scenario, one
that is no less complicated than would be simply using unmanaged GDI to
composite your bitmaps.
Even if the expansion of the BufferedGraphicsContext does what it seems
like you're hoping it does, you still have to draw all of your data to the
screen sequentially, copying it back to the BufferedGraphicsContext to get
the compositing you want, and then presumably copy the result back to the
screen. You might get that to happen quickly, but I doubt you can get it
to happen quickly enough that the user won't notice (in particular, I'd
expect a fair amount of flickering as the different images get put on the
screen so that you can copy them back to your off-screen Graphics
instance).
[...]
Now, all that said, the underlying source for this enumeration is the
drawing modes found in the native Windows HDC object. So, if what you
want is off-screen drawing that uses something more complex than the
two compositing modes that the Graphics class does offer, that's one
approach.
Don't want to go there.
I messed around trying to mix HDC object calls with managed drawing, it
got extremely complicated very quickly
I don't know what you mean by "extremely complicated", but it sure seems
to me that what you're talking about doing instead is at least as
complicated.
Pete