Platforms to show: All Mac Windows Linux Cross-Platform

Back to PictureMBS class.

Previous items

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 iOS Targets
method Large Picture MBS Images Plugin 10.3 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Copies pixels from one picture into another picture with some options.

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:

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 iOS Targets
method Large Picture MBS Images Plugin 10.3 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Copies pixels from one picture into another picture with some options.
Example
Var DestImage As PictureMBS
Var Image As PictureMBS
Var Mask As PictureMBS
Var DestX as Integer=100
Var DestY as Integer=100
Var SourceX as Integer=0
Var SourceY as Integer=0
Var Width as Integer=500
Var Height as Integer=500
Var UseColours as Boolean = false
Var 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

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:

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 iOS Targets
method Large Picture MBS Images Plugin 10.3 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Copies pixels from one picture into another picture with some options.

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:

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 iOS Targets
method Large Picture MBS Images Plugin 15.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Combines picture with mask and background color.

See also:

PictureMBS.CompareImages(other as PictureMBS) as Int64

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Large Picture MBS Images Plugin 10.3 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Compares two pictures.
Example
Var p as new PictureMBS(1000,1000, PictureMBS.imageFormatRGB)

// fill random
p.FillRectRandom

Var 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

Returns -1 if both pictures are not from the same structure. (e.g. compare gray with RGB)
Else returns the number of different pixels.

PictureMBS.Constructor(pic as picture, UseAlpha as boolean=false)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Large Picture MBS Images Plugin 8.7 ✅ Yes ❌ No ❌ No ✅ Yes All
Creates a PictureMBS which shares memory with the given picture.
Example
// Create a picture with mask:
Var p as Picture = LogoMBS(200)
Var 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
Var pic as new PictureMBS(p, true)
Var 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 Xojo picture
canvas2.Backdrop = pic.CopyPictureWithMask

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. Xojo 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:

PictureMBS.Constructor(width as Integer, height as Integer, ImageFormat as Integer)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Large Picture MBS Images Plugin 8.7 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Creates a new PictureMBS object with the given size and Imageformat.

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:

PictureMBS.Constructor(width as Integer, height as Integer, ImageFormat as Integer, BlockSize as Int64, FilePath as folderitem)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Large Picture MBS Images Plugin 8.7 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Creates a PictureMBS object using virtual memory.
Example
Var mm as int64 = Picturembs.CalculateMemory(7000, 150000, PictureMBS.ImageFormatRGB)
// shows that this size needs 3 GB in memory

// create image
Var blocksize as Integer = 100*1024*1024
Var file as FolderItem = GetTemporaryFolderItem
Var 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
Var f as FolderItem = SpecialFolder.Desktop.Child("test.tif")
Var 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
Var 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

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:

PictureMBS.CopyMask as picture

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Large Picture MBS Images Plugin 8.7 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Copies the alpha channel into a mask picture.

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:

PictureMBS.CopyMask(x as Integer, y as Integer, w as Integer, h as Integer) as picture

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Large Picture MBS Images Plugin 8.7 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Copies the given area of the alpha channel into a mask picture.

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:

PictureMBS.CopyPicture as picture

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Large Picture MBS Images Plugin 8.7 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Copies the RGB channels or the gray channel into a picture.
Example
// get some picture
Var logo as Picture = LogoMBS(500)

// create PictureMBS
Var rgb as new PictureMBS(logo)

// Create a gray picture and copy RGB to gray
Var g as new PictureMBS(500, 500, PictureMBS.ImageFormatG)
call g.CopyPixels(rgb)

// Create CMYK and fill cyan channel with grayscale image
Var cmyk as new PictureMBS(500, 500, PictureMBS.ImageFormatCMYK)
call cmyk.MagentaChannel.CopyPixels(g)

// display it
Backdrop = cmyk.CopyPicture

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 with Gray, RGB and CMYK pictures and supports alpha channel. For CMYK we have some simply conversion to RGB to give you a preview. For a real world application, use Color Conversion like our LCMS plugin.

See also:

PictureMBS.CopyPicture(x as Integer, y as Integer, w as Integer, h as Integer) as picture

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Large Picture MBS Images Plugin 8.7 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Copies the RGB channels or the gray channel in the given area into a picture.

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 with Gray, RGB and CMYK pictures and supports alpha channel. For CMYK we have some simply conversion to RGB to give you a preview. For a real world application, use Color Conversion like our LCMS plugin.

See also:

PictureMBS.CopyPictureWithAlpha as picture

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Large Picture MBS Images Plugin 18.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Copies picture with alpha.

Returns a picture with HasAlphaChannel = true.

See also:

PictureMBS.CopyPictureWithAlpha(x as integer, y as integer, w as integer, h as integer) as picture

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Large Picture MBS Images Plugin 18.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Copies picture in rectangle with alpha.

