MBS Plugin Documentation

Search:

Statistics   -   FAQ   -   Plugin Parts (All, Dependencies)   -   Class hierarchie

New in Version 7.0 7.1 7.2 7.3 7.4 7.5 7.6 7.7 7.8 8.0 8.1 8.2 8.3 8.4 8.5 8.6 8.7 9.0

The list of the   themes,   classes,   controls,   modules,   global methods by category,   global methods by name,   screenshots,   licenses   and   examples.

Platforms to show: All Mac Windows Linux Cross-Platform

Next items

Picture.AutoLevelMBS as picture
method, Graphics & Pictures, MBS Picture Plugin (Picture), class Picture, Plugin version: 6.3, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

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.
Picture.BitmapMBS as picture
method, Graphics & Pictures, MBS Picture Plugin (PictureRotate), class Picture, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Returns the picture as a bitmap picture.
Example:
r=app.resourceFork.getpicture(148)
p=r.bitmap
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:

BlendPicturesMBS(source as picture, sourcepercent as double, dest as picture, destpercent as double) as picture
global method, Graphics & Pictures, MBS Picture Plugin (PictureBlend), Plugin version: 4.3, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

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:

BlendPicturesWithMaskMBS(source as picture, dest as picture, mask as picture) as picture
global method, Graphics & Pictures, MBS Picture Plugin (PictureBlend), Plugin version: 4.3, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

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:

BuildPictureWithGWorldHandleMBS(handle as integer, ByPassOwernerShip as boolean) as picture
global method, Graphics & Pictures, MBS Picture Plugin (Picture), Plugin version: 3.3, Mac OS X: Works, Windows: Works, Linux x86: Does nothing, Feedback.

Function: Creates a new Realbasic picture using a GWorld Handle.
Notes:
If ByPassOwernerShip is true, RB will destroy the GWorld Handle later if the picture is destroyed. If ByPassOwernerShip is false, the Picture will become unuseable (maybe crashes when used) as soon as the given handle is destroyed.

Returns nil on any error.
Requires QuickTime on Windows.
BuildPictureWithPicHandleDataMBS(data as string) as picture
global method, Graphics & Pictures, MBS Picture Plugin (Picture), Plugin version: 3.3, Mac OS X: Works, Windows: Works, Linux x86: Does nothing, Feedback.

Function: Creates a Realbasic picture from data from a PicHandle.
Example:
// Use an AppleScript to get a picture, decode the picture, and make a RB picture

dim s as String
dim a as AppleScriptMBS
dim i as integer

s="set p to the clipboard as ""PICT"""+chr(13)
s=s+"return p"

a=new AppleScriptMBS
a.Compile s

a.Execute

S=A.Result

i=instr(s,"PICT")
s=mid(s,i+4)

s=DecodingFromHexMBS(s)

Backdrop=NewPictureWithPicHandleDataMBS(s)

Notes:
Returns nil on any error.
Requires QuickTime on Windows.
The data is copied into the new picture object.
Picture.ChangeBrightnessAbsoluteMBS(r as double, g as double, b as double) as picture
method, Graphics & Pictures, MBS Picture Plugin (Picture), class Picture, Plugin version: 4.3, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Changes the bightness of an image.
Notes:
To every pixel component the value is added.
Returns nil if the picture is no bitmap picture.

PS: This function may be optimized, if someone needs it to be faster.

Some examples which use this method:

Picture.ChangeBrightnessAbsoluteMBS(x as double) as picture
method, Graphics & Pictures, MBS Picture Plugin (Picture), class Picture, Plugin version: 4.3, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Changes the bightness of an image.
Notes:
To every pixel component the value is added.
Returns nil if the picture is no bitmap picture.

PS: This function may be optimized, if someone needs it to be faster.

Some examples which use this method:

Picture.ChangeBrightnessLinearMBS(r as double, g as double, b as double) as picture
method, Graphics & Pictures, MBS Picture Plugin (Picture), class Picture, Plugin version: 4.3, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Changes the bightness of an image linear.
Notes:
Returns nil if the picture is no bitmap picture.
PS: This function may be optimized, if someone needs it to be faster (e.g. using Altivec).

Some examples which use this method:

