Paul,
As far as just the blank button itself being moved on/off screen, it takes almost no time that I can tell (haven’t officially timed it, though).
But the real test will be how quickly an image can be grabbed of the dialog, and then applied to the button. And also if it can be done at all.
Artur,
If I had done the entire dialog in DotNet, that would be an option, but I’ve come too far at this point using a mix of DotNet and maxscript controls, that it won’t be worth my time simply to eliminate some flickering.
I’m not familiar with using external dll’s, but I’m willing to learn. As long as it was something that was either garanteed to be on every end user’s machine, or I was able to package it with the tool.
That being said, it really seems like DotNot itself would allow some way to grab a screen shot of any arbitray rect on the screen… I just have to find it.
(DotNetClass “system.drawing.Graphics”).CopyFromScreen seems to be the key
There’s a simple code sample in C# here:
http://weblogs.asp.net/jalpeshpvadgama/archive/2008/01/28/how-to-take-screenshot-in-c.aspx
Thanks, Marco! That looks very promising. It’ll take me a bit to figure out how to translate into Maxscript, but I’ll let you know how it turns out when I do.
Thanks so much!
Sure, I’ll give it a try myself when I get some free time, shouldn’t be too hard.
Yikes, can’t wrap my head around all these DotNet objects and classes.
So apparently, first you have to create an image object, and from that you can create a graphics object, which is what has the CopyFromScreen() method? When I try the following code, it just returns “undefined”:
img=(dotNetClass "System.Drawing.Image").fromFile "C:\\someDummyGraphic.tif"
gfx=(DotNetClass "system.drawing.Graphics").fromImage img
screenCap=gfx.CopyFromScreen 0 0 0 0 (dotNetObject "System.Drawing.Size" 100 100)
I haven’t figured out how to make image objects out of thin air, so here I’m building one using the fromFile() method, to pull in a blank .tif file that I made just for testing purposes. The img and gfx variables are being filled with valid values, but the screenCap varaible is just coming back undefined.
Anyone know what I’m doing wrong (and also know how to make image objects without needing an exising external file saved prior)?
Oops, I’m understanding now. The pixels are pasted into the image object stored in img.
img=(dotNetObject "System.Drawing.Bitmap" 100 100)
gfx=(DotNetClass "system.drawing.Graphics").fromImage img
screenCap=gfx.CopyFromScreen 0 0 0 0 (dotNetObject "System.Drawing.Size" 100 100)
gfx.CopyFromScreen 0 0 0 0 (dotNetObject "System.Drawing.Size" 100 100)
img.save "C:\ est.jpg"
Thanks, Marco
So my idea didn’t work. I’m able to now screen cap the dialog’s rect and paste that into a button that’s temporarily scaled to the size of the dialog in order to hide the controls flickering underneath, but in the end it still looks like one big flicker, and the pasted image doesn’t have time to display on the screen. I suspect if I used a timer to spread out the activites into seperate CPU cycles this would work the way I envisioned, but then it will take even longer to redraw the dialog because of the delays added. I might experiment with that at some point, but for now I’ll just live with the flicker.
Thanks all for your input.