Xojo Developer Conference
25/27th April 2018 in Denver.
MBS Xojo Conference
6/7th September 2018 in Munich, Germany.

Platforms to show: All Mac Windows Linux Cross-Platform

Previous items Next items

PictureMBS.Combine(Image As PictureMBS, Mask As PictureMBS, DestX as Integer, DestY as Integer, SourceX as Integer, SourceY as Integer, Width as Integer, Height as Integer, UseColours As Boolean, ForeColour as Integer) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Large Picture MBS Images Plugin 10.3 Yes Yes Yes Yes No
Function: Copies pixels from one picture into another picture with some options.
Notes:
Returns true on success and false on failure.

This function has 4 behaviors depending on the parameters:

1. If mask is nil and no ForeColour and MaskColour values are passed, the pixels a copied to the destination picture.

2. But if there is a mask, the pixels are copied with applying the mask.

3. If the mask color is not defined, the the pixels are filled with the fore color applying the mask.

4. As the last variation the pixels are copied and the forecolor, the mask color or black is used with the image as the mask. If UseColours parameter is false black is used for this.

Parameters:
Image: the source picture, must not be nil.
PreMultipliedSource: Optional parameter. If true the image must be premultiplied. Default is false.
Mask: the mask picture, can be nil.
DestX: destination position
DestY: destination position
SourceX: source position
SourceY: source position
Width: width of the area to copy
Height: height of the area to copy
UseColours: whether to use the mask colour.
ForeColour: the fore colour, optional, can be integer or color
MaskColour: the mask color, optional, can be integer or color

This function is 5 times in the plugin defined to implement having the last two parameters optional and either integer or color. You can pass a negative number for MaskColour or ForeColour to disable this parameter.

The images you use can be Gray, RGB with or without alpha channels. But most variants here ignore alpha channels. To make sure the alpha channel is not touched, use the PictureMBS.RGBChannels function and pass that new PictureMBS.

See also:

Feedback, Comments & Corrections

PictureMBS.Combine(Image As PictureMBS, Mask As PictureMBS, DestX as Integer, DestY as Integer, SourceX as Integer, SourceY as Integer, Width as Integer, Height as Integer, UseColours As Boolean, ForeColour as Integer, MaskColour as Integer) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Large Picture MBS Images Plugin 10.3 Yes Yes Yes Yes No
Function: Copies pixels from one picture into another picture with some options.
Notes:
Returns true on success and false on failure.

This function has 4 behaviors depending on the parameters:

1. If mask is nil and no ForeColour and MaskColour values are passed, the pixels a copied to the destination picture.

2. But if there is a mask, the pixels are copied with applying the mask.

3. If the mask color is not defined, the the pixels are filled with the fore color applying the mask.

4. As the last variation the pixels are copied and the forecolor, the mask color or black is used with the image as the mask. If UseColours parameter is false black is used for this.

Parameters:
Image: the source picture, must not be nil.
PreMultipliedSource: Optional parameter. If true the image must be premultiplied. Default is false.
Mask: the mask picture, can be nil.
DestX: destination position
DestY: destination position
SourceX: source position
SourceY: source position
Width: width of the area to copy
Height: height of the area to copy
UseColours: whether to use the mask colour.
ForeColour: the fore colour, optional, can be integer or color
MaskColour: the mask color, optional, can be integer or color

This function is 5 times in the plugin defined to implement having the last two parameters optional and either integer or color. You can pass a negative number for MaskColour or ForeColour to disable this parameter.

The images you use can be Gray, RGB with or without alpha channels. But most variants here ignore alpha channels. To make sure the alpha channel is not touched, use the PictureMBS.RGBChannels function and pass that new PictureMBS.

See also:

Feedback, Comments & Corrections

PictureMBS.Combine(Image As PictureMBS, PreMultipliedSource as boolean, Mask As PictureMBS, DestX as Integer, DestY as Integer, SourceX as Integer, SourceY as Integer, Width as Integer, Height as Integer, UseColours As Boolean) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Large Picture MBS Images Plugin 10.3 Yes Yes Yes Yes No
Function: Copies pixels from one picture into another picture with some options.
Example:
dim DestImage As PictureMBS
dim Image As PictureMBS
dim Mask As PictureMBS
dim DestX as Integer=100
dim DestY as Integer=100
dim SourceX as Integer=0
dim SourceY as Integer=0
dim Width as Integer=500
dim Height as Integer=500

// we create a little mask for a smooth fade
dim m as Picture = NewPicture(500,500,32)
dim g as Graphics = m.Graphics

