Xojo Conferences
XDCMay2019MiamiUSA
MBSOct2019CologneDE

Platforms to show: All Mac Windows Linux Cross-Platform

Previous items

Picture.ReplaceRedChannelMBS(RedChannel as picture) as picture
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Graphics & Pictures MBS Picture Plugin 9.4 Yes Yes Yes Yes No
Function: Returns a copy of the picture with the red channel replaced with the red channel of the given picture.
Notes: Returns nil on low memory.

Feedback, Comments & Corrections

Picture.RotateImageAndMaskMBS(angle as Double, cut as boolean = False) as picture
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Graphics & Pictures MBS Picture Plugin 13.4 Yes Yes Yes Yes No
Function: Rotates the picture by angle° counter clockwise.
Notes:
Internally uses RotateMBS.
Works with masked and alpha channel pictures, but is faster with masked pictures.
Returns nil on any error.
if cut is true, the image is cut to the original size.

Feedback, Comments & Corrections

Picture.ScaleImageAndMaskMBS(width as Integer, height as Integer, AntiAlias as boolean=false, YieldTicks as Integer=0) 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: Scales the picture to the new size including mask (in case one exists).
Notes:
This is a self made algorithm which produces nice pictures on all platforms.
It is slower than QuickDraw on Mac OS, but nicer than drawpicture on Windows.
Returns nil on low memory or invalid width and height values.

AntiAlias is set to false if width<=self.width or height<=self.height.

If YieldTicks is 0, no time is given to other threads in your application. If it is a value > 0, this time is waited before a thread switch is done. Setting it to 1 will give away control to another thread after 1/60th of a second. We recommend a value of 3 to 5 for a good reponsibility of your application.

Some examples which use this method:

Feedback, Comments & Corrections

Picture.ScaleMBS(width as Integer, height as Integer, AntiAlias as boolean=false, YieldTicks as Integer=0) as picture
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Graphics & Pictures MBS Picture Plugin 5.1 Yes Yes Yes Yes No
Function: Scales the picture to the new size.
Example:
dim pic as new Picture(100,100,32)

pic.Graphics.ForeColor=&cFF0000
pic.Graphics.FillOval 0,0,100,100

dim scaledPic as picture = pic.ScaleMBS(200,200)

// show scaledPic
window1.backdrop = scaledPic
Notes:
This is a self made algorithm which produces nice pictures on all platforms.
It is slower than QuickDraw on Mac OS, but nicer than drawpicture on Windows.
Returns nil on low memory or invalid width and height values.

AntiAlias is set to false if width<=self.width or height<=self.height.

If YieldTicks is 0, no time is given to other threads in your application. If it is a value > 0, this time is waited before a thread switch is done. Setting it to 1 will give away control to another thread after 1/60th of a second. We recommend a value of 3 to 5 for a good reponsibility of your application.

Scaling down does not use antialias. If you need full antialias, please use ScalingMBS function.

If input and output size is equal, you get your picture back unchanged.
This function does not handle mask or alpha channel. Please use pictures with mask and scale image and mask separately.

Some examples which use this method:

Feedback, Comments & Corrections

Picture.ScalingMBS(mode as Integer, width as Integer, height as Integer, yield as Integer = 0) as picture
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Graphics & Pictures MBS Picture Plugin 8.0 Yes Yes Yes Yes No
Function: Scales the picture to the given size.
Example:
dim p as Picture

p=LogoMBS(1000)

p=p.ScalingMBS(2, 4000, 4000)

backdrop=p
Notes:
On low memory this function can return nil or the image may look bad. (e.g. all black)
The memory used for the temporary storage is original height * new width * 12 bytes plus some extra.
For scaling with the same size as the picture already has, the scaling is still performed.

Returns nil ony error. (e.g. destwidth=0)

Modes:
1triangle
2box, nereast neighbor
3lanczos 3
4lanczos 8
5mitchell
6poly 3
7cubic

This function does not handle mask or alpha channel. Please use pictures with mask and scale image and mask separately.

Feedback, Comments & Corrections

Picture.ScrollHorizontalMBS(delta as Integer, wrap as boolean, scrollmask as boolean) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Graphics & Pictures MBS Picture Plugin 6.5 Yes Yes No Yes No
Function: Scrolls the image data horizontally.
Example:
dim p as Picture

