Platforms to show: All Mac Windows Linux Cross-Platform

MemoryblockBGRtoPictureMBS(dest as picture, source as memoryblock, offset as Integer, width as Integer, height as Integer) as picture

Type Topic Plugin Version macOS Windows Linux iOS Targets
global method Graphics & Pictures MBS Picture Plugin 10.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Copies image data from a memoryblock into a picture object.
Example
Var m as MemoryBlock
Var 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*3) // 3 bytes per Pixel

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

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

q=MemoryblockBGRtoPictureMBS(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 nil on any error.
source 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 width*height*3 bytes in the memoryblock.

In the dest picture parameter you can provide a picture to draw in. If the picture is no big enough or nil, a new one is created.

Does not access the mask inside the image!
Data is copied from memory block to the new picture, not referenced.

See also:

MemoryblockBGRtoPictureMBS(source as memoryblock, offset as Integer, width as Integer, height as Integer) as picture

Type Topic Plugin Version macOS Windows Linux iOS Targets
global method Graphics & Pictures MBS Picture Plugin 8.5 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Copies image data from a memoryblock into a picture object.
Example
// convert raw BGR pixels with 3 bytes each from a MemoryBlock into a picture, e.g. data from a camera or library
Var w As Integer = 100
Var h As Integer = 50
Var m As New MemoryBlock(w * h * 3) // BGR pixels with 3 bytes each
For i As Integer = 0 To m.Size - 1
m.Byte(i) = (i \ 3 Mod w) * 255 \ w // a simple gradient
Next
Var result As Picture = MemoryblockBGRtoPictureMBS(m, 0, w, h)
If result <> Nil Then System.DebugLog result.Width.ToString + " x " + result.Height.ToString

Returns nil on any error.
source 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 width*height*3 bytes in the memoryblock.

Does not access the mask inside the image!
Data is copied from memory block to the new picture, not referenced.

See also:

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


The biggest plugin in space...