Xojo Developer Conference
25/27th April 2018 in Denver.
MBS Xojo Conference
6/7th September 2018 in Munich, Germany.

Platforms to show: All Mac Windows Linux Cross-Platform

NewPictureReaderMBS(pic as picture) as PictureReaderMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
global method Graphics & Pictures MBS Picture Plugin 6.5 Yes Yes Yes Yes No
Function: Creates a new picture reader.
Example:
dim pic as Picture = LogoMBS(500)
dim p as PictureReaderMBS
dim m as MemoryBlock
dim r,g,b,rRow,gRow,bRow,h1,w1,x,y,bpp as Integer

// Create a new picture reader
p=NewPictureReaderMBS(pic)

h1=p.Height-1
w1=p.Width-1

bpp=p.BytesPerPixel
rRow=p.RedOffset
gRow=p.GreenOffset
bRow=p.BlueOffset
// in each row the red, blue and green channels have different offsets.
// but offsets are platform dependend

dim sum as Double

for y=0 to h1
// Get data in memory. This Memoryblock has a size property of 0!
m=p.Data(y)
r=rRow
g=gRow
b=bRow

for x=0 to w1

sum = sum + m.UInt8Value(r)
sum = sum + m.UInt8Value(g)
sum = sum + m.UInt8Value(b)

r=r+bpp
g=g+bpp
b=b+bpp
next

next

// show the sum of all pixels:
MsgBox "Sum with plugin is: "+str(sum)


// now try same in RB code:

dim surface as RGBSurface = pic.RGBSurface
dim c as color

sum = 0.0

for y=0 to h1
for x=0 to w1
c = surface.Pixel(x,y)

sum = sum + c.red
sum = sum + c.Green
sum = sum + c.Blue

next

next

surface = nil

MsgBox "Sum with RB Code is: "+str(sum)
quit
Notes:
Returns nil on failure.
Please report if nil is returned as it should work always (except for low memory).

Some examples using this method:

Feedback, Comments & Corrections

NewPictureWriterMBS(width as Integer, height as Integer, AlphaChannel as boolean = false) as PictureWriterMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
global method Graphics & Pictures MBS Picture Plugin 6.5 Yes Yes Yes Yes No
Function: Creates a new picture writer.
Example:
dim p as PictureWriterMBS
dim m as MemoryBlock
dim r,g,b,rRow,gRow,bRow,h1,w1,x,y,bpp as Integer

// Create a new picture writer
p=NewPictureWriterMBS(512,512)

h1=p.Height-1
w1=p.Width-1

bpp=p.BytesPerPixel
rRow=p.RedOffset
gRow=p.GreenOffset
bRow=p.BlueOffset
// in each row the red, blue and green channels have different offsets.
// but offsets are platform dependend

for y=0 to h1
// Get data in memory. This Memoryblock has a size property of 0!
m=p.Data(y)
r=rRow
g=gRow
b=bRow

for x=0 to w1

m.UInt8Value(r)=x\2
m.UInt8Value(g)=y\2
m.UInt8Value(b)=x*y\2

r=r+bpp
g=g+bpp
b=b+bpp
next

next

// Use Render to make a picture object
dim pic as Picture = p.Render
Backdrop = pic
Notes:
Returns nil on failure (low memory).
If alpha is requested, but not possible in the given version of Xojo (or Real Studio), we return a picture without.

Some examples using this method:

Feedback, Comments & Corrections

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




Links
MBS Xojo Chart Plugins