Xojo Conferences
MBSSep2018MunichDE
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

MemoryblockARGBtoPictureMBS(source as memoryblock, offset as Integer, width as Integer, height as Integer, LittleEndian as boolean) as picture
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
global method Graphics & Pictures MBS Picture Plugin 6.3 Yes Yes Yes Yes No
Function: Copies image data from a memoryblock into a picture object.
Example:
const kAlphaOffset=0 ' (BigEndian) and 3 (LittleEndian)
dim m as MemoryBlock
dim p,q,k as Picture

p=NewPicture(100,100,32)
p.Graphics.ForeColor=rgb(255,128,1)
p.Graphics.FillRect 0,0,100,100
p.mask.Graphics.ForeColor=rgb(127,127,127)
p.mask.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

// copy green channel from mask image into Memoryblock
if p.mask.CopyGtoMemoryblockMBS(m,kAlphaOffset,4) then
'MsgBox EncodingToHexMBS(m.StringValue(0,99))
end if

// make the picture from this Memoryblock
q=MemoryblockARGBtoPictureMBS(m,0,100,100,false)

// make the mask from this Memoryblock
k=MemoryblockGrayToPictureMBS(m,kAlphaOffset,100,100,4)

// combine picture and mask
q.Mask.Graphics.DrawPicture k,0,0

Backdrop=q
Notes:
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.

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

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

Feedback, Comments & Corrections

MemoryblockRGBtoPictureMBS(source as memoryblock, offset as Integer, width as Integer, height as Integer) as picture
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
global method Graphics & Pictures MBS Picture Plugin 6.3 Yes Yes Yes Yes No
Function: Copies image data from a memoryblock into a picture object.
Example:
dim m as MemoryBlock
dim p,q as Picture

p=NewPicture(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.CopyRGBtoMemoryblockMBS(m,0) then

q=MemoryblockRGBtoPictureMBS(m,0,100,100)

Backdrop=q

end if
Notes:
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.

Some examples using this method:

Feedback, Comments & Corrections

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





Links
MBS FileMaker blog