Platforms to show: All Mac Windows Linux Cross-Platform

Previous items

Picture.MakeHBITMAPMBS as integer
method, Graphics & Pictures, MBS REALbasic Picture Plugin (Picture), class Picture, Mac OS X: Does nothing, Windows: Works, Linux x86: Does nothing, Feedback.

Function: Returns a HBITMAP handle to the picture.
Notes:
The picture is cloned but both pictures may use the same binary data in background.

You will have to free this handle with DeleteObject:
Declare Function DeleteObject Lib "gdi32" (hObject As Integer) As Integer
Picture.MirrorMBS as picture
method, Graphics & Pictures, MBS REALbasic Picture Plugin (PictureRotate), class Picture, Plugin version: 7.8, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Mirrors the picture vertically and horizontally.
Example:
canvas1.backdrop=pic.MirrorMBS

Notes:
Same as rotation by 180 degree.
This method returns a copy of the picture mirrored.
Returns nil on low memory.

Some examples which use this method:

Picture.MirrorPictureMBS as boolean
method, Graphics & Pictures, MBS REALbasic Picture Plugin (PictureRotate), class Picture, Plugin version: 7.8, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Mirrors the picture vertically and horizontally.
Example:
if pic.MirrorPictureMBS then // mirror picture
canvas1.backdrop=pic
else
canvas1.backdrop=pic.MirrorMBS // mirror a copy
end if

Notes:
Same as rotation by 180 degree.
This methods mirrors the picture data itself. Returns true on success and false on failure. Only bitmap pictures can be mirrored this way.

Some examples which use this method:

Picture.PaletteMBS as PaletteMBS
method, Graphics & Pictures, MBS REALbasic Picture Plugin (PicturePalette), class Picture, Mac OS X: Works, Windows: Does nothing, Linux x86: Does nothing, Feedback.

Function: Set or get the PaletteMBS of this picture.
Notes:
On Windows, always nil.
May return nil if no PaletteMBS is used for that picture.
(Read and Write computed property)

Some examples which use this method:

Picture.PicHandleDataMBS as string
method, Graphics & Pictures, MBS REALbasic Picture Plugin (Picture), class Picture, Plugin version: 4.1, Mac OS X: Works, Windows: Does nothing, Linux x86: Does nothing, Feedback.

Function: Returns the picture data as PICT data.
Example:
dim p as Picture
dim s as string

p=LogoMBS(500)
Backdrop=p

s=p.PicHandleDataMBS

title= str(len(s))

EditField1.text=S

Notes:
If the picture is not a PicHandle picture, it is first converted.
The resulting data may have a 512 byte header which must be removed if you want to put the data into the clipboard.
Returns "" on any error.

Some examples which use this method:

Picture.PicHandleMBS as picture
method, Graphics & Pictures, MBS REALbasic Picture Plugin (Picture), class Picture, Mac OS X: Works, Windows: Does nothing, Linux x86: Does nothing, Feedback.

Function: Clones the picture as a PicHandle picture.
Example:
dim p as picture

p=newpicture(100,100,32)
p.graphics.drawline 0,0,100,100

imageWell1.Image=p.picHandleMBS


Notes:
A Realbasic picture object may contain an icon, a bitmap, a picture handle or something else what Realbasic will support as a picture in the future.
This function return the picture as a pichandle picture so you can use it for an imagewell control.
Not sure if masks or transparency will work.

Some examples which use this method:

Picture.ReplaceBlueChannelMBS(BlueChannel as picture) as picture
method, Graphics & Pictures, MBS REALbasic Picture Plugin (Picture), class Picture, Plugin version: 9.4, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Returns a copy of the picture with the blue channel replaced with the blue channel of the given picture.
Notes: Returns nil on low memory.
Picture.ReplaceColorMBS(SearchColor as color, ReplaceWithColor as color) as picture
method, Graphics & Pictures, MBS REALbasic Picture Plugin (Picture), class Picture, Plugin version: 7.7, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Searches the given color and replaces it with the second color.
Example:
dim p as Picture

p=NewPicture(300,300,32)

p.Graphics.ForeColor=&cFF0000
p.Graphics.FillRect 000,100,100,100

p.Graphics.ForeColor=&c00FF00
p.Graphics.FillRect 100,100,100,100