for y as Integer = 0 to 499
dim n as Integer = y*255/499
g.ForeColor = rgb(n, n, n)
g.DrawLine 0,y,499,y
next

// uncomment to see our mask:
'Backdrop = m
'return

image=new PictureMBS(LogoMBS(500))
Mask=new PictureMBS(m)
DestImage=new PictureMBS(700,700,PictureMBS.ImageFormatRGB)

// this will only copy the pixels
if DestImage.Combine(image,false,Mask,DestX,DestY,SourceX,SourceY,Width,Height,false) then
window1.Backdrop=DestImage.CopyPicture
end if
Notes:
Returns true on success and false on failure.

This function has 4 behaviors depending on the parameters:

1. If mask is nil and no ForeColour and MaskColour values are passed, the pixels a copied to the destination picture.

2. But if there is a mask, the pixels are copied with applying the mask.

3. If the mask color is not defined, the the pixels are filled with the fore color applying the mask.

4. As the last variation the pixels are copied and the forecolor, the mask color or black is used with the image as the mask. If UseColours parameter is false black is used for this.

Parameters:
Image: the source picture, must not be nil.
PreMultipliedSource: Optional parameter. If true the image must be premultiplied. Default is false.
Mask: the mask picture, can be nil.
DestX: destination position
DestY: destination position
SourceX: source position
SourceY: source position
Width: width of the area to copy
Height: height of the area to copy
UseColours: whether to use the mask colour.
ForeColour: the fore colour, optional, can be integer or color
MaskColour: the mask color, optional, can be integer or color

This function is 5 times in the plugin defined to implement having the last two parameters optional and either integer or color. You can pass a negative number for MaskColour or ForeColour to disable this parameter.

The images you use can be Gray, RGB with or without alpha channels. But most variants here ignore alpha channels. To make sure the alpha channel is not touched, use the PictureMBS.RGBChannels function and pass that new PictureMBS.

See also:

Feedback, Comments & Corrections

PictureMBS.Combine(Image As PictureMBS, PreMultipliedSource as boolean, Mask As PictureMBS, DestX as Integer, DestY as Integer, SourceX as Integer, SourceY as Integer, Width as Integer, Height as Integer, UseColours As Boolean, ForeColour As color) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Large Picture MBS Images Plugin 10.3 Yes Yes Yes Yes No
Function: Copies pixels from one picture into another picture with some options.
Notes:
Returns true on success and false on failure.

This function has 4 behaviors depending on the parameters:

1. If mask is nil and no ForeColour and MaskColour values are passed, the pixels a copied to the destination picture.

2. But if there is a mask, the pixels are copied with applying the mask.

3. If the mask color is not defined, the the pixels are filled with the fore color applying the mask.

4. As the last variation the pixels are copied and the forecolor, the mask color or black is used with the image as the mask. If UseColours parameter is false black is used for this.

Parameters:
Image: the source picture, must not be nil.
PreMultipliedSource: Optional parameter. If true the image must be premultiplied. Default is false.
Mask: the mask picture, can be nil.
DestX: destination position
DestY: destination position
SourceX: source position
SourceY: source position
Width: width of the area to copy
Height: height of the area to copy
UseColours: whether to use the mask colour.
ForeColour: the fore colour, optional, can be integer or color
MaskColour: the mask color, optional, can be integer or color

This function is 5 times in the plugin defined to implement having the last two parameters optional and either integer or color. You can pass a negative number for MaskColour or ForeColour to disable this parameter.

The images you use can be Gray, RGB with or without alpha channels. But most variants here ignore alpha channels. To make sure the alpha channel is not touched, use the PictureMBS.RGBChannels function and pass that new PictureMBS.

See also:

Feedback, Comments & Corrections

PictureMBS.Combine(Image As PictureMBS, PreMultipliedSource as boolean, Mask As PictureMBS, DestX as Integer, DestY as Integer, SourceX as Integer, SourceY as Integer, Width as Integer, Height as Integer, UseColours As Boolean, ForeColour As color, MaskColour As color) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Large Picture MBS Images Plugin 10.3 Yes Yes Yes Yes No
Function: Copies pixels from one picture into another picture with some options.
Notes:
Returns true on success and false on failure.

This function has 4 behaviors depending on the parameters:

1. If mask is nil and no ForeColour and MaskColour values are passed, the pixels a copied to the destination picture.

2. But if there is a mask, the pixels are copied with applying the mask.

