Xojo Conferences
MBSSep2018MunichDE
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

Next items

Picture.AddSteganographyMBS(flags as Integer, data as Memoryblock) as Picture
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Graphics & Pictures MBS Picture Plugin 14.2 Yes Yes Yes Yes No
Function: Adds steganography to a new picture.
Example:
dim p as Picture = LogoMBS(500)
// this example uses chr(0) as end marker
dim s as string = "Hello World. This is just a test." + chr(0)
dim pic as Picture = p.AddSteganographyMBS(1, s)

dim data as MemoryBlock = pic.SteganographyMBS(1)
dim d as string = data.CString(0)

MsgBox d
Notes:
Flags can be a combination of red (&h100), green (&h010) and blue (&h001).
Returns a new picture or nil. The existing picture is not modified.

If you like to store data, please encrypt them and include some way that you find your data again, detect length of data, verify it's okay via checksum and than decrypt your data.
Please store image in a loss less format like PNG.
Function does not handle mask or alpha channel.

Feedback, Comments & Corrections

Picture.AddSteganographyPictureMBS(flags as Integer, data as Picture) as Picture
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Graphics & Pictures MBS Picture Plugin 16.2 Yes Yes Yes Yes No
Function: Adds steganography to a new picture.
Example:
const AllChannels = &h111

dim p as new Picture(500, 500, 32)

dim w as new window1
w.Title = "white"
w.Backdrop = p

dim l as Picture = LogoMBS(500)

w = new window1
w.Title = "Logo"
w.Backdrop = l

// adds picture. You will normally not see the modification
dim x as Picture = p.AddSteganographyPictureMBS(AllChannels, l)

w = new window1
w.Title = "Logo hidden in white picture"
w.Backdrop = x

// as we store in lowest bit, this picture will look strange
dim y as Picture = x.SteganographyPictureMBS(AllChannels)

w = new window1
w.Title = "Logo extracted"
w.Backdrop = y
Notes:
Flags can be a combination of red (&h100), green (&h010) and blue (&h001).
Returns a new picture or nil. The existing picture is not modified.

Function does not handle mask or alpha channel.

Some examples which use this method:

Feedback, Comments & Corrections

Picture.AutoLevelCopyMBS as picture
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Graphics & Pictures MBS Picture Plugin 9.2 Yes Yes Yes Yes No
Function: Applies auto levels on the picture.
Notes:
The histogram is built, white and back points are searched and all pixels adjusted.
Returns nil on any error.
Thanks to Jeff Thoman for his code.

This version of the method makes a copy of the picture so it works on any kind of picture.

Renamed in version 9.2 from AutoLevelMBS to AutoLevelCopyMBS.

Feedback, Comments & Corrections

Picture.AutoLevelMBS as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Graphics & Pictures MBS Picture Plugin 9.1 Yes Yes No Yes No
Function: Applies auto levels on the picture.
Notes:
The histogram is built, white and back points are searched and all pixels adjusted.
Returns true on success and false on any error.
Thanks to Jeff Thoman for his code.

This version of the method modifies the pixels on the picture. Works on 32bit and 24bit pictures.

If you get a type mismatch error on using this function, you may want to use AutoLevelCopyMBS which is the old behavior.

Feedback, Comments & Corrections

Picture.BitmapMBS as picture
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Graphics & Pictures MBS Picture Plugin Yes Yes Yes Yes No
Function: Returns the picture as a bitmap picture.
Example:
dim p,r as picture
r=LogoMBS(500)
p=r.BitmapMBS
canvas1.backdrop=p
Notes:
A Realbasic picture object may contain an icon, a bitmap, a picture handle or something else what Realbasic will support as a picture in the future.
The picture editing functions of this plugin can only work with bitmap pictures and this clone function creates such pictures for you.
This function takes a look on the picture and returns it unchanged if it is allready a bitmap, but if not, the picture is Cloned as a bitmap. If you prefer to get a copy of the picture as a bitmap picture, use clone instead.

app.resourceFork.getpicture(148) is the about picture of REALbasic in the 4.5 release. This may change in future releases, so you will get nil. But using this picture will make the plugin download smaller.

The Cloned picture does not have a mask.

Some examples which use this method:

Feedback, Comments & Corrections