p.Graphics.ForeColor=&c0000FF
p.Graphics.FillRect 200,100,100,100

p.Graphics.ForeColor=&c777700
p.Graphics.FillRect 100,200,100,100

// shows a violet box on the left. Other pixels unchanged
backdrop=p.ReplaceColorMBS(&cFF0000,&cFF00FF)

Notes:
All other pixels are copied to the new picture.
Returns nil on any error.
Picture.ReplaceGreenChannelMBS(GreenChannel as picture) as picture
method, Graphics & Pictures, MBS REALbasic Picture Plugin (Picture), class Picture, Plugin version: 9.4, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Returns a copy of the picture with the green channel replaced with the green channel of the given picture.
Notes: Returns nil on low memory.
Picture.ReplaceRedChannelMBS(RedChannel as picture) as picture
method, Graphics & Pictures, MBS REALbasic Picture Plugin (Picture), class Picture, Plugin version: 9.4, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Returns a copy of the picture with the red channel replaced with the red channel of the given picture.
Notes: Returns nil on low memory.
Picture.Rotate180MBS as picture
method, Graphics & Pictures, MBS REALbasic Picture Plugin (PictureRotate), class Picture, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Rotates the picture by 180° counter clockwise.
Example:
dim p,r as picture
r=LogoMBS(500)
p=r.cloneMBS
canvas1.backdrop=p.Rotate180MBS

Notes:
You may use the function picture.bitmap to make sure that the picture is a bitmap, because this function works only for bitmap pictures.

app.resourceFork.getpicture(148) is the about picture of REALbasic in the 4.5 release. This may change in future releases, so you will get nil. But using this picture will make the plugin download smaller.

Some examples which use this method:

Picture.Rotate270MBS as picture
method, Graphics & Pictures, MBS REALbasic Picture Plugin (PictureRotate), class Picture, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Rotates the picture by 270° counter clockwise.
Example:
dim p,r as picture
r=LogoMBS(500)
p=r.cloneMBS
canvas1.backdrop=p.Rotate270MBS

Notes:
You may use the function picture.bitmap to make sure that the picture is a bitmap, because this function works only for bitmap pictures.

app.resourceFork.getpicture(148) is the about picture of REALbasic in the 4.5 release. This may change in future releases, so you will get nil. But using this picture will make the plugin download smaller.

Some examples which use this method:

Picture.Rotate90MBS as picture
method, Graphics & Pictures, MBS REALbasic Picture Plugin (PictureRotate), class Picture, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Rotates the picture by 90° counter clockwise.
Example:
dim p,r as picture
r=LogoMBS(500)
p=r.cloneMBS
canvas1.backdrop=p.Rotate90MBS

Notes:
You may use the function picture.bitmap to make sure that the picture is a bitmap, because this function works only for bitmap pictures.

app.resourceFork.getpicture(148) is the about picture of REALbasic in the 4.5 release. This may change in future releases, so you will get nil. But using this picture will make the plugin download smaller.

Some examples which use this method:

Picture.RotateMBS(angle as double,background as color) as picture
method, Graphics & Pictures, MBS REALbasic Picture Plugin (PictureRotate), class Picture, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Rotates the picture by angle° counter clockwise.
Example:
dim p,r as picture
r=LogoMBS(500)
p=r.cloneMBS
canvas1.backdrop=p.RotateMBS(42.3,rgb(255,255,255))

Notes:
The area around the picture is filled using the backcolor.

You may use the function picture.bitmap to make sure that the picture is a bitmap, because this function works only for bitmap pictures.

app.resourceFork.getpicture(148) is the about picture of REALbasic in the 4.5 release. This may change in future releases, so you will get nil. But using this picture will make the plugin download smaller.

Some examples which use this method:

Picture.ScaleImageAndMaskMBS(width as integer, height as integer, AntiAlias as boolean=false, YieldTicks as integer=0) as picture
method, Graphics & Pictures, MBS REALbasic Picture Plugin (PictureScale), class Picture, Plugin version: 7.0, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Scales the picture to the new size including mask (in case one exists).
Notes:
This is a self made algorithm which produces nice pictures on all platforms.
It is slower than QuickDraw on Mac OS, but nicer than drawpicture on Windows.
Returns nil on low memory or invalid width and height values.

