Platforms to show: All Mac Windows Linux Cross-Platform

Back to Picture class.

Picture.CopyARGBtoMemoryblockMBS(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.
Example
dim m as MemoryBlock
dim p,q as Picture

p=New Picture(100,100,32)
p.Graphics.ForeColor=rgb(255,128,1)
p.Graphics.FillRect 0,0,100,100

// Make a new MemoryBlock
m=NewMemoryBlock(100*100*4) // 3 bytes per Pixel

// Copy RGB without alpha
if p.CopyARGBtoMemoryblockMBS(m,0,0) then

dim x as Picture = New Picture(100,100,32)

q=MemoryblockARGBtoPictureMBS(x, m,0,100,100)

Backdrop=q

if x=q then
window1.Title = "reused picture"
else
window1.Title = "created new picture"
end if
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.

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.CopyARGBtoMemoryblockMBS(destination as memoryblock, offset as Integer, LittleEndian as boolean, 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 5.3 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Copies raw image data into a memoryblock.
Example
dim m as MemoryBlock
dim p as Picture

p=New Picture(100,100,32)
p.Graphics.ForeColor=rgb(255,128,1)
p.Graphics.FillRect 0,0,100,100

// Make a new MemoryBlock
m=NewMemoryBlock(100*100*4) // 4 bytes per Pixel

// copy RGB and leave room for alpha
if p.CopyARGBtoMemoryblockMBS(m,0,false,-1) then
MsgBox EncodingToHexMBS(m.StringValue(0,99))
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.

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!

LittleEndian specifies whether the image is stored in ARGB (BigEndian) or BGRA (LittleEndian) mode.

If Alphavalue is in range of 0 to 255 the alpha value of all pixel is set to this value. If the AlphaValue is outside this range the alpha value is not touched for all pixels.

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:

Picture.CopyARGBtoMemoryblockMBS(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.CopyARGBtoMemoryblockMBS(m, 0, p.Mask) then
// convert back
Backdrop = MemoryblockARGBtoPictureMBS(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...