Picture.ChangeBrightnessLinearMBS(x as double) as picture
method, Graphics & Pictures, MBS Picture Plugin (Picture), class Picture, Plugin version: 4.3, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Changes the bightness of an image linear.
Notes:
Returns nil if the picture is no bitmap picture.
PS: This function may be optimized, if someone needs it to be faster (e.g. using Altivec).

Some examples which use this method:

Picture.ChangeContrastMBS(x as double) as picture
method, Graphics & Pictures, MBS Picture Plugin (Picture), class Picture, Plugin version: 4.3, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Changes the contrast of the picture.
Notes:
All three color channels are handled with the same contrast change.
Returns a picture on success or nil on any error.
Parameters can have any value.
(values >=0.0 will add contrast, values below 0.0 will reduce contrast till gray picture at -1.0, values below -1.0 will add contrast again and also invert the picture)

Some examples which use this method:

Picture.ChangeContrastMBS(xr as double, xg as double, xb as double) as picture
method, Graphics & Pictures, MBS Picture Plugin (Picture), class Picture, Plugin version: 4.3, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Changes the contrast of the picture.
Notes:
Three different values, one for each channel.
Returns a picture on success or nil on any error.
(values >=0.0 will add contrast, values below 0.0 will reduce contrast till gray picture at -1.0, values below -1.0 will add contrast again and also invert the picture)

Some examples which use this method:

Picture.ChangeCustomMBS(a as double, b as double) as picture
method, Graphics & Pictures, MBS Picture Plugin (Picture), class Picture, Plugin version: 4.3, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Changes the picture with custom values.
Notes:
Uses this formular:
NewPixelComponent=OldPixelComponent*a+b

Some examples which use this method:

class Picture
class, Graphics & Pictures, MBS QuickTime Plugin (QuickTime), class Picture, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Extends Realbasic's Picture Class.
Picture.cloneMBS as picture
method, Graphics & Pictures, MBS Picture Plugin (PictureRotate), class Picture, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Clones the picture as a bitmap.
Example:
r=app.resourceFork.getpicture(148)
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.

Some examples which use this method:

Picture.CloneMBS(width as integer, height as integer) as picture
method, Graphics & Pictures, MBS Picture Plugin (PictureRotate), class Picture, Plugin version: 7.0, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Clones the picture as a bitmap with given size.
Example:
r=app.resourceFork.getpicture(148)
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.

Some examples which use this method:

CombinePicturesMBS(red as picture, blue as picture, green as picture) as picture
global method, Graphics & Pictures, MBS Picture Plugin (Picture), Plugin version: 4.3, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Combines the red, green and blue channels of three images into the a new one.
Notes: Returns nil on any error.
Picture.CopyABGRtoMemoryblockMBS(destination as memoryblock, offset as integer, AlphaValue as integer) as boolean
method, Graphics & Pictures, MBS Picture Plugin (PictureMemory), class Picture, Plugin version: 8.5, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

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.
Picture.CopyARGBtoMemoryblockMBS(destination as memoryblock, offset as integer, AlphaValue as integer) as boolean
method, Graphics & Pictures, MBS Picture Plugin (PictureMemory), class Picture, Plugin version: 8.5, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

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.
Picture.CopyARGBtoMemoryblockMBS(destination as memoryblock, offset as integer, LittleEndian as boolean, AlphaValue as integer) as boolean
method, Graphics & Pictures, MBS Picture Plugin (PictureMemory), class Picture, Plugin version: 5.3, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

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.
Picture.CopyBGRAtoMemoryblockMBS(destination as memoryblock, offset as integer, AlphaValue as integer) as boolean
method, Graphics & Pictures, MBS Picture Plugin (PictureMemory), class Picture, Plugin version: 8.5, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

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.
Picture.CopyBGRtoMemoryblockMBS(destination as memoryblock, offset as integer) as boolean
method, Graphics & Pictures, MBS Picture Plugin (PictureMemory), class Picture, Plugin version: 8.5, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

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*3 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.
Picture.CopyBGRXtoMemoryblockMBS(destination as memoryblock, offset as integer) as boolean
method, Graphics & Pictures, MBS Picture Plugin (PictureMemory), class Picture, Plugin version: 8.5, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

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.
Picture.CopyBtoMemoryblockMBS(destination as memoryblock, offset as integer, PixelByteSize as integer) as boolean
method, Graphics & Pictures, MBS Picture Plugin (PictureMemory), class Picture, Plugin version: 5.3, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Copies raw image data into a memoryblock.
Example:
const kAlphaOffset=0 ' (BigEndian) and 3 (LittleEndian)
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
p.mask.Graphics.ForeColor=rgb(127,127,127)
p.mask.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

// copy Blue channel from mask image into Memoryblock
if p.mask.CopyBtoMemoryblockMBS(m,kAlphaOffset,4) 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.
PixelByteSize is normally 4 for 32bit per Pixel.
By using a different offset you can have this function working correctly on non BigEndian platforms.
The function will crash if the memoryblock is too small. Needs picture.width*picture.height*PixelByteSize bytes in the memoryblock.
Mask images in RB are all gray so it does not matter which channel you copy to get the alpha channel. This function takes the blue channel from the source 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.
Picture.CopyGtoMemoryblockMBS(destination as memoryblock, offset as integer, PixelByteSize as integer) as boolean
method, Graphics & Pictures, MBS Picture Plugin (PictureMemory), class Picture, Plugin version: 5.3, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Copies raw image data into a memoryblock.
Example:
const kAlphaOffset=0 ' (BigEndian) and 3 (LittleEndian)
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
p.mask.Graphics.ForeColor=rgb(127,127,127)
p.mask.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

// copy green channel from mask image into Memoryblock
if p.mask.CopyGtoMemoryblockMBS(m,kAlphaOffset,4) 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.
PixelByteSize is normally 4 for 32bit per Pixel.
By using a different offset you can have this function working correctly on non BigEndian platforms.
The function will crash if the memoryblock is too small. Needs picture.width*picture.height*PixelByteSize bytes in the memoryblock.
Mask images in RB are all gray so it does not matter which channel you copy to get the alpha channel. This function takes the green channel from the source 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.
Picture.CopyMaskMBS as picture
method, Graphics & Pictures, MBS Picture Plugin (PictureCopy), class Picture, Plugin version: 8.6, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Copies the mask of the picture into a new and independend picture object.
Example:
dim p as Picture

p=NewPicture(300,300,32)

p.Graphics.ForeColor=&cFF0000
p.Graphics.FillRect 0,0,300,300

p.mask.Graphics.ForeColor=&cFFFFFF
p.mask.Graphics.Fillrect 0,0,300,300

p.mask.Graphics.ForeColor=&c000000
p.mask.Graphics.Filloval 0,0,300,300

Backdrop=p.CopyMaskMBS

Notes: Returns nil on low memory.

Some examples which use this method:

Picture.CopyPictureWithMaskMBS as picture
method, Graphics & Pictures, MBS Picture Plugin (PictureCopy), class Picture, Plugin version: 8.6, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Copies the the picture into a new and independend picture object with mask.
Example:
dim p as Picture

p=NewPicture(300,300,32)

p.Graphics.ForeColor=&cFF0000
p.Graphics.FillRect 0,0,300,300

p.mask.Graphics.ForeColor=&cFFFFFF
p.mask.Graphics.Fillrect 0,0,300,300

p.mask.Graphics.ForeColor=&c000000
p.mask.Graphics.Filloval 0,0,300,300

Backdrop=p.CopyPictureWithMaskMBS

Notes: Returns nil on low memory.
Picture.CopyPictureWithoutMaskMBS as picture
method, Graphics & Pictures, MBS Picture Plugin (PictureCopy), class Picture, Plugin version: 8.6, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Copies the the picture into a new and independend picture object without the mask.
Example:
dim p as Picture

p=NewPicture(300,300,32)

p.Graphics.ForeColor=&cFF0000
p.Graphics.FillRect 0,0,300,300

p.mask.Graphics.ForeColor=&cFFFFFF
p.mask.Graphics.Fillrect 0,0,300,300

p.mask.Graphics.ForeColor=&c000000
p.mask.Graphics.Filloval 0,0,300,300

Backdrop=p.CopyPictureWithoutMaskMBS

Notes: Returns nil on low memory.

Some examples which use this method:

Previous items Next items

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