View Full Version : I don't know how to use this, plase help me to understand the help!

02-16-2009, 07:14 PM
Please, be patience, i'm really newbie.

I don't know how to use this:


CompareBitmaps {<filename>File1 | <bitmap>bitmap1} {<filename>File2 | <bitmap>bitmap2} \
<int>tolerance(# different pixels) <int>variation(0-255) \
useAlpha:<boolean> errorMsg:<&string>


I'm trying this script:


bm01 = bitmap renderWidth renderHeight filename:"c:\\temp\\tem_01.tif"
bm00 = bitmap renderWidth renderHeight filename:"c:\\temp\\tem_00.tif"

print (CompareBitmaps bm01 bm00)


And the output is this:


-- Error occurred in anonymous codeblock; filename: E:\3dsMax2009\Scripts\Juan\; position: 183
-- Frame:
-- Argument count error: CompareBitmaps wanted 4, got 2


I want to use the result of bitmapCompare function inside an if expression.

I think that i have a problem because i don't really understand the explanation.

For example:

{<filename>File1 | <bitmap>bitmap1}

What does mean the {} and why the filename is inside <> and the File1 is not, and why is this simbol too "|" ????

also after that there is a "\" does this mean something?

and this:

<int>tolerance(# different pixels) <int>variation(0-255) \
useAlpha:<boolean> errorMsg:<&string>

It's self explanatory that i'm not understanding the most basic comprehension of the programming help file.

Please help me to understand the help.

02-16-2009, 07:51 PM
Ok, i think i understand a bit more the expressions of the explanations of the commands.

But as far as i understand the function "CompareBitmaps bm01 bm00" it's ok

Why i'm getting this output?
Why is the CompareBitmaps asking me for 2 more arguments?

Sorry for the inconvenience, be patience, all the programming stuff is new for me and i'm a bit ashame questioning so much, i don't want you to beleive that i don't look for help in the help, but sometimes it's hard to find what i need :)

Cheers and Thanks!

02-16-2009, 08:50 PM
Now if i put this string i get "true" output when the pictures are the same and when not too :p

Please, i'am stucked in this all this evening, and i'm sure that is quite simple, somone explain me what does this mean

CompareBitmaps bm00 bm01 0 1


02-16-2009, 09:07 PM
Ok, i found a workaround but if someone can explain me the CompareBitmaps i'll apreciate so much.
Here is the workaround, comparing File Sizes

F01 = getFileSize "c:\\temp\\tem_00.tif"
F00 = getFileSize "c:\\temp\\tem_02.tif"

fn compareb = (if F00 == F01 then (Print "·EUREKA") else (Print "leches"))


Still hope someone can explain the workflow with CompareBitmaps

Cheers :D

02-16-2009, 09:14 PM
CompareBitmaps {<filename>File1 | <bitmap>bitmap1} {<filename>File2 | <bitmap>bitmap2} \
<int>tolerance(# different pixels) <int>variation(0-255) \
useAlpha:<boolean> errorMsg:<&string>
This function expects 4 arguments, and 2 optional (keyword) arguments. The first part {<filename>File1 | <bitmap>bitmap1} tells you that you can choose (indicated by the pipe character |) to supply either a filename or a bitmap value. Same goes for the second part {<filename>File2 | <bitmap>bitmap2}. The 3rd and 4th expect integer values, the documentation for this method tells you what they are for.

The last two useAlpha:<boolean> errorMsg:<&string> are keyword arguments (recognized by the column, where the first part is the argument name, and the second part (after the column) is the argument value. These arguments are not required when you call the method. When the caller doesn't specify them, they are given a 'default' value by the method. The documentation tells you what the default values are for any method that uses keyword arguments.

The second keyword argument errorMsg:<&string> is a special case, namely a by-reference argument (recognized by the ampersand &). Such an argument is passed as an 'instance' (in layman's terms) meaning that when the method changes the value of that variable it will in fact change the original variable that you supplied.

So, an example:
local myErrorMsg
CompareBitmaps someBitmap1 someBitmap2 20 5 errorMsg:&myErrorMsg
-- The method returns true if the bitmaps were considered identical
-- and false otherwise. Since a method can only return a single value,
-- the by-reference argument errorMsg:<&string> is used
-- to store information about why the method returned true or false.
-- So the variable myErrorMsg will contain more detailed information
-- about the method's result.
print myErrorMsg
Be sure to check out the topic "Syntax Definitions in This Document" in the maxscript manual. The symbols that are used throughout the documentation are explained in this topic.

Also, the "By Reference Parameter Passing" topic explains how to work with by-reference arguments.

Hope this helps,

02-16-2009, 09:29 PM
Thanks Magicm!

I checked "Syntax Definitions in This Documents" for the second post but i could not understand the 3rd and the 4th values, now i think i understand thank to you.

but i have a question:

In my third post i posted the script i had to check, and the values are 0 and 1, i think this values are the maximun number of pixels that can be different and the maximun variation to define those pixels as different, ok, but in the script i posted i had two pictures that are extremly diferent

bm00 was a 2 by 2 pixels black bitmap
bm01 was a 720x405 "marvelous" teapot render

So why the test keep telling me that the result is true?

And when i had for the test both bitmaps of 2 by 2 pixels black the test says True also, i cannot understand this.

Thanks!!! :D

02-16-2009, 09:40 PM
TIn my third post i posted the script i had to check, and the values are 0 and 1, i think this values are the maximun number of pixels that can be different and the maximun variation to define those pixels as different, ok, but in the script i posted i had two pictures that are extremly diferent
A value of 0 for <int>tolerance(# different pixels) makes no sense as it would cause the method to return true on any two bitmaps. This value indicates how many pixels must be different before the comparison fails. So you should use a value of at least 1.


02-16-2009, 09:50 PM
Ok, i understand now.

I'm going to test it

Thanks!! :D

CGTalk Moderation
02-16-2009, 09:50 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.