p=LogoMBS(500) // any bitmap image

if p.ScrollHorizontalMBS(100,true,false) then
Title="ok"
end if

Backdrop=p
Notes:
Returns true on success and false on failure.
Works only on Mac OS and Windows with 32bit bitmap images.
scrollmask defines whether a mask (if one exists) is also scrolled.
Wrap will define whether the image will wrap on the edges. If wrap is enabled on Mac, the whole thing speeds up.

Feedback, Comments & Corrections

Picture.ScrollMBS(deltaX as Integer, deltaY as Integer, wrap as boolean, scrollmask as boolean) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Graphics & Pictures MBS Picture Plugin 6.5 Yes Yes No Yes No
Function: Combines calls to ScrollHorizontalMBS and ScrollVerticalMBS.
Notes:
Returns true on success and false on failure.
Works only on Mac OS and Windows with 32bit bitmap images.
scrollmask defines whether a mask (if one exists) is also scrolled.
Wrap will define whether the image will wrap on the edges. If wrap is enabled on Mac, the whole thing speeds up.

Some examples which use this method:

Feedback, Comments & Corrections

Picture.ScrollVerticalMBS(delta as Integer, wrap as boolean, scrollmask as boolean) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Graphics & Pictures MBS Picture Plugin 6.5 Yes Yes No Yes No
Function: Scrolls the image data vertically.
Example:
dim p as Picture

p=LogoMBS(500) // any bitmap image

if p.ScrollVerticalMBS(100,true,false) then
Title="ok"
end if

Backdrop=p
Notes:
Returns true on success and false on failure.
Works only on Mac OS and Windows with 32bit bitmap images.
scrollmask defines whether a mask (if one exists) is also scrolled.
Wrap will define whether the image will wrap on the edges. If wrap is enabled on Mac, the whole thing speeds up.

Feedback, Comments & Corrections

Picture.SetSteganographyMBS(flags as Integer, data as Memoryblock) as boolean
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 an existing 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)
if p.SetSteganographyMBS(1, s) then

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

Backdrop = p
Break
end if
Notes:
Flags can be a combination of red (&h100), green (&h010) and blue (&h001).
Returns true on success or false on failure.
If memoryblock provided is nil, this function fails.

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.SetSteganographyPictureMBS(flags as Integer, data as Picture) as boolean
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 an existing picture.
Example:
const AllChannels = &h111

dim p as new Picture(500, 500, 32)
dim l as Picture = LogoMBS(500)

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

// adds picture. You will normally not see the modification
if p.SetSteganographyPictureMBS(AllChannels, l) then

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

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

w = new window1
w.Title = "Logo extracted"
w.Backdrop = y
end if
Notes:
Flags can be a combination of red (&h100), green (&h010) and blue (&h001).
Returns true on success or false on failure.

Function does not handle mask or alpha channel.

Feedback, Comments & Corrections

Picture.SobelChannelsMBS(Red as boolean, Green as Boolean, Blue as boolean, direction1 as Integer = 1, direction2 as Integer = 3, swap as boolean = false) as picture
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Graphics & Pictures MBS Picture Plugin 11.1 Yes Yes Yes Yes No
Function: Calculates the sobel operator.
Example:
dim m as Picture = LogoMBS(500)

// only green
Backdrop = m.SobelChannelsMBS(false, true, false)
Notes:
Useful for edge detection.
See also SobelMBS function which takes similar operators.
You can set Red/Blue/Green parameters to define which channel is modified and which channel is just copied.
Pictures look quite funny. The channel who got the edge detection has bigger areas black or white so other colors in other channels have much more visible effect.

Some examples which use this method:

Feedback, Comments & Corrections

Picture.SobelMBS(direction1 as Integer = 1, direction2 as Integer = 3, swap as boolean = false, gray as boolean = true) as picture
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Graphics & Pictures MBS Picture Plugin 11.1 Yes Yes Yes Yes No
Function: Calculates the sobel operator.
Example:
dim m as Picture = LogoMBS(500)

Backdrop = m.SobelMBS
Notes:
Useful for edge detection.

direction1: The direction for first matrix.
direction2: The direction for first matrix.
swap: If false, you get white on black. If true you get black on white.
gray: whether to output gray image instead of RGB image.

Possible Matrix values:
-1: negative identity:
0: identity
1: west
2: east
3: north
4: south
5: south east
6: north west
7: north east
8: south west

