Xojo Conferences
MBSSep2018MunichDE
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

Graphics.DrawRotatedTextMBS(Rotation as Double, text as string, x as Integer, y as Integer, Center as Boolean = false, alpha as Double = 1.0, NoSwapY as boolean = false, FontWidth as Integer = 0)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Graphics & Pictures MBS Util Plugin 11.2 Yes Yes No No No
Function: Draws rotated text.
Example:
Sub Paint(g As Graphics)

g.DrawRotatedTextMBS 45, "Hello World", 100, 100

End Sub
Notes:
Rotation is the angle in degree.
Currently only supported for Mac OS X and Windows in GUI applications.

The plugin does not see the clipping offset for the graphics object. So for graphics objects from printer or canvas, you need to offset the position. Seems like with a Canvas the coordinates are relative to canvas in Cocoa, but relative to Windows in Carbon.

We have the optional parameter Center which tells the plugin to center the rotated text, so the rotation point is in the middle of the text.
The plugin queries Bold, Italic, Underline, ForeColor, TextUnit, TextSize or TextFont.

Alpha gives the alpha value for Mac OS X. Can be 1.0 (Full color) to 0.0 (no color).

On Mac targets the Y coordinate needs to be swapped internally from top down coordinates to bottom up coordinates. As this does not work 100% correct on printers (the plugin doesn't know page margins), you can provide correct Y coordinate yourself and pass NoSwapY = true. (added in plugin version 13.1)
On Windows the OS function used (ExtTextOut) does not support multiple lines.

FontWidth is only for Windows to define the width of the font. Default is 0 to use default width.
The average width, in logical units, of characters in the font. If FontWidth is zero, the aspect ratio of the device is matched against the digitization aspect ratio of the available fonts to find the

On Windows for drawing in a picture, make sure the font size and font name are set. Else it may not draw.

Some examples which use this method:

Feedback, Comments & Corrections

Graphics.DrawWindowsIconMBS(file as folderitem, IconID as Integer, x as Integer, y as Integer, w as Integer, h as Integer) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Graphics & Pictures MBS Win Plugin 10.1 No Yes No No No
Function: Draws a windows icon on the given rectangle.
Notes:
The folderitem should point to a file with icons (exe, dll, ico or something else). If IconID is zero, the first icon is used. Else IconID is the id of the icon.
If w or h is 0, the default size is used.
Returns true on success and false on failure.

Some examples which use this method:

Feedback, Comments & Corrections

Graphics.MeasureRotatedTextMBS(text as string, byref Width as Double, byref Height as Double, FontWidth as Integer = 0) as Boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Graphics & Pictures MBS Util Plugin 17.0 Yes Yes No No No
Function: Measure size of text.
Notes:
This is compatible to text drawing in DrawRotatedTextMBS, so you can use it to calculate the required space.
No rotation is used for measurement.
Returns true on success and false on failure.

Some examples which use this method:

Feedback, Comments & Corrections

Graphics.PaintdesktopMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Graphics & Pictures MBS Picture Plugin No Yes No No No
Function: Draws on Windows the desktop into the current graphics port.
Notes: May not draw a desktop picture.

Feedback, Comments & Corrections

Graphics.StretchBltMBS(nXOriginDest as Integer, nYOriginDest as Integer, nWidthDest as Integer, nHeightDest as Integer, source as graphics, nXOriginSrc as Integer, nYOriginSrc as Integer, nWidthSrc as Integer, nHeightSrc as Integer, dwRop as Integer) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Graphics & Pictures MBS Win Plugin 6.1 No Yes No No No
Function: The StretchBlt function copies a bitmap from a source rectangle into a destination rectangle, stretching or compressing the bitmap to fit the dimensions of the destination rectangle, if necessary.
Notes:
This is just a wrapper to the StretchBlt function from the Windows API.

The system stretches or compresses the bitmap according to the stretching mode currently set in the destination device context.

Parameters:

nXOriginDestSpecifies the x-coordinate, in logical units, of the upper-left corner of the destination rectangle.
nYOriginDestSpecifies the y-coordinate, in logical units, of the upper-left corner of the destination rectangle.
nWidthDestSpecifies the width, in logical units, of the destination rectangle.
nHeightDestSpecifies the height, in logical units, of the destination rectangle.
hdcSrcThe source device context.
nXOriginSrcSpecifies the x-coordinate, in logical units, of the upper-left corner of the source rectangle.
nYOriginSrcSpecifies the y-coordinate, in logical units, of the upper-left corner of the source rectangle.
nWidthSrcSpecifies the width, in logical units, of the source rectangle.
nHeightSrcSpecifies the height, in logical units, of the source rectangle.
dwRopSpecifies the raster operation to be performed. Raster operation codes define how the system combines colors in output operations that involve a brush, a source bitmap, and a destination bitmap. See BitBlt for a list of common raster operation codes (ROPs). Note that the CAPTUREBLT ROP generally cannot be used for printing device contexts.

Return Values

If the function succeeds, the return value is true.
If the function fails, the return value is false.

Possible operation modes:

SRCCOPY&h00CC0020dest = sourceCopies the source rectangle directly to the destination rectangle.
SRCPAINT&h00EE0086dest = source OR destCombines the colors of the source and destination rectangles by using the Boolean OR operator.
SRCAND&h008800C6dest = source AND destCombines the colors of the source and destination rectangles by using the Boolean AND operator.
SRCINVERT&h00660046dest = source XOR destCombines the colors of the source and destination rectangles by using the Boolean XOR operator.
SRCERASE&h00440328dest = source AND (NOT dest )Combines the inverted colors of the destination rectangle with the colors of the source rectangle by using the Boolean AND operator.
NOTSRCCOPY&h00330008dest = (NOT source)Copies the inverted source rectangle to the destination.
NOTSRCERASE&h001100A6dest = (NOT src) AND (NOT dest)Combines the colors of the source and destination rectangles by using the Boolean OR operator and then inverts the resultant color.
MERGECOPY&h00C000CAdest = (source AND pattern)Merges the colors of the source rectangle with the brush currently selected in hdcDest, by using the Boolean AND operator.
MERGEPAINT&h00BB0226dest = (NOT source) OR destMerges the colors of the inverted source rectangle with the colors of the destination rectangle by using the Boolean OR operator.
PATCOPY&h00F00021dest = patternCopies the brush currently selected in hdcDest, into the destination bitmap.
PATPAINT&h00FB0A09dest = DPSnooCombines the colors of the brush currently selected in hdcDest, with the colors of the inverted source rectangle by using the Boolean OR operator. The result of this operation is combined with the colors of the destination rectangle by using the Boolean OR operator.
PATINVERT&h005A0049dest = pattern XOR destCombines the colors of the brush currently selected in hdcDest, with the colors of the destination rectangle by using the Boolean XOR operator.
DSTINVERT&h00550009dest = (NOT dest)Inverts the destination rectangle.
BLACKNESS&h00000042dest = BLACKFills the destination rectangle using the color associated with index 0 in the physical palette. (This color is black for the default physical palette.)
WHITENESS&h00FF0062dest = WHITEFills the destination rectangle using the color associated with index 1 in the physical palette. (This color is white for the default physical palette.)
NOMIRRORBITMAP&h80000000Do not Mirror the bitmap in this call.Prevents the bitmap from being mirrored.
CAPTUREBLT&h40000000Include layered windows.Includes any windows that are layered on top of your window in the resulting image. By default, the image only contains your window. Note that this generally cannot be used for printing device contexts.

Feedback, Comments & Corrections

graphics.StretchDIBitsMBS(XDest as Integer, YDest as Integer, DestWidth as Integer, DestHeight as Integer, XSource as Integer, YSource as Integer, SourceWidth as Integer, SourceHeight as Integer, Bits as memoryblock, ImageWidth as Integer, ImageHeight as Integer, ImageBitCount as Integer) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Graphics & Pictures MBS Picture Plugin 10.1 No Yes No No No
Function: The StretchDIBits function copies the color data for a rectangle of pixels in a DIB image to the specified destination rectangle.
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 XDest as Integer = 0
dim YDest as Integer = 0
dim DestWidth as Integer = 100
dim DestHeight as Integer = 100
dim XSource as Integer = 0
dim YSource as Integer = 0
dim SourceWidth as Integer = 100
dim SourceHeight as Integer = 100
dim Bits as memoryblock = m
dim ImageWidth as Integer = 100
dim ImageHeight as Integer = 100
dim ImageBitCount as Integer = 24

call g.StretchDIBitsMBS(XDest, YDest, DestWidth, DestHeight, XSource, YSource, SourceWidth, SourceHeight, bits, ImageWidth, ImageHeight, ImageBitCount)

end if
Notes:
If the destination rectangle is larger than the source rectangle, this function stretches the rows and columns of color data to fit the destination rectangle. If the destination rectangle is smaller than the source rectangle, this function compresses the rows and columns by using the specified raster operation.

You specify the dest rectangle in the graphics object, the source rectangle in the picture, the memoryblock with the bits, the size of the image and the bit count of the image (24 or 32).

The origin of a bottom-up DIB is the bottom-left corner; the origin of a top-down DIB is the upper-left corner.

StretchDIBits creates a mirror image of a bitmap if the signs of the nSrcWidth and nDestWidth parameters, or if the nSrcHeight and nDestHeight parameters differ. If nSrcWidth and nDestWidth have different signs, the function creates a mirror image of the bitmap along the x-axis. If nSrcHeight and nDestHeight have different signs, the function creates a mirror image of the bitmap along the y-axis.

Returns true on success and false on failure.

Feedback, Comments & Corrections

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





Links
MBS Xojo Chart Plugins