Returns a picture with HasAlphaChannel = true.

See also:

PictureMBS.CopyPictureWithMask as picture

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Large Picture MBS Images Plugin 8.7 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Copies the picture with mask.

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 with Gray, RGB and CMYK pictures and supports alpha channel. For CMYK we have some simply conversion to RGB to give you a preview. For a real world application, use Color Conversion like our LCMS plugin.

See also:

PictureMBS.CopyPictureWithMask(x as Integer, y as Integer, w as Integer, h as Integer) as picture

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Large Picture MBS Images Plugin 8.7 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Copies the picture with mask in the given area.

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 with Gray, RGB and CMYK pictures and supports alpha channel. For CMYK we have some simply conversion to RGB to give you a preview. For a real world application, use Color Conversion like our LCMS plugin.

See also:

PictureMBS.CopyPixels(source as PictureMBS) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Large Picture MBS Images Plugin 8.7 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Copies all pixels from the source picture to the current picture.
Example
Var l as Picture = LogoMBS(500)
Var p as new PictureMBS(l)
// create new picture:
// can be any image format: ImageFormatRGB, ImageFormatG, ImageFormatBGR, etc.
Var d as new PictureMBS(l.Width, l.Height, PictureMBS.ImageFormatRGB)

if d.CopyPixels(p) then
Backdrop = d.CopyPicture
else
MsgBox "Failed."
end if

This function is optimized for several image formats:
- Gray to Gray.
- RGB to Gray uses R*0.3+G*0.59+B*0.11.
- RGB to RGB.
- Gray to RGB fill red, green and blue with the same gray value.
- CMYK to CMYK
- CMYK to Gray, copies from black channel
- Gray to CMYK, copies to black channel
If an alpha channel exists in both images, it is copied.

See also:

Some examples using this method:

PictureMBS.CopyPixels(source as PictureMBS, DestX as Integer, DestY as Integer, DestWidth as Integer, DestHeight as Integer) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Large Picture MBS Images Plugin 8.7 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Copies pixels from the source picture to the current picture.
Example
Var l as Picture = LogoMBS(500)
Var p as new PictureMBS(l)
Var d as new PictureMBS(700, 700, PictureMBS.ImageFormatRGB)

if d.CopyPixels(p,100,100,500,500) then
Backdrop = d.CopyPicture
else
MsgBox "Failed."
end if

DestWidth and DestHeight specify how many pixels are copied.
DestX/DestY specify the destination position in the current picture.

This function is optimized for several image formats:
- Gray to Gray.
- RGB to Gray uses R*0.3+G*0.59+B*0.11.
- RGB to RGB.
- Gray to RGB fill red, green and blue with the same gray value.
- CMYK to Gray, copies from black channel
- Gray to CMYK, copies to black channel
If an alpha channel exists in both images, it is copied.

See also:

PictureMBS.CopyPixels(source as PictureMBS, DestX as Integer, DestY as Integer, DestWidth as Integer, DestHeight as Integer, SourceX as Integer, SourceY as Integer) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Large Picture MBS Images Plugin 8.7 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Copies pixels from the source picture to the current picture.
Example
Var l as Picture = LogoMBS(500)
Var p as new PictureMBS(l)
Var d as new PictureMBS(700, 700, PictureMBS.ImageFormatRGB)

if d.CopyPixels(p,100,100,500,500,0,0) then
Backdrop = d.CopyPicture
else
MsgBox "Failed."
end if

SourceX/SourceY is the position in the source picture.
DestWidth/DestHeight specify how many pixels are copied.
DestX/DestY specify the destination position in the current picture.

This function is optimized for several image formats:
- Gray to Gray.
- RGB to Gray uses R*0.3+G*0.59+B*0.11.
- RGB to RGB.
- Gray to RGB fill red, green and blue with the same gray value.
- CMYK to Gray, copies from black channel
- Gray to CMYK, copies to black channel
If an alpha channel exists in both images, it is copied.

See also:

PictureMBS.CreatePictureMBS(width as Integer, height as Integer, ImageFormat as Integer) as PictureMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Large Picture MBS Images Plugin 9.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Creates a new PictureMBS object.

Returns nil if no factory can create a valid picture.

First the Factory on the current ImageMBS object (self) is asked to create the picture.
Second the global Factory object is asked.
Third the normal PictureMBS constructor is used.

See also:

Some examples using this method:

PictureMBS.CyanChannel as PictureMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Large Picture MBS Images Plugin 11.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
The cyan channel of a CMYK picture as a new PictureMBS object.

Returns nil if this channel does not exist.
No copy is made of the actual pixel data. Modifying the channel picture will modify the original picture.
Use this function to access the pixels of the channel directly.
The resulting PictureMBS object is a grayscale picture.

Previous items

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


The biggest plugin in space...