Xojo Conferences
MBSSep2018MunichDE
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

Previous items Next items

Picture.MirrorMBS as picture
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 and horizontally.
Example:
canvas1.backdrop=pic.MirrorMBS
Notes:
Same as rotation by 180 degree.
This method returns a copy of the picture mirrored.
Returns nil on low memory.

Some examples which use this method:

Feedback, Comments & Corrections

Picture.MirrorPictureMBS 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 and horizontally.
Example:
if pic.MirrorPictureMBS then // mirror picture
canvas1.backdrop=pic
else
canvas1.backdrop=pic.MirrorMBS // mirror a copy
end if
Notes:
Same as rotation by 180 degree.
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

NewPictureWithColorMBS(width as Integer, height as Integer, c as color) as picture
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
global method Graphics & Pictures MBS Picture Plugin 11.0 Yes Yes Yes Yes No
Function: Creates a new picture and fills it with the given color.
Example:
window1.backdrop = NewPictureWithColorMBS(200, 200, &c3366CC)
Notes: This function is mostly to check if the picture writer code in our plugins work.

Feedback, Comments & Corrections

Picture.RedChannelMBS 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 red channel of the picture copied into a new picture.
Example:
dim p as Picture = LogoMBS(500)
Backdrop = p.RedChannelMBS

Feedback, Comments & Corrections

RenderSamplesMBS(Samples as memoryblock, SampleCount as Integer, Smooth as Integer, Width as Integer, Height as Integer, outlinewidth as Integer, BackColor as color=&c88B5C4, ForeColor as color=&c274C5A, OutLineColor as color=&c203F4E, Bits as Integer = 8, AutoScale as boolean = false) as Picture
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
global method Graphics & Pictures MBS Picture Plugin 9.7 Yes Yes Yes Yes No
Function: Renders audio samples into a picture.
Notes:
Samples has one byte for each audio value and 2 bytes for each stereo sample.
SampleCount: Number of Samples. = Samples.size/2
Smooth: How smooth the samples should be made.
Width: Width of picture
Height: Height of picture
outlinewidth: The width of the outline (0=no outline)
BackColor: The back color.
ForeColor: the fore color.
OutLineColor: The color for the outline.
Bits: Pass 7 for signed bytes, 8 for unsigned bytes, 15 for signed shorts and 16 for unsigned short values. Pass -32 for Float32 and -64 for Float64.
AutoScale: Whether to scale automatically depending on highest values.

Some examples using this method:

Feedback, Comments & Corrections

Picture.ReplaceBlueChannelMBS(BlueChannel 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 blue channel replaced with the blue channel of the given picture.
Notes: Returns nil on low memory.

Feedback, Comments & Corrections

Picture.ReplaceColorMBS(SearchColor as color, ReplaceWithColor as color) as picture
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Graphics & Pictures MBS Picture Plugin 7.7 Yes Yes Yes Yes No
Function: Searches the given color and replaces it with the second color.
Example:
dim p as Picture

p=NewPicture(300,300,32)

p.Graphics.ForeColor=&cFF0000
p.Graphics.FillRect 000,100,100,100

p.Graphics.ForeColor=&c00FF00
p.Graphics.FillRect 100,100,100,100

p.Graphics.ForeColor=&c0000FF
p.Graphics.FillRect 200,100,100,100

p.Graphics.ForeColor=&c777700
p.Graphics.FillRect 100,200,100,100

// shows a violet box on the left. Other pixels unchanged
backdrop=p.ReplaceColorMBS(&cFF0000,&cFF00FF)
Notes:
All other pixels are copied to the new picture.
Returns nil on any error.

Feedback, Comments & Corrections

Picture.ReplaceGreenChannelMBS(GreenChannel 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 green channel replaced with the green channel of the given picture.
Notes: Returns nil on low memory.

Feedback, Comments & Corrections

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

Previous items Next items

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





Links
MBS Xojo Plugins