Notifications
Clear all
[Closed] [.Net]PictureBox, changing the image
Jul 15, 2015 1:12 am
Hi,
I want for my tool to be able to change the image. I’m not familiar with DOTNET so obviously my code fails:
try(destroyDialog NightmarePublisherGUI)catch()
rollout NightmarePublisherGUI "Nightmare Publisher" width:640 height:370 (
local fileName = ""
local snapshotImage = "Path_to_some_image"
local snapshotJPG = dotNetObject "System.Drawing.Bitmap" snapshotImage
local snapshotRect = dotNetObject "System.Drawing.Rectangle" 0 0 280 280
fn viewport_snapshot imgPath fname frameNum = (
snapshot_name = imgPath + "\\" + fname;
curr_size = getViewSize()
view_size = [280,280]
ratio = curr_size.y/view_size.y
view_size.x = view_size.x * ratio
anim_bmp = bitmap view_size.x view_size.y filename:snapshot_name
sliderTime = frameNum
dib = gw.getViewportDib()
copy dib anim_bmp
save anim_bmp
close anim_bmp
gc()
)
dotNetControl __snapshotIMG "System.Windows.Forms.PictureBox" pos:[320,15] width:280 height:280
dotNetControl __makeImg "System.Windows.Forms.Button" width:280 height:50 pos:[320,310]
on NightmarePublisherGUI open do (
__makeImg.text = "Snapshot View"
)
on __snapshotIMG Paint senderArg paintEventArgs do (
Graphics = paintEventArgs.Graphics
Graphics.DrawImage snapshotJPG snapshotRect
)
on __makeImg Click do (
imagePath = maxFilePath + "publish"
if (doesFileExist imagePath == false) do makeDir imagePath
fileName = (substring maxFileName 1 (maxFileName.count - 4)) + "_info.jpg"
viewport_snapshot imagePath fileName currentTime
newImg = imagePath + "\\" + fileName
snapshotImage = newImg
setProperty snapshotJPG snapshotImage newImg
)
)createDialog NightmarePublisherGUI
especially this line:
setProperty snapshotJPG snapshotImage newImg
This is so maxscript thinking… But I really have no idea how to push it foreward?
Can I use one dotNetControl to change dotNetObject?
How can I change the image instantly after making the preview .jpg?
3 Replies
Jul 15, 2015 1:12 am
does it have to be exactly .net control?
it’s easier to do with image button, bitmap or imgtag rollout controls… and which is more helpful there is a snippet in the mxs help (type in index “image buttons”)
Jul 15, 2015 1:12 am
(
try destroydialog ::RO_VIEWPORT_SNAPSHOT catch()
rollout RO_VIEWPORT_SNAPSHOT "Snapshot" width:496 height:416
(
dotnetcontrol dn_pictureBox "PictureBox" pos:[8,8] width:480 height:360
button bt_open "Open" pos:[8,378] width:112 height:32
button bt_snapshot "Snapshot" pos:[258,378] width:112 height:32
button bt_save "Save" pos:[378,378] width:112 height:32
local snap
fn GetBitmapFromClipboard =
(
if snap != undefined do snap.Dispose()
snap = (dotnetclass "System.Windows.Forms.Clipboard").GetImage()
)
fn GetBitmapFromFile filename =
(
if snap != undefined do snap.Dispose()
snap = dotnetObject "System.Drawing.Bitmap" filename
)
on bt_open pressed do
(
filename = getOpenFileName types:"PNG (*.png)|*.png"
if filename != undefined do dn_pictureBox.image = GetBitmapFromFile filename
)
on bt_snapshot pressed do
(
setclipboardBitmap (gw.getViewportDib())
dn_pictureBox.image = GetBitmapFromClipboard()
)
on bt_save pressed do
(
if snap != undefined do
(
filename = getSaveFileName types:"PNG (*.png)|*.png"
if filename != undefined do snap.Save filename
)
)
)
createdialog RO_VIEWPORT_SNAPSHOT
)
Jul 15, 2015 1:12 am
I didn’t know you can do this with just mxs I assumed I need DOTNET for that.
Actually for what I need a bitmap is just enough!