AntiAlias is set to false if width<=self.width or height<=self.height.

If YieldTicks is 0, no time is given to other threads in your application. If it is a value > 0, this time is waited before a thread switch is done. Setting it to 1 will give away control to another thread after 1/60th of a second. We recommend a value of 3 to 5 for a good reponsibility of your application.
Picture.ScaleMBS(width as integer, height as integer, AntiAlias as boolean=false, YieldTicks as integer=0) as picture
method, Graphics & Pictures, MBS REALbasic Picture Plugin (PictureScale), class Picture, Plugin version: 5.1, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Scales the picture to the new size.
Notes:
This is a self made algorithm which produces nice pictures on all platforms.
It is slower than QuickDraw on Mac OS, but nicer than drawpicture on Windows.
Returns nil on low memory or invalid width and height values.

AntiAlias is set to false if width<=self.width or height<=self.height.

If YieldTicks is 0, no time is given to other threads in your application. If it is a value > 0, this time is waited before a thread switch is done. Setting it to 1 will give away control to another thread after 1/60th of a second. We recommend a value of 3 to 5 for a good reponsibility of your application.

Some examples which use this method:

Picture.ScalingMBS(mode as integer, width as integer, height as integer) as picture
method, Graphics & Pictures, MBS REALbasic Picture Plugin (PictureScaling), class Picture, Plugin version: 8.0, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Scales the picture to the given size.
Example:
dim p as Picture

p=LogoMBS(1000)

p=p.ScalingMBS(2, 4000, 4000)

backdrop=p

Notes:
On low memory this function can return nil or the image may look bad. (e.g. all black)

The memory used for the temporary storage is original height * new width * 12 bytes plus some extra.

For scaling with the same size as the picture already has, the scaling is still performed.

Returns nil ony error. (e.g. destwidth=0)

Modes:
1triangle
2box, nereast neighbor
3lanczos 3
4lanczos 8
5mitchell
6poly 3
7cubic
Picture.ScrollHorizontalMBS(delta as integer, wrap as boolean, scrollmask as boolean) as boolean
method, Graphics & Pictures, MBS REALbasic Picture Plugin (Picture), class Picture, Plugin version: 6.5, Mac OS X: Works, Windows: Works, Linux x86: Does nothing, Feedback.

Function: Scrolls the image data horizontally.
Example:
dim p as Picture

p=LogoMBS(500) // any bitmap image

if p.ScrollHorizontalMBS(100,true,false) then
Title="ok"
end if

Backdrop=p


Notes:
Returns true on success and false on failure.
Works only on Mac OS and Windows with 32bit bitmap images.
scrollmask defines whether a mask (if one exists) is also scrolled.
Wrap will define whether the image will wrap on the edges. If wrap is enabled on Mac, the whole thing speeds up.
Picture.ScrollMBS(deltaX as integer, deltaY as integer, wrap as boolean, scrollmask as boolean) as boolean
method, Graphics & Pictures, MBS REALbasic Picture Plugin (Picture), class Picture, Plugin version: 6.5, Mac OS X: Works, Windows: Works, Linux x86: Does nothing, Feedback.

Function: Combines calls to ScrollHorizontalMBS and ScrollVerticalMBS.
Notes:
Returns true on success and false on failure.
Works only on Mac OS and Windows with 32bit bitmap images.
scrollmask defines whether a mask (if one exists) is also scrolled.
Wrap will define whether the image will wrap on the edges. If wrap is enabled on Mac, the whole thing speeds up.

Some examples which use this method:

Picture.ScrollVerticalMBS(delta as integer, wrap as boolean, scrollmask as boolean) as boolean
method, Graphics & Pictures, MBS REALbasic Picture Plugin (Picture), class Picture, Plugin version: 6.5, Mac OS X: Works, Windows: Works, Linux x86: Does nothing, Feedback.

Function: Scrolls the image data vertically.
Example:
dim p as Picture

p=LogoMBS(500) // any bitmap image

if p.ScrollVerticalMBS(100,true,false) then
Title="ok"
end if

Backdrop=p



