[Closed] Pastebitmap and progressbar
Hi,
I’m using pastebitmap in my script for dealing with big bitmaps (3000 to 4000k).
Evrything works fine except that it take a “lot” of time even on my coreI7 to process the bitmap.
Meanwhile the script seems to be hanged for the user which sometimes cancel it.
So I’m wondering if there’s a way to display a progress bar of the process which seems to me somehow complicated as there is no obvious way to get the progression of the function i used in pastebitmap. This function is this one :
fn pasteAlpha src1 p1 src2 p2 = (color src1.a src1.a src1.a 255)
A second option could be to display a kind of messagebox without button (and without stoping the script) which would be destroy at the end of the process, but i didn’t find any “infobox”. It could be done with dotnet i think, but I’m really not an expert on the subject.
For now the only way i found is to display a rolloutfloater with createdialog and then destroydialog which is not exactly what i want.
If anybody as an idea
I had the same problem with a distribution script i made, my solution was to work in a different thread of max, so you can take advantage of multithreading, for me it doesnt work as multithread, but i was able to use one thread for my script that was different from the thread of max, so my max UI was not hanged.
LoneRobot has something about that in it’s site, take a look, this is the way i went with my script:
Cheers.
Thanks for answering,
It seems promising (and i’ve learned somethigh here), but i’m not sure it would solve the problem.
Let me explain :
The operation which take time and hang max (which in fact is not really a problem) is a SINGLE pastebitmap operation (in fact the culprit is the pastealpha function). So i have no way to know the progress of the operation until it is complete and i’m pretty sure doing it in another thread won’t solve that problem. The added risk is that if max run in his own thread not hanged the user could easly close the macroscript UI while the operation is processing in another thread.
But I may be wrong.
I imagine i could use get and setpixels in a loop and in that case probably i could use a progressbar, but it’s much slower…
here is a sample taken from MXS help and modified to show progress bar during paste bitmap function:
try(destroydialog rend_rol) catch()
rollout rend_rol "" width:200
(
local count = 0
button rend_bt "Paste Test" width:180
progressbar pb width:180 height:8 offset:[-2,0]
fn compfn c1 p1 c2 p2 =
(
res = c2 --the result will contain the G and B of b2
res.r = c1.r --but the R from b1
count += 1
if mod count 320 == 0 do
(
pb.value = 100.0*(count/320)/240
)
res --then we return the resulting color value
)
on rend_bt pressed do
(
resetMaxFile #noPrompt --start a new scene
theTeapot = teapot wirecolor:white segs:10
theTarget1 = targetObject pos:[-1,0,10]
theCamera1 = TargetCamera pos:[-10,-130,30] target:theTarget1
theTarget2 = targetObject pos:[1,0,10]
theCamera2 = TargetCamera pos:[10,-130,30] target:theTarget2
b1 = bitmap 320 240
b2 = bitmap 320 240
render camera:theCamera1 to:b1 vfb:off
render camera:theCamera2 to:b2 vfb:off
pb.value = count = 0
pastebitmap b1 b2 [0,0] [0,0] type:#function function:compfn
display b2
pb.value = count = 0
)
)
createdialog rend_rol
it should not slow the pasting down dramatically.
Thanks a lot, i’ll give it a try…
But i can’t believe i missed it from the MXS Help.