dotNet bitmap functions returning undefined

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

Thread Tools Display Modes
  02 February 2018
dotNet bitmap functions returning undefined

Hi everyone.

I'm revisiting an old script that worked without error in Max 2011, but in 2014 and higher it's throwing a lot of exceptions.

Here's a small example:

// Create bitmap
bm = bitmap 28 28 color: (col = ((colorMan.getColor #background)*255)as color) // <-- Sidenote: This is no longer getting the correct button UI color for me either
// Send to clipboard
setclipboardBitmap bm
// Make dotNet bitmap
b = clipboard.GetImage() // Sometimes b is returning undefined, sometimes b is "dotNetObject:System.Drawing.Bitmap"
// Manipulate bitmap
b.RotateFlip (dotnetclass "System.Drawing.RotateFlipType").Rotate90FlipNone // When b returns "dotNetObject:System.Drawing.Bitmap" then the rotate stuff returns undefined :\

Is this happening for anyone else? If so, what changed since 2011 and how can I re-write the code to make it work like before? The weird thing is that sometimes it does work but it's very inconsistent and I'm not well versed enough in dotNet to figure out why :\

I've spent a few days searching and trying to figure it out but I'm not making any progress.
  02 February 2018
This may or may not be related, but at times getting data from the clipboard can at times return undefined.

You can try something like this.

local loadBitmapRetryCount = 4
local loadedImage = undefined
for i = 1 to loadBitmapRetryCount do
   if (undefined == loadedImage) then
      loadedImage = loadBitmapFunction filePath
useBitmapFunction loadedImage
My opinions are not those of my employer.
  02 February 2018
works ok for me

fn dotnetFlipBitmap theBmp =
   setclipboardBitmap theBmp
   b = (dotnetclass "Clipboard").GetImage()
   b.RotateFlip (dotnetclass "System.Drawing.RotateFlipType").RotateNoneFlipXY
   (dotnetclass "Clipboard").SetImage b
bm = bitmap 28 28 color:red
dotnetFlipBitmap bm
  02 February 2018
Originally Posted by Pacermike:
colorMan.getColor #background -- Sidenote: This is no longer getting the correct button UI color for me

That's because since 2017 you're supposed to use #button for button bg color, #background and #window are deprecated in favor of #backgroundOdd.
Scripts :: linkedin
reply share thread

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Society of Digital Artists

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump

All times are GMT. The time now is 09:31 PM.

Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.