BlendPicturesMBS(source as picture, sourcepercent as Double, dest as picture, destpercent as Double) as picture
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
global method Graphics & Pictures MBS Picture Plugin 4.3 Yes Yes Yes Yes No
Function: Blends two pictures.
Example:
dim a,b,c as picture

a=newpicture(100,100,32)
b=newpicture(100,100,32)
' ... draw something in a and b
c=newpicture(100,100,32)
c=BlendPicturesMBS(a,0.5,b,0.5)
Notes:
Percent is in range from 0 to 1. Values out of this range may work, but you get strange results.

Reason for returning nil:
- One of the two pictures used is nil.
- One of the pictures is not a 32bit bitmap picture.
- The two parameter pictures have not the same size as the others.

Some examples using this method:

Feedback, Comments & Corrections

BlendPicturesWithMaskMBS(source as picture, dest as picture, mask as picture) as picture
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
global method Graphics & Pictures MBS Picture Plugin 4.3 Yes Yes Yes Yes No
Function: Blends two pictures.
Example:
dim a,b,c,m as picture

a=newpicture(100,100,32)
b=newpicture(100,100,32)
m=newpicture(100,100,32)
' ... draw something in a and b
c=BlendPicturesWithMaskMBS(a,b,m)
Notes:
The mask defines how much from one picture is used.

Reason for returning false:
- One of the three pictures used is nil.
- One of the pictures is not a 32bit bitmap picture.
- The three parameter pictures have not the same size as the others.

Some examples using this method:

Feedback, Comments & Corrections

Picture.BlueChannelMBS as picture
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Graphics & Pictures MBS Picture Plugin 11.0 Yes Yes Yes Yes No
Function: The blue channel of the picture copied into a new picture.
Example:
dim p as Picture = LogoMBS(500)
Backdrop = p.BlueChannelMBS

Feedback, Comments & Corrections

Picture.BlurMBS(Radius as Double, yield as Integer = 0) as picture
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Graphics & Pictures MBS Picture Plugin 10.3 Yes Yes Yes Yes No
Function: Applies a blur effect to the image.
Example:
dim p as Picture = LogoMBS(500)
window1.Backdrop = p.BlurMBS(2)
Notes:
This is not a gaussian blur, but a faster box blur.
Returns nil on any error.

Some examples which use this method:

Feedback, Comments & Corrections

Picture.CalcSteganographyMBS(flags as Integer) as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Graphics & Pictures MBS Picture Plugin 14.2 Yes Yes Yes Yes No
Function: Calculates the steganography size.
Example:
dim p as Picture = LogoMBS(500)

dim size1 as Integer = p.CalcSteganographyMBS(&h100)
MsgBox "Red only: "+str(size1)

dim size2 as Integer = p.CalcSteganographyMBS(&h111)
MsgBox "RGB only: "+str(size2)
Notes:
Returns number of bytes that can be stored in an image of the size of this picture.
Flags can be a combination of red (&h100), green (&h010) and blue (&h001).

Feedback, Comments & Corrections

Picture.cloneMBS as picture
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Graphics & Pictures MBS Picture Plugin Yes Yes Yes Yes No
Function: Clones the picture as a bitmap.
Example:
dim p,r as picture
r=LogoMBS(500)
p=r.clonembs
canvas1.backdrop=p
Notes:
A Realbasic picture object may contain an icon, a bitmap, a picture handle or something else what Realbasic will support as a picture in the future.
The picture editing functions of this plugin can only work with bitmap pictures and this clone function creates such pictures for you.
If a picture is a bitmap can be easily tested with the graphics property like this:

if p.graphics=nil then // if no bitmap
p=p.clonembs // make one
end if

app.resourceFork.getpicture(148) is the about picture of REALbasic in the 4.5 release. This may change in future releases, so you will get nil. But using this picture will make the plugin download smaller.

The Cloned picture does not have a mask.
See FAQ entry "How to duplicate a picture with mask or alpha channel?" on how to duplicate with mask.

See also:

Some examples which use this method:

Feedback, Comments & Corrections