3. If the mask color is not defined, the the pixels are filled with the fore color applying the mask.

4. As the last variation the pixels are copied and the forecolor, the mask color or black is used with the image as the mask. If UseColours parameter is false black is used for this.

Parameters:
Image: the source picture, must not be nil.
PreMultipliedSource: Optional parameter. If true the image must be premultiplied. Default is false.
Mask: the mask picture, can be nil.
DestX: destination position
DestY: destination position
SourceX: source position
SourceY: source position
Width: width of the area to copy
Height: height of the area to copy
UseColours: whether to use the mask colour.
ForeColour: the fore colour, optional, can be integer or color
MaskColour: the mask color, optional, can be integer or color

This function is 5 times in the plugin defined to implement having the last two parameters optional and either integer or color. You can pass a negative number for MaskColour or ForeColour to disable this parameter.

The images you use can be Gray, RGB with or without alpha channels. But most variants here ignore alpha channels. To make sure the alpha channel is not touched, use the PictureMBS.RGBChannels function and pass that new PictureMBS.

See also:

Feedback, Comments & Corrections

PictureMBS.Combine(Image As PictureMBS, PreMultipliedSource as boolean, Mask As PictureMBS, DestX as Integer, DestY as Integer, SourceX as Integer, SourceY as Integer, Width as Integer, Height as Integer, UseColours As Boolean, ForeColour as Integer) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Large Picture MBS Images Plugin 10.3 Yes Yes Yes Yes No
Function: Copies pixels from one picture into another picture with some options.
Example:
dim DestImage As PictureMBS
dim Image As PictureMBS
dim Mask As PictureMBS
dim DestX as Integer=100
dim DestY as Integer=100
dim SourceX as Integer=0
dim SourceY as Integer=0
dim Width as Integer=500
dim Height as Integer=500
dim UseColours as Boolean = false
dim ForeColour as color = &cFF0000

image=new PictureMBS(LogoMBS(500))
Mask=nil
DestImage=new PictureMBS(700,700,PictureMBS.ImageFormatRGB)

if DestImage.Combine(image,Mask,DestX,DestY,SourceX,SourceY,Width,Height,UseColours,ForeColour) then
window1.Backdrop=DestImage.CopyPicture
end if
Notes:
Returns true on success and false on failure.

This function has 4 behaviors depending on the parameters:

1. If mask is nil and no ForeColour and MaskColour values are passed, the pixels a copied to the destination picture.

2. But if there is a mask, the pixels are copied with applying the mask.

3. If the mask color is not defined, the the pixels are filled with the fore color applying the mask.

4. As the last variation the pixels are copied and the forecolor, the mask color or black is used with the image as the mask. If UseColours parameter is false black is used for this.

Parameters:
Image: the source picture, must not be nil.
PreMultipliedSource: Optional parameter. If true the image must be premultiplied. Default is false.
Mask: the mask picture, can be nil.
DestX: destination position
DestY: destination position
SourceX: source position
SourceY: source position
Width: width of the area to copy
Height: height of the area to copy
UseColours: whether to use the mask colour.
ForeColour: the fore colour, optional, can be integer or color
MaskColour: the mask color, optional, can be integer or color

This function is 5 times in the plugin defined to implement having the last two parameters optional and either integer or color. You can pass a negative number for MaskColour or ForeColour to disable this parameter.

The images you use can be Gray, RGB with or without alpha channels. But most variants here ignore alpha channels. To make sure the alpha channel is not touched, use the PictureMBS.RGBChannels function and pass that new PictureMBS.

See also:

Feedback, Comments & Corrections

PictureMBS.Combine(Image As PictureMBS, PreMultipliedSource as boolean, Mask As PictureMBS, DestX as Integer, DestY as Integer, SourceX as Integer, SourceY as Integer, Width as Integer, Height as Integer, UseColours As Boolean, ForeColour as Integer, MaskColour as Integer) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Large Picture MBS Images Plugin 10.3 Yes Yes Yes Yes No
Function: Copies pixels from one picture into another picture with some options.
Notes:
Returns true on success and false on failure.

This function has 4 behaviors depending on the parameters:

1. If mask is nil and no ForeColour and MaskColour values are passed, the pixels a copied to the destination picture.

2. But if there is a mask, the pixels are copied with applying the mask.

3. If the mask color is not defined, the the pixels are filled with the fore color applying the mask.

4. As the last variation the pixels are copied and the forecolor, the mask color or black is used with the image as the mask. If UseColours parameter is false black is used for this.