Notes:
Returns true on success and false on failure.
Works only on Mac OS and Windows with 32bit bitmap images.
scrollmask defines whether a mask (if one exists) is also scrolled.
Wrap will define whether the image will wrap on the edges. If wrap is enabled on Mac, the whole thing speeds up.
Picture.ThreadedTransformMBS(Threaded as integer, Map() as color) as picture
method, Graphics & Pictures, MBS REALbasic Picture Plugin (PictureMT), class Picture, Console safe, Plugin version: 10.0, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Performs a transformation to the picture.
Example:
dim p as Picture = LogoMBS(500)

dim map(-1) as color

for r as integer = 0 to 255
for g as integer = 0 to 255
for b as integer = 0 to 255
// index is r*65536+g*256+b

// we swap colors: r gives g, g gives b, b gives r
map.Append rgb(g,b,r)
next
next
next

Backdrop=p.ThreadedTransformMBS(0, map)

Notes:
Threaded specifies how many threads you want to use:
A negative value disables threading, zero will use one thread for each CPU core and a positive number specifies the thread count.

For each color in the source picture the red, blue and green values are used as index (blue+green*256+blue*65536) in the arrays to get the new color value.

The arrays should have 2^24 entries.

See also:

Some examples which use this method:

Picture.ThreadedTransformMBS(Threaded as integer, Map() as integer) as picture
method, Graphics & Pictures, MBS REALbasic Picture Plugin (PictureMT), class Picture, Console safe, Plugin version: 10.0, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Performs a transformation to the picture.
Example:
dim p as Picture = LogoMBS(500)

dim map(-1) as integer

for r as integer = 0 to 255
for g as integer = 0 to 255
for b as integer = 0 to 255
// index is r*65536+g*256+b

// we swap colors: r gives g, g gives b, b gives r
map.Append g*65536+b*256+r
next
next
next

Backdrop=p.ThreadedTransformMBS(0, map)

Notes:
Threaded specifies how many threads you want to use:
A negative value disables threading, zero will use one thread for each CPU core and a positive number specifies the thread count.

For each color in the source picture the red, blue and green values are used as index (blue+green*256+blue*65536) in the arrays to get the new color value.

The arrays should have 2^24 entries.

See also:

Some examples which use this method:

Picture.ThreadedTransformMBS(Threaded as integer, RedMap as memoryblock, GreenMap as memoryblock, BlueMap as memoryblock) as picture
method, Graphics & Pictures, MBS REALbasic Picture Plugin (PictureMT), class Picture, Console safe, Plugin version: 10.0, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Performs a transformation to the picture.
Example:
dim p as Picture = LogoMBS(500)

dim red as MemoryBlock = NewMemoryBlock(256)
dim green as MemoryBlock = NewMemoryBlock(256)
dim blue as MemoryBlock = NewMemoryBlock(256)

for i as integer=0 to 255
red.Byte(i)=i/2
green.Byte(i)=i/2
blue.Byte(i)=i/2
next

Backdrop=p.ThreadedTransformMBS(0, red, green, blue)

Notes:
Threaded specifies how many threads you want to use:
A negative value disables threading, zero will use one thread for each CPU core and a positive number specifies the thread count.

For each color in the source picture the red, blue and green values are used as index in the memoryblocks to get the new color value.

The memoryblocks must have a size of 256 Bytes.

See also:

Some examples which use this method:

Picture.ThreadedTransformMBS(Threaded as integer, RedMap() as integer, GreenMap() as integer, BlueMap() as integer) as picture
method, Graphics & Pictures, MBS REALbasic Picture Plugin (PictureMT), class Picture, Console safe, Plugin version: 10.0, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Performs a transformation to the picture.
Example:
dim p as Picture = LogoMBS(500)

dim red(-1) as integer
dim green(-1) as integer
dim blue(-1) as integer

for i as integer=0 to 255
red.Append i/2
green.Append i/2
blue.Append i/2
next

Backdrop=p.ThreadedTransformMBS(0, red, green, blue)

Notes:
Threaded specifies how many threads you want to use:
A negative value disables threading, zero will use one thread for each CPU core and a positive number specifies the thread count.

For each color in the source picture the red, blue and green values are used as index in the arrays to get the new color value.

The arrays should have 256 entries.

See also:

Some examples which use this method:

TintPictureMBS(source as picture, GreyBase as color, SepiaBase as color) as picture
global method, Graphics & Pictures, MBS REALbasic Picture Plugin (Picture), Plugin version: 4.3, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Tints the image.
Example:
// The code does the same thing as this Realbasic code:

Sub TintPicture(theImg as Picture, pGreyBase as Color, pSepiaBase as Color)
Dim theRGBSurface as RGBSurface
Dim theWidth, theHeight as Integer
Dim pColor as Color
Dim x, y as Integer
Dim theGrey as Integer

dim SepiaBaseR as Double
dim SepiaBaseG as Double
dim SepiaBaseB as Double

dim GreyBaseR as Double
dim GreyBaseG as Double
dim GreyBaseB as Double

SepiaBaseR=pSepiaBase.Red / 255.0
SepiaBaseG=pSepiaBase.Green / 255.0
SepiaBaseB=pSepiaBase.Blue / 255.0

GreyBaseR=pGreyBase.Red / 255.0
GreyBaseG=pGreyBase.Green / 255.0
GreyBaseB=pGreyBase.Blue / 255.0

theRGBSurface = theImg.RGBSurface

theWidth = theImg.Width-1
theHeight = theImg.Height-1

For x = 0 to theWidth
For y = 0 to theHeight
pColor = theImg.RGBSurface.Pixel( x, y )

theGrey = ( GreyBaseR * pColor.Red ) + ( GreyBaseG * pColor.Green ) + ( GreyBaseB * pColor.Blue )
theImg.RGBSurface.Pixel( x, y ) = RGB( theGrey * SepiaBaseR, theGrey * SepiaBaseG, theGrey * SepiaBaseB )

Next
Next
End Sub

Notes:
You can use the code to do something like a Sepia effect.
Returns a new picture on success.

Some examples using this method:

Picture.TransformColorsMBS(red as memoryblock, blue as memoryblock, green as memoryblock) as picture
method, Graphics & Pictures, MBS REALbasic Picture Plugin (Picture), class Picture, Plugin version: 4.3, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Applies a transform table to the pixels.
Notes:
Red, blue and green are 256 byte big memoryblocks with one byte for each value.

In RB the function does this:
color=rgb(red.byte[color.red], green.byte[color.green], blue.byte[color.blue])
Picture.TrimMBS(left as integer, top as integer, width as integer, height as integer) as picture
method, Graphics & Pictures, MBS REALbasic Picture Plugin (PictureTrim), class Picture, Plugin version: 8.0, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Trims the picture to the given rectangle.
Example:
dim p as picture
dim someimage as Picture = LogoMBS(100)

p=someimage.TrimMBS(100,200,300,400)

Notes:
This method does not handle the mask.
So p.Trim(0,0,p.width,p.height) will give you a copy of the image pixels without mask.
left and top are zero based.

Use TrimWithMaskMBS if you need the mask to be trimmed.
Returns nil on low memory or bad parameters.

Some examples which use this method:

Picture.TrimWithMaskMBS(left as integer, top as integer, width as integer, height as integer) as picture
method, Graphics & Pictures, MBS REALbasic Picture Plugin (PictureTrim), class Picture, Plugin version: 8.0, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Trims the picture to the given rectangle.
Example:
dim p as picture
dim someimage as Picture = LogoMBS(100)

p=someimage.TrimWithMaskMBS(100,200,300,400)

Notes:
left and top are zero based.
Returns nil on low memory or bad parameters.
Picture.VMirrorMBS as picture
method, Graphics & Pictures, MBS REALbasic Picture Plugin (PictureRotate), class Picture, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Mirrors the picture vertically.
Example:
canvas1.backdrop=pic.VMirrorMBS

Notes:
This method returns a copy of the picture mirrored.
Returns nil on low memory.

Some examples which use this method:

Picture.VMirrorPictureMBS as boolean
method, Graphics & Pictures, MBS REALbasic Picture Plugin (PictureRotate), class Picture, Plugin version: 7.8, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Mirrors the picture vertically.
Example:
if pic.VMirrorPictureMBS then // mirror picture
canvas1.backdrop=pic
else
canvas1.backdrop=pic.VMirrorMBS // mirror a copy
end if

Notes: This methods mirrors the picture data itself. Returns true on success and false on failure. Only bitmap pictures can be mirrored this way.

Some examples which use this method:

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




Links
MBS Realbasic Plugins - JUZ Nickenich