Picture.CloneMBS(width as Integer, height as Integer) as picture
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Graphics & Pictures MBS Picture Plugin 7.0 Yes Yes Yes Yes No
Function: Clones the picture as a bitmap with given size.
Example:
dim p,r as picture
r=LogoMBS(500)
p=r.clonembs(100,100)
canvas1.backdrop=p
Notes:
A Realbasic picture object may contain an icon, a bitmap, a picture handle or something else what Realbasic will support as a picture in the future.
The picture editing functions of this plugin can only work with bitmap pictures and this clone function creates such pictures for you.
If a picture is a bitmap can be easily tested with the graphics property like this:

if p.graphics=nil then // if no bitmap
p=p.clonembs // make one
end if

app.resourceFork.getpicture(148) is the about picture of REALbasic in the 4.5 release. This may change in future releases, so you will get nil. But using this picture will make the plugin download smaller.

The Cloned picture does not have a mask or alpha channel.
See FAQ entry "How to duplicate a picture with mask or alpha channel?" on how to duplicate with mask.

See also:

Some examples which use this method:

Feedback, Comments & Corrections

Picture.ColorizeMBS(hue as Double, sat as Double, light as Double) as picture
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Graphics & Pictures MBS Picture Plugin 12.5 Yes Yes Yes Yes No
Function: Colorizes a picture.
Notes:
Hue, Sat and Light in range 0.0 to 1.0 please.
Returns new picture.

Some examples which use this method:

Feedback, Comments & Corrections

Picture.ColornessMBS(threshold as Integer = 10) as Double
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Graphics & Pictures MBS Picture Plugin 12.0 Yes Yes Yes Yes No
Function: Calculates the color coverage of the picture.
Example:
dim file as FolderItem = SpecialFolder.Desktop.Child("test.png")
dim pic as Picture = Picture.Open(file)

MsgBox str(pic.ColornessMBS)
Notes:
Counts how many pixels have color and returns percentage depending on a given threshold.
Changed in 12.3pr5 to ignore nearly black pictures when counting.

Feedback, Comments & Corrections

CombinePicturesMBS(red as picture, blue as picture, green as picture) as picture
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
global method Graphics & Pictures MBS Picture Plugin 4.3 Yes Yes Yes Yes No
Function: Combines the red, green and blue channels of three images into the a new one.
Notes: Returns nil on any error.

Feedback, Comments & Corrections

Picture.CombinePixelMBS(Mode as Integer, SecondPicture As Picture) as picture
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Graphics & Pictures MBS Picture Plugin 9.7 Yes Yes Yes Yes No
Function: Combines pixels of two images with the given mode.
Example:
dim pic as picture // some picture
dim other as picture // some other picture
dim result as picture = pic.CombinePixelMBS(1, other)

// effects are made like this. If you have a suggestion for a new effect,
// send your suggestion to MBS support:
Function Combine(x as color, y as color) As color
Return rgb(x.red+y.red, x.green+y.green, x.blue+y.blue)
End Function
Notes:
Each pixel is sent through an operation.

Modes:
1Average (50% first and 50% second picture)
2Gray
3LighterPixel
4DarkerPixel
5Difference Max
6Difference Max Squared

Some examples which use this method:

Feedback, Comments & Corrections

Picture.CompareBrightnessMBS(other as picture, mode as Integer, threshold as Integer) as Double
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Graphics & Pictures MBS Picture Plugin 10.1 Yes Yes Yes Yes No
Function: Compares two pictures in brightness.
Example:
dim p as picture = newPicture(100,100,32)
dim q as Picture = NewPicture(100,100,32)

dim diff as Double = p.CompareBrightnessMBS(q, 0, 0)

MsgBox str(Diff) // shows 0 = equal
Notes:
Returns the percent of difference: Number of pixels where the squared color difference is bigger than the threshold divided by the total number of pixels.
If width and height are not equal, the result is 1.0.
If you need to check the mask also, please call this method a second time for the masks.

Modes:
0y = 0.33 * R + 0.5 * G + 0.16 * BFaster version of 3
1y = 0.375 * R + 0.5 * G + 0.125 * BFaster version of 3
2y = 0.2126 * R + 0.7152 * G + 0.0722 * BPhotometric/digital ITU-R
3y = 0.299 * R + 0.587 * G + 0.114 * BDigital CCIR601

Mode 2 and 3 uses doubles and mode 0 and 1 use integers so they should be faster.
Still Mode 0 and 1 are just approximation formulas which trade accuracy for perfomance.

Only compares raw pixels without checking mask or alpha channel.

Feedback, Comments & Corrections