Parameters:
Image: the source picture, must not be nil.
PreMultipliedSource: Optional parameter. If true the image must be premultiplied. Default is false.
Mask: the mask picture, can be nil.
DestX: destination position
DestY: destination position
SourceX: source position
SourceY: source position
Width: width of the area to copy
Height: height of the area to copy
UseColours: whether to use the mask colour.
ForeColour: the fore colour, optional, can be integer or color
MaskColour: the mask color, optional, can be integer or color

This function is 5 times in the plugin defined to implement having the last two parameters optional and either integer or color. You can pass a negative number for MaskColour or ForeColour to disable this parameter.

The images you use can be Gray, RGB with or without alpha channels. But most variants here ignore alpha channels. To make sure the alpha channel is not touched, use the PictureMBS.RGBChannels function and pass that new PictureMBS.

See also:

Feedback, Comments & Corrections

PictureMBS.Combine(Mask As PictureMBS, X as Integer, Y as Integer, Width as Integer, Height as Integer, BackColour As color) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Large Picture MBS Images Plugin 15.1 Yes Yes Yes Yes No
Function: Combines picture with mask and background color.

See also:

Feedback, Comments & Corrections

PictureMBS.CompareImages(other as PictureMBS) as Int64
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Large Picture MBS Images Plugin 10.3 Yes Yes Yes Yes No
Function: Compares two pictures.
Example:
dim p as new PictureMBS(1000,1000, PictureMBS.imageFormatRGB)

// fill random
p.FillRectRandom

dim q as new PictureMBS(1000,1000, PictureMBS.imageFormatRGB)

// copy pixels
call q.CopyPixels(p, 0, 0, 1000, 1000, 0, 0)
q.FillRect(0,0,10,10,0) // fill 100 pixels

// show image
Backdrop = q.CopyPicture

// and compare
Title = str(p.CompareImages(q)) // shows 100
Notes:
Returns -1 if both pictures are not from the same structure. (e.g. compare gray with RGB)
Else returns the number of different pixels.

Feedback, Comments & Corrections

PictureMBS.Constructor(Buf as MemoryBlock, width as Integer, height as Integer, ImageFormat as Integer, RowSize as Integer)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Large Picture MBS Images Plugin 9.0 Yes Yes Yes Yes No
Function: Creates a PictureMBS object based on a memoryblock.

See also:

Feedback, Comments & Corrections

PictureMBS.Constructor(pic as picture, UseAlpha as boolean=false)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Large Picture MBS Images Plugin 8.7 Yes No No Yes, macOS only No
Function: Creates a PictureMBS which shares memory with the given picture.
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

canvas1.Backdrop = p

// create PictureMBS
dim pic as new PictureMBS(p, true)
dim mask as new PictureMBS(p.mask)

// draw mask into alpha channel
call pic.AlphaChannel.CopyPixels(mask,0,0,mask.Width,mask.Height,0,0)

// and copy back to REALbasic picture
canvas2.Backdrop = pic.CopyPictureWithMask
Notes:
All drawings in the Picture and in the PictureMBS object will be visible in both objects.
This function works on Mac OS and Windows with both 24 bit and 32 bit pictures.
On Mac this function can fail if the picture is not a GWorld (Bitmap) picture.

The Valid property is set to true on success.

If you set UseAlpha=True, the 4th channel in a 32 bit picture is available for you as an alpha channel. REALbasic does not use the 4th channel in the picture data and 24 bit pictures do not have one. So you can use 32 bit pictures, copy the pictures mask in the alpha channel (using PictureMBS.AlphaChannel. inverting may be needed), perform some operations and later make a copy of the of the image to a picture and extract the alpha channel back into the pictue's mask.

Added support for Console/Web targets in 12.2 plugins. Please be aware that alpha channel of pictures with alpha channel has only a range from 0 to 127 for the values.

See also:

Feedback, Comments & Corrections

PictureMBS.Constructor(width as Integer, height as Integer, ImageFormat as Integer)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Large Picture MBS Images Plugin 8.7 Yes Yes Yes Yes No
Function: Creates a new PictureMBS object with the given size and Imageformat.
Notes:
ImageFormat must be one of the ImageFormat constants.
The Valid property is set to true on success.

The constructor allocated address space for the image.
Physical memory is allocated based on write access to pixels.

See also:

Feedback, Comments & Corrections

