[Closed] Viewport Grabbing & .Net form transparency
I have some problems with viewport grabbing and Net form TransparencyKey property.
If TransparencyKey property is in form, then form not displaying in screenGrab buffer.
No TransparencyKey – all ok.
There are some screenshots and sample code
http://screencast.com/t/7Sm6dbeMg7
Any Ideas? thanks.
(
(
try(form.close())catch()
form=dotNetObject "form"
form.TopMost=true -- Transparency
form.backColor=(dotNetClass "system.drawing.color").fromArgb 128 128 128 --back color
-- form.TransparencyKey=(dotNetClass "system.drawing.color").fromArgb 128 128 128
lb1=dotNetObject "label"
lb1.bounds=dotNetObject "system.drawing.rectangle" 0 0 200 200
lb1.backColor=(dotNetClass "system.drawing.color").red
lb1.Text = "BLABLABLA"
form.controls.add lb1
maxw = dotnetobject "MaxCustomControls.Win32HandleWrapper" (dotnetobject "System.IntPtr" (Windows.GetMAXHWND()))
form.show(maxw)
form.refresh()
)
------------------------
sleep 1
display (viewport.getViewportDib())
try(form.close())catch()
)
Well for BackColor, since its ARGB, maybe try doing 128 128 128 0. 0 being black/no visibility?
You want to see the outside of the window/form still right?
Edit: Nevermind,
-- Runtime error: dotNet runtime exception: Control does not support transparent background colors.
why do you think that viewport.getViewportDib has to grab popup dialogs? it grabs the active viewport only.
hmm…
viewport.getViewportDib grabs dialogs
gw.getViewportDib – don’t
Am I doing something wrong?
http://screencast.com/t/7Sm6dbeMg7
there are two screen grabs (not printscreens)
if you want to grab the screen why do you grab a viewport? you can find a lot of samples on this forum how to grab a screen using .NET
—why do you grab a viewport?
Because it was very simple with viewport.getViewportDib method… until there are no TransparencyKey in the dotnet form.
Yes I want to grab a viewport WITH .net form (with tranparency) over this viewport ; and maybe it is screen grabbing, not viewport
okay, I’ll try to search more.
what version of max do you use? since max 2009 both methods grab the viewport only as I remember…
2009X32 , and I’cant test now on another versions…
I found this sample
(
img=(dotNetObject “System.Drawing.Bitmap” 1000 1000)
gfx=(DotNetClass “system.drawing.Graphics”).fromImage img
screenCap=gfx.CopyFromScreen 0 0 0 0 (dotNetObject “System.Drawing.Size” 1000 1000)
gfx.CopyFromScreen 0 0 0 0 (dotNetObject “System.Drawing.Size” 1000 1000)
img.save “C:\ est.jpg”
)
CopyFromScreen method – is it vewport grabbing? or screen grabbing? because I have similar results as viewport.getViewportDib method – no form in screengrab file (if TransparencyKey is in form). And if I delete TransparencyKey string – all ok
i don’t see any problem with or without transparency key:
form = dotnetobject "Form"
form.Text = "Transparency Test - " + timestamp() as string
form.BackColor = form.BackColor.LightGray
form.TransparencyKey = form.BackColor
form.StartPosition = form.StartPosition.Manual
form.Bounds = dotnetobject "System.Drawing.Rectangle" 100 100 320 240
maxw = dotnetobject "MaxCustomControls.Win32HandleWrapper" (dotnetobject "System.IntPtr" (Windows.GetMAXHWND()))
form.show maxw
forcecompleteredraw()
--[color=Yellow]user32.SetAllWindowRedraw (Windows.GetMAXHWND())[/color]
bm = dotnetobject "System.Drawing.Bitmap" 640 640
gr = (dotnetclass "System.Drawing.Graphics").FromImage bm
gr.CopyFromScreen 0 0 0 0 (dotnetobject "System.Drawing.Size" 480 480)
file = getDir #temp + @"\grab.bmp"
bm.Save file (dotnetclass "System.Drawing.Imaging.ImageFormat").Bmp
gr.Dispose()
bm.Dispose()
display (openbitmap file)
try(form.Close())catch()
i'm using my function to force max redraw but as I know it might be any...
forcecompleteredraw() for example...
Thanks for reply and sample, Denis. I replaced your magic function by forcecompleteredraw(),
Also I’ve tested It on max 11-12
it doesn’t work, sorry)). :surprised
http://screencast.com/t/kut7GXCEqYuO screen
All my maxes are broken?? :applause:
i don’t know what to say… hmm… make a snippet that doesn’t work as expected… and i think many warriors of this order will be happy to get a chance to kick max’s butt