Picture.CompareMBS(other as picture, threshold as Integer) as Double
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Graphics & Pictures MBS Picture Plugin 10.1 Yes Yes Yes Yes No
Function: Compares two pictures.
Example:
dim p as picture = newPicture(100,100,32)
dim q as Picture = NewPicture(100,100,32)

dim diff as Double = p.CompareMBS(q, 0)

MsgBox str(Diff) // shows 0 = equal

p.Graphics.ForeColor = &cFF0000
p.Graphics.FillRect 0, 0, p.Width, p.Height

q.Graphics.ForeColor = &cFF0001
q.Graphics.FillRect 0, 0, q.Width, q.Height

dim diff1 as Double = p.CompareMBS(q, 0)
dim diff2 as Double = p.CompareMBS(q, 2)

MsgBox str(Diff1)+" "+str(Diff2) // shows 1 (all pixels different) and shows 0 (all equal)
Notes:
Returns the percent of difference: Number of pixels where the squared color difference is bigger than the threshold divided by the total number of pixels.
If width and height are not equal, the result is 1.0.
If you need to check the mask also, please call this method a second time for the masks.

Only compares raw pixels without checking mask or alpha channel.

Feedback, Comments & Corrections

Picture.CopyABGRtoMemoryblockMBS(destination as memoryblock, offset as Integer, AlphaValue as Integer, StartLine as Integer = 0, EndLine as Integer = -1, Yield as Integer = 0, DestRowBytes as Integer = 0) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Graphics & Pictures MBS Picture Plugin 8.5 Yes Yes Yes Yes No
Function: Copies raw image data into a memoryblock.
Notes:
Returns true on success.
destination should not be nil.
offset should be 0 or bigger and is the start position in the memoryblock.

The function will crash if the memoryblock is too small. Needs picture.width*picture.height*4 bytes in the memoryblock.

Does not access the mask inside the image!

This method was written for speed, so the creation of the memoryblock is your part. You can of course reuse memoryblocks for batch processing images as long as the memoryblock is big enough.

The X variant of this method does not touch the alpha channel in the memoryblock and the A variant changes the alpha value to the given value.

StartLine and Endline define the range of source lines from picture. Range is from 0 to picture.height-1. if Endline is -1, we use picture.height-1 internally. Yield specifies how much CPU time is given to other threads. If yield = 0, we give no CPU time away. If yield is > 0, we yield every yield/60th second to other threads. If DestRowBytes is not zero, it specifies the bytes per row in the target memoryblock for each line.

See also:

Feedback, Comments & Corrections

Picture.CopyABGRtoMemoryblockMBS(destination as memoryblock, offset as Integer, MaskForAlpha as picture, StartLine as Integer = 0, EndLine as Integer = -1, Yield as Integer = 0, DestRowBytes as Integer = 0) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Graphics & Pictures MBS Picture Plugin 13.0 Yes Yes Yes Yes No
Function: Copies raw image data into a memoryblock.
Example:
// Create a picture with mask:
dim p as Picture = LogoMBS(200)
dim g as Graphics = p.mask.Graphics

g.ForeColor = &cFFFFFF
g.FillRect 0,0,g.Width,g.Height

g.ForeColor = &c000000
g.Filloval 0,0,g.Width,g.Height

// convert to memoryblock
dim m as new MemoryBlock(4 * p.Width * p.Height)

if p.CopyABGRtoMemoryblockMBS(m, 0, p.Mask) then
// convert back
Backdrop = MemoryblockABGRtoPictureMBS(m, 0, p.Width, p.Height)

break // look into memoryblock with debugger
end if
Notes:
Returns true on success.
destination should not be nil.
offset should be 0 or bigger and is the start position in the memoryblock.
MaskForAlpha should not be nil and be the mask for this image.

The function will crash if the memoryblock is too small. Needs picture.width*picture.height*4 bytes in the memoryblock. Mask and Picture must have equal size.
The mask is used to fill alpha channel.

This method was written for speed, so the creation of the memoryblock is your part. You can of course reuse memoryblocks for batch processing images as long as the memoryblock is big enough.

StartLine and Endline define the range of source lines from picture. Range is from 0 to picture.height-1. if Endline is -1, we use picture.height-1 internally. Yield specifies how much CPU time is given to other threads. If yield = 0, we give no CPU time away. If yield is > 0, we yield every yield/60th second to other threads. If DestRowBytes is not zero, it specifies the bytes per row in the target memoryblock for each line.