PictureMBS.Constructor(width as Integer, height as Integer, ImageFormat as Integer, BlockSize as Integer, FilePath as folderitem)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Large Picture MBS Images Plugin 8.7 Yes Yes Yes Yes No
Function: Creates a PictureMBS object using virtual memory.
Example:
dim mm as int64 = Picturembs.CalculateMemory(7000, 150000, PictureMBS.ImageFormatRGB)
// shows that this size needs 3 GB in memory

// create image
dim blocksize as Integer = 100*1024*1024
dim file as FolderItem = GetTemporaryFolderItem
dim pic as new PictureMBS(7000, 150000, PictureMBS.ImageFormatRGB, blocksize, file)

// draw dots on it
for x as Integer = 0 to pic.Width step 500
for y as Integer = 0 to pic.Height step 500
pic.FillRect(x, y, 100, 100, 175)
next
next

// write to tiff
dim f as FolderItem = SpecialFolder.Desktop.Child("test.tif")
dim t as TiffPictureMBS

if pic <> nil then
t = new TiffPictureMBS

if t.Create(F) then

const PLANARCONFIG_CONTIG = 1
const PHOTOMETRIC_RGB = 2
const FILLORDER_MSB2LSB = 1
const RESUNIT_INCH = 2
const ORIENTATION_TOPLEFT = 1
const COMPRESSION_LZW = 5

t.Height = pic.Height
t.Width = pic.Width

t.RowsPerStrip = 1
t.PlanarConfig = PLANARCONFIG_CONTIG
t.Photometric = PHOTOMETRIC_RGB
t.BitsPerSample = 8
t.SamplesPerPixel = 3
t.FillOrder = FILLORDER_MSB2LSB
t.Orientation = ORIENTATION_TOPLEFT
t.ResolutionUnit = RESUNIT_INCH
t.VerticalResolution = 72.0
t.HorizontalResolution = 72.0
t.Compression = COMPRESSION_LZW

for i as Integer = 0 to t.Height - 1
dim m as MemoryBlock = pic.RowInFormat(i, PictureMBS.ImageFormatRGB)
t.Scanline(i) = m

next

t.Close
end if
else

end if

// cleanup
pic = nil
file.delete
Notes:
The size of this image is limited to available hard disc space.
The system will cache this data in memory to avoid writing it to disc. Using picture sizes bigger than physical memory can result into slow processing.

FilePath points to the location where the file is created.
On Windows the FilePath can be nil in which space in the system swapfile is used.
On Mac/Linux with nil FilePath, we use automatically a temp file path.

BlockSize specifies how many bytes of memory should be used in application memory space. A typical value may be 100 mega bytes.

The Valid property is set to true on success.
File is deleted in destructor and folderitem is than invalid.

See also:

Feedback, Comments & Corrections

PictureMBS.CopyGWorld as Variant
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Large Picture MBS Images Plugin 10.1 Yes No No Yes, macOS only No
Function: Creates a GWorld with a copy of the picture data.
Example:
// get a PictureMBS object somewhere
dim pic as Picture = LogoMBS(500)
dim p as Picturembs = new PictureMBS(pic)

// make a gworld from it.
dim g as GWorldMBS = p.CopyGWorld

// for debugging show content
Backdrop = g.CopyPicture

// Export to TIFF with Quicktime Graphics Exporter
dim q as new QTGraphicsExporterMBS

q.OpenExporter("TIFF")
q.InputGWorldHandle = g.Handle
q.CompressionQuality = &h400
q.OutputFile = SpecialFolder.Desktop.Child("test.tif")

if q.Export>0 then
MsgBox "OK"
end if
Notes: Works with 8 bit gray and with RGB data.

Feedback, Comments & Corrections

PictureMBS.CopyMask as picture
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Large Picture MBS Images Plugin 8.7 Yes Yes Yes Yes No
Function: Copies the alpha channel into a mask picture.
Notes:
Be aware that PictureMBS objects can have more pixels than picture objects can store, so this will not always work.
Returns nil on any error (e.g. out of memory).
Works for all pictures with alpha channel.

See also:

Feedback, Comments & Corrections

PictureMBS.CopyMask(x as Integer, y as Integer, w as Integer, h as Integer) as picture
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Large Picture MBS Images Plugin 8.7 Yes Yes Yes Yes No
Function: Copies the given area of the alpha channel into a mask picture.
Notes:
Be aware that PictureMBS objects can have more pixels than picture objects can store, so this will not always work.
Returns nil on any error (e.g. out of memory).
Works for all pictures with alpha channel.

See also:

Feedback, Comments & Corrections

Previous items Next items

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




Links
MBS Xojo Plugins