Platforms to show: All Mac Windows Linux Cross-Platform

Back to Picture class.

Picture.CopyABGRtoMemoryblockMBS(destination as memoryblock, offset as Integer, AlphaValue as Integer, StartLine as Integer = 0, EndLine as Integer = -1, Yield as Integer = 0, DestRowBytes as Integer = 0) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Graphics & Pictures MBS Picture Plugin 8.5 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Copies raw image data into a memoryblock.

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.

StartLine and Endline define the range of source lines from picture. Range is from 0 to picture.height-1. if Endline is -1, we use picture.height-1 internally. Yield specifies how much CPU time is given to other threads. If yield = 0, we give no CPU time away. If yield is > 0, we yield every yield/60th second to other threads. If DestRowBytes is not zero, it specifies the bytes per row in the target memoryblock for each line.

See also:

Picture.CopyABGRtoMemoryblockMBS(destination as memoryblock, offset as Integer, MaskForAlpha as picture, StartLine as Integer = 0, EndLine as Integer = -1, Yield as Integer = 0, DestRowBytes as Integer = 0) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Graphics & Pictures MBS Picture Plugin 13.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Copies raw image data into a memoryblock.
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

// convert to memoryblock
dim m as new MemoryBlock(4 * p.Width * p.Height)

if p.CopyABGRtoMemoryblockMBS(m, 0, p.Mask) then
// convert back
Backdrop = MemoryblockABGRtoPictureMBS(m, 0, p.Width, p.Height)

break // look into memoryblock with debugger
end if

Returns true on success.
destination should not be nil.
offset should be 0 or bigger and is the start position in the memoryblock.
MaskForAlpha should not be nil and be the mask for this image.

The function will crash if the memoryblock is too small. Needs picture.width*picture.height*4 bytes in the memoryblock. Mask and Picture must have equal size.
The mask is used to fill alpha channel.

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.

StartLine and Endline define the range of source lines from picture. Range is from 0 to picture.height-1. if Endline is -1, we use picture.height-1 internally. Yield specifies how much CPU time is given to other threads. If yield = 0, we give no CPU time away. If yield is > 0, we yield every yield/60th second to other threads. If DestRowBytes is not zero, it specifies the bytes per row in the target memoryblock for each line.

See also:

Blog Entries

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


The biggest plugin in space...