See also:

Feedback, Comments & Corrections

Picture.CopyARGBtoMemoryblockMBS(destination as memoryblock, offset as Integer, AlphaValue as Integer, StartLine as Integer = 0, EndLine as Integer = -1, Yield as Integer = 0, DestRowBytes as Integer = 0) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Graphics & Pictures MBS Picture Plugin 8.5 Yes Yes Yes Yes No
Function: Copies raw image data into a memoryblock.
Example:
dim m as MemoryBlock
dim p,q as Picture

p=NewPicture(100,100,32)
p.Graphics.ForeColor=rgb(255,128,1)
p.Graphics.FillRect 0,0,100,100

// Make a new MemoryBlock
m=NewMemoryBlock(100*100*4) // 3 bytes per Pixel

// Copy RGB without alpha
if p.CopyARGBtoMemoryblockMBS(m,0,0) then

dim x as Picture = NewPicture(100,100,32)

q=MemoryblockARGBtoPictureMBS(x, m,0,100,100)

Backdrop=q

if x=q then
window1.Title = "reused picture"
else
window1.Title = "created new picture"
end if
end if
Notes:
Returns true on success.
destination should not be nil.
offset should be 0 or bigger and is the start position in the memoryblock.

The function will crash if the memoryblock is too small. Needs picture.width*picture.height*4 bytes in the memoryblock.

Does not access the mask inside the image!

This method was written for speed, so the creation of the memoryblock is your part. You can of course reuse memoryblocks for batch processing images as long as the memoryblock is big enough.

The X variant of this method does not touch the alpha channel in the memoryblock and the A variant changes the alpha value to the given value.

StartLine and Endline define the range of source lines from picture. Range is from 0 to picture.height-1. if Endline is -1, we use picture.height-1 internally. Yield specifies how much CPU time is given to other threads. If yield = 0, we give no CPU time away. If yield is > 0, we yield every yield/60th second to other threads. If DestRowBytes is not zero, it specifies the bytes per row in the target memoryblock for each line.

See also:

Feedback, Comments & Corrections

Picture.CopyARGBtoMemoryblockMBS(destination as memoryblock, offset as Integer, LittleEndian as boolean, AlphaValue as Integer, StartLine as Integer = 0, EndLine as Integer = -1, Yield as Integer = 0, DestRowBytes as Integer = 0) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Graphics & Pictures MBS Picture Plugin 5.3 Yes Yes Yes Yes No
Function: Copies raw image data into a memoryblock.
Example:
dim m as MemoryBlock
dim p as Picture

p=NewPicture(100,100,32)
p.Graphics.ForeColor=rgb(255,128,1)
p.Graphics.FillRect 0,0,100,100

// Make a new MemoryBlock
m=NewMemoryBlock(100*100*4) // 4 bytes per Pixel

// copy RGB and leave room for alpha
if p.CopyARGBtoMemoryblockMBS(m,0,false,-1) then
MsgBox EncodingToHexMBS(m.StringValue(0,99))
end if
Notes:
Returns true on success.
destination should not be nil.
offset should be 0 or bigger and is the start position in the memoryblock.

The function will crash if the memoryblock is too small. Needs picture.width*picture.height*4 bytes in the memoryblock.

Does not access the mask inside the image!

LittleEndian specifies whether the image is stored in ARGB (BigEndian) or BGRA (LittleEndian) mode.

If Alphavalue is in range of 0 to 255 the alpha value of all pixel is set to this value. If the AlphaValue is outside this range the alpha value is not touched for all pixels.

This method was written for speed, so the creation of the memoryblock is your part. You can of course reuse memoryblocks for batch processing images as long as the memoryblock is big enough.

StartLine and Endline define the range of source lines from picture. Range is from 0 to picture.height-1. if Endline is -1, we use picture.height-1 internally. Yield specifies how much CPU time is given to other threads. If yield = 0, we give no CPU time away. If yield is > 0, we yield every yield/60th second to other threads. If DestRowBytes is not zero, it specifies the bytes per row in the target memoryblock for each line.

See also:

Feedback, Comments & Corrections

Next items

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





Links
MBS FileMaker blog