Xojo Conferences
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

MemoryblockABGRtoPictureMBS(dest as picture, 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 10.1 Yes Yes Yes Yes No
Function: Copies image data from a memoryblock into a picture object.
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.

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:

Feedback, Comments & Corrections

MemoryblockABGRtoPictureMBS(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 8.5 Yes Yes Yes Yes No
Function: 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.CopyABGRtoMemoryblockMBS(m, 0, p.Mask) then
// convert back
Backdrop = MemoryblockABGRtoPictureMBS(m, 0, p.Width, p.Height)

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

See also:

Feedback, Comments & Corrections

MemoryblockARGBtoPictureMBS(dest as picture, 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 10.1 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*4) // 3 bytes per Pixel

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

dim x as Picture = NewPicture(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
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.

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:

Feedback, Comments & Corrections

MemoryblockARGBtoPictureMBS(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 8.5 Yes Yes Yes Yes No
Function: 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.CopyARGBtoMemoryblockMBS(m, 0, p.Mask) then
// convert back
Backdrop = MemoryblockARGBtoPictureMBS(m, 0, p.Width, p.Height)

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

See also:

Feedback, Comments & Corrections

MemoryblockBGRAtoPictureMBS(dest as picture, 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 10.1 Yes Yes Yes Yes No
Function: 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.CopyBGRAtoMemoryblockMBS(m, 0, p.Mask) then
// convert back
Backdrop = MemoryblockBGRAtoPictureMBS(nil, m, 0, p.Width, p.Height)

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

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

See also:

Feedback, Comments & Corrections

MemoryblockBGRAtoPictureMBS(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 8.5 Yes Yes Yes Yes No
Function: 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.CopyBGRAtoMemoryblockMBS(m, 0, p.Mask) then
// convert back
Backdrop = MemoryblockBGRAtoPictureMBS(m, 0, p.Width, p.Height)

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

See also:

Feedback, Comments & Corrections

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 Console & Web iOS
global method Graphics & Pictures MBS Picture Plugin 10.1 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.CopyBGRtoMemoryblockMBS(m,0) then

dim x as Picture = NewPicture(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
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.

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:

Feedback, Comments & Corrections

MemoryblockBGRtoPictureMBS(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 8.5 Yes Yes Yes Yes No
Function: Copies image data from a memoryblock into a picture object.
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.

See also:

Feedback, Comments & Corrections

MemoryblockGrayToPictureMBS(source as memoryblock, offset as Integer, width as Integer, height as Integer, PixelByteSize 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:
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*PixelByteSize 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:

Some examples using this method:

Feedback, Comments & Corrections

MemoryblockGrayToPictureMBS(source as memoryblock, offset as Integer, width as Integer, height as Integer, PixelByteSize as Integer, Red as Integer, Blue as Integer, Green as Integer) as picture
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
global method Graphics & Pictures MBS Picture Plugin 8.5 Yes Yes Yes Yes No
Function: Copies image data from a memoryblock into a picture object.
Notes:
This variantion of this method Multiplies the gray value with Red, Blue and Green and divided by 256.

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*PixelByteSize 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:

Some examples using this method:

Feedback, Comments & Corrections

MemoryblockGrayToPictureMBS(source as memoryblock, offset as Integer, width as Integer, height as Integer, PixelByteSize as Integer, Red() as Integer, Blue() as Integer, Green() as Integer) as picture
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
global method Graphics & Pictures MBS Picture Plugin 8.5 Yes Yes Yes Yes No
Function: Copies image data from a memoryblock into a picture object.
Notes:
This variantion of this method lookups the Red, Green and Blue values for the next pixel by using the gray value as index.

The arrays should have 256 elements.

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*PixelByteSize 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:

Some examples using this method:

Feedback, Comments & Corrections

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 Console & Web iOS
global method Graphics & Pictures MBS Picture Plugin 10.1 Yes Yes Yes Yes No
Function: 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
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.

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:

Feedback, Comments & Corrections

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 Console & Web iOS
global method Graphics & Pictures MBS Picture Plugin 8.5 Yes Yes Yes Yes No
Function: 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
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.

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:

Feedback, Comments & Corrections

MemoryblockRGBtoPictureMBS(dest as picture, 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 10.1 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

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

q=MemoryblockRGBtoPictureMBS(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
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.

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.

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 Xojo tutorial videos