Platforms to show: All Mac Windows Linux Cross-Platform

MemoryblockRGBAtoPictureMBS(dest as picture, source as memoryblock, offset as Integer, width as Integer, height as Integer, FlipVertically as boolean=false) 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
// 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.CopyRGBAtoMemoryblockMBS(m, 0, p.Mask) then
// convert back
Backdrop = MemoryblockRGBAtoPictureMBS(m, 0, p.Width, p.Height)

break // look into memoryblock with debugger
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*4 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.

If FlipVertically is true the image is flipped. New in version 9.4.

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

See also:

MemoryblockRGBAtoPictureMBS(source as memoryblock, offset as Integer, width as Integer, height as Integer, FlipVertically as boolean=false) 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
// some memory with pixel data
dim m as MemoryBlock = NewMemoryBlock(100*100*32)

for i as Integer = 1 to 1000
// place random pixels
m.Int8Value(rnd*m.size) = rnd*256
next

// and make a picture
dim l as Picture = MemoryBlockRGBAtoPictureMBS(m, 0, 100, 100)

// display in window
window1.backdrop = l

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*4 bytes in the memoryblock.

If FlipVertically is true the image is flipped. New in version 9.4.

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