Platforms to show: All Mac Windows Linux Cross-Platform

Back to Picture class.

Picture.isGrayMBS(tolerance as Integer = 0) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Graphics & Pictures MBS Picture Plugin 12.5 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Checks if a picture has only shades of gray in all pixels.
Example
dim p as new Picture(100,100,32)

// 1. test white picture

if p.isGrayMBS then
MsgBox "white picture is gray."
end if

// 2. test gray picture
dim g as Graphics = p.Graphics
g.ForeColor = &c777777
g.FillRect 0, 0, 100, 100

if p.isGrayMBS then
MsgBox "gray picture is gray."
end if

// 3. test gray picture with tolerance
g.ForeColor = &c777778
g.FillRect 0, 0, 100, 100

if p.isGrayMBS(0) then
MsgBox "gray (not correct)"
else
MsgBox "not gray (correct)"
end if

if p.isGrayMBS(1) then
MsgBox "gray (correct)"
else
MsgBox "not gray (not correct)"
end if

// 4. test gray picture with over tolerance
g.ForeColor = &c777779
g.FillRect 0, 0, 100, 100

if p.isGrayMBS(0) then
MsgBox "gray (not correct)"
else
MsgBox "not gray (correct)"
end if

if p.isGrayMBS(1) then
MsgBox "gray (not correct)"
else
MsgBox "not gray (correct)"
end if

Tolerance defines how big the difference between two channels can be. Typically a value smaller than 5. Pass 0 if you need exact gray scales.
Like the difference between &c000000 and &c000001 is not visible to most people, it can be ignored often.

See also:

Picture.isGrayMBS(tolerance as Integer, left as Integer,top as Integer,width as Integer,height as Integer) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Graphics & Pictures MBS Picture Plugin 12.5 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Checks if a picture has only shades of gray in all pixels.

Tolerance defines how big the difference between two channels can be. Typically a value smaller than 5. Pass 0 if you need exact gray scales.
Like the difference between &c000000 and &c000001 is not visible to most people, it can be ignored often.

See also:

Blog Entries

The items on this page are in the following plugins: MBS Picture Plugin.


The biggest plugin in space...