You can add 10 to the 8 direction matrixes to get more weight.

Some examples which use this method:

Feedback, Comments & Corrections

Picture.SteganographyMBS(flags as Integer) as Memoryblock
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Graphics & Pictures MBS Picture Plugin 14.2 Yes Yes Yes Yes No
Function: Queries steganography information inside the picture.
Example:
dim p as Picture = LogoMBS(500)

dim s as string = "Hello World. This is just a test." + chr(0)
if p.SetSteganographyMBS(1, s) then

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

Backdrop = p
Break
end if
Notes: Flags can be a combination of red (&h100), green (&h010) and blue (&h001).

Feedback, Comments & Corrections

Picture.SteganographyPictureMBS(flags as Integer) 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: Queries steganography information inside the 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).

Some examples which use this method:

Feedback, Comments & Corrections

Picture.ThreadedTransformMBS(Threaded as Integer, Map() as color, dest as picture = nil) as picture
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Graphics & Pictures MBS Picture Plugin 10.0 Yes Yes Yes Yes No
Function: Performs a transformation to the picture.
Example:
dim p as Picture = LogoMBS(500)

dim map(-1) as color

for r as Integer = 0 to 255
for g as Integer = 0 to 255
for b as Integer = 0 to 255
// index is r*65536+g*256+b

// we swap colors: r gives g, g gives b, b gives r
map.Append rgb(g,b,r)
next
next
next

Backdrop=p.ThreadedTransformMBS(0, map)
Notes:
Threaded parameter specifies how many threads you want to use:
A negative value disables threading, zero will use one thread for each CPU core and a positive number specifies the thread count.

For each color in the source picture the red, blue and green values are used as index (blue+green*256+blue*65536) in the arrays to get the new color value.

The arrays should have 2^24 entries.

You can pass destination picture. If dest is not nil and size matches, the plugin reuses the picture object which increases performance as no new picture is created.

See also:

Some examples which use this method:

Feedback, Comments & Corrections

Picture.ThreadedTransformMBS(Threaded as Integer, Map() as Integer, dest as picture = nil) as picture
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Graphics & Pictures MBS Picture Plugin 10.0 Yes Yes Yes Yes No
Function: Performs a transformation to the picture.
Example:
dim p as Picture = LogoMBS(500)

dim map(-1) as Integer

for r as Integer = 0 to 255
for g as Integer = 0 to 255
for b as Integer = 0 to 255
// index is r*65536+g*256+b

// we swap colors: r gives g, g gives b, b gives r
map.Append g*65536+b*256+r
next
next
next

Backdrop=p.ThreadedTransformMBS(0, map)
Notes:
Threaded parameter specifies how many threads you want to use:
A negative value disables threading, zero will use one thread for each CPU core and a positive number specifies the thread count.

For each color in the source picture the red, blue and green values are used as index (blue+green*256+blue*65536) in the arrays to get the new color value.

The arrays should have 2^24 entries.

You can pass destination picture. If dest is not nil and size matches, the plugin reuses the picture object which increases performance as no new picture is created.

See also:

Some examples which use this method:

Feedback, Comments & Corrections

Picture.ThreadedTransformMBS(Threaded as Integer, RedMap as memoryblock, GreenMap as memoryblock, BlueMap as memoryblock, dest as picture = nil) as picture
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Graphics & Pictures MBS Picture Plugin 10.0 Yes Yes Yes Yes No
Function: Performs a transformation to the picture.
Example:
dim p as Picture = LogoMBS(500)

dim red as MemoryBlock = NewMemoryBlock(256)
dim green as MemoryBlock = NewMemoryBlock(256)
dim blue as MemoryBlock = NewMemoryBlock(256)

for i as Integer=0 to 255
red.Byte(i)=i/2
green.Byte(i)=i/2
blue.Byte(i)=i/2
next

Backdrop=p.ThreadedTransformMBS(0, red, green, blue)
Notes:
Threaded parameter specifies how many threads you want to use:
A negative value disables threading, zero will use one thread for each CPU core and a positive number specifies the thread count.

For each color in the source picture the red, blue and green values are used as index in the memoryblocks to get the new color value.

The memoryblocks must have a size of 256 Bytes.

You can pass destination picture. If dest is not nil and size matches, the plugin reuses the picture object which increases performance as no new picture is created.

See also:

Some examples which use this method:

Feedback, Comments & Corrections

Picture.ThreadedTransformMBS(Threaded as Integer, RedMap() as Integer, GreenMap() as Integer, BlueMap() as Integer, dest as picture = nil) as picture
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Graphics & Pictures MBS Picture Plugin 10.0 Yes Yes Yes Yes No
Function: Performs a transformation to the picture.
Example:
dim p as Picture = LogoMBS(500)

dim red(-1) as Integer
dim green(-1) as Integer
dim blue(-1) as Integer

for i as Integer=0 to 255
red.Append i/2
green.Append i/2
blue.Append i/2
next

Backdrop=p.ThreadedTransformMBS(0, red, green, blue)
Notes:
Threaded parameter specifies how many threads you want to use:
A negative value disables threading, zero will use one thread for each CPU core and a positive number specifies the thread count.

For each color in the source picture the red, blue and green values are used as index in the arrays to get the new color value.

The arrays should have 256 entries.

You can pass destination picture. If dest is not nil and size matches, the plugin reuses the picture object which increases performance as no new picture is created.

See also:

Some examples which use this method:

Feedback, Comments & Corrections

Picture.ThresholdMBS(Threshold as integer) as picture
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Graphics & Pictures MBS Picture Plugin 17.5 Yes Yes Yes Yes No
Function: Creates black and white picture.
Notes:
With threshold value you define threshold in range from 0 to 255.
Normally you use 127 for turning picture to black & white.

Feedback, Comments & Corrections

Picture.TransformColorsMBS(red as memoryblock, blue as memoryblock, green as memoryblock, dest as picture = nil) as picture
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Graphics & Pictures MBS Picture Plugin 4.3 Yes Yes Yes Yes No
Function: Applies a transform table to the pixels.
Notes:
Red, blue and green are 256 byte big memoryblocks with one byte for each value.

In RB the function does this:
color=rgb(red.byte[color.red], green.byte[color.green], blue.byte[color.blue])

If you pass a destination picture and it has right size, the plugin will recycle that instead of creating a new one to increase performance.

Some examples which use this method:

Feedback, Comments & Corrections

Picture.TrimMBS(left as Integer, top as Integer, width as Integer, height as Integer) as picture
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Graphics & Pictures MBS Picture Plugin 8.0 Yes Yes Yes Yes No
Function: Trims the picture to the given rectangle.
Example:
dim p as Picture = LogoMBS(500)

Backdrop = p.TrimMBS(100,100,300,300)
Notes:
This method does not handle the mask.
So p.Trim(0,0,p.width,p.height) will give you a copy of the image pixels without mask.
left and top are zero based.

Use TrimWithMaskMBS if you need the mask to be trimmed.
Returns nil on low memory or bad parameters.

Feedback, Comments & Corrections

Picture.TrimWithMaskMBS(left as Integer, top as Integer, width as Integer, height as Integer) as picture
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Graphics & Pictures MBS Picture Plugin 8.0 Yes Yes Yes Yes No
Function: Trims the picture to the given rectangle.
Example:
dim p as picture
dim someimage as Picture = LogoMBS(100)

p=someimage.TrimWithMaskMBS(100,200,300,400)
Notes:
left and top are zero based.
Returns nil on low memory or bad parameters.

Feedback, Comments & Corrections

Picture.VMirrorMBS as picture
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Graphics & Pictures MBS Picture Plugin Yes Yes Yes Yes No
Function: Mirrors the picture vertically.
Example:
canvas1.backdrop=pic.VMirrorMBS
Notes:
This method returns a copy of the picture mirrored.
Returns nil on low memory.

Some examples which use this method:

Feedback, Comments & Corrections

Picture.VMirrorPictureMBS as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Graphics & Pictures MBS Picture Plugin 7.8 Yes Yes Yes Yes No
Function: Mirrors the picture vertically.
Example:
if pic.VMirrorPictureMBS then // mirror picture
canvas1.backdrop=pic
else
canvas1.backdrop=pic.VMirrorMBS // mirror a copy
end if
Notes: This methods mirrors the picture data itself. Returns true on success and false on failure. Only bitmap pictures can be mirrored this way.

Some examples which use this method:

Feedback, Comments & Corrections

Previous items

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




Links
MBS Xojo Plugins