I wanted a function to simply do a _PrintString to a 32-bit screen in a given fg/bg color, but allow the text to be scaled to 2x, 3x, etc., and work with a custom font. Kind of like a simpler RotoZoom, as it doesn't need to rotate and the x,y is the top left corner of the text and not the center. It started out as a modified RotoZoom2/DrawStrng but it used an older(?) PrintWidth function that wasn't compiling so I replaced it with _UPrintWidth.
Anyway, this should be a simple thing to do, but nothing is appearing on the screen.
The font is a custom fixed-width bitmap font (8x8 pixels per character) and is already set up and working before this sub is called. The screen is a 32-bit image 1024x768, already created and set to _DEST displaying text. The display is set to _AutoDisplay.
I have tried debugging it and all the values appear to be what I expect.
If anyone has a minute and could take a look & let me know what might be wrong here it would be most appreciated.
Anyway, this should be a simple thing to do, but nothing is appearing on the screen.
The font is a custom fixed-width bitmap font (8x8 pixels per character) and is already set up and working before this sub is called. The screen is a 32-bit image 1024x768, already created and set to _DEST displaying text. The display is set to _AutoDisplay.
I have tried debugging it and all the values appear to be what I expect.
If anyone has a minute and could take a look & let me know what might be wrong here it would be most appreciated.
Code: (Select All)
'Prints string MyString stretched to xScale%, yScale%
'in the current _FONT
'to 32-bit screen at ColNum%,RowNum%
'where the width of 1 column is _FontWidth * xScale%
' and height of 1 row is _FontHeight * yScale%
'with foreground color fg~& and background color bg~&
Sub DrawString (MyString As String, fg~&, bg~&, ColNum%, RowNum%, xScale%, yScale%)
Dim SavedSource&
Dim SavedDest&
Dim MyImage&
Dim FontHandle&
Dim x1&, y1&, x2&, y2&, w1&, h1&
' remember the source / destination
SavedSource& = _Source
SavedDest& = _Dest
' get the font
FontHandle& = _Font
MyImage& = _NewImage(_UPrintWidth(MyString, , FontHandle&), _FontHeight(FontHandle&), 32)
_Dest MyImage&
_Font FontHandle&
Color fg, bg
_UPRINTSTRING (0 , 0 ), MyString , , , FontHandle& , MyImage&
w1& = _Width(MyImage&) * xScale%
h1& = _Height(MyImage&) * yScale%
x1& = ColNum% * w1&
y1& = RowNum% * h1&
x2& = x1& + w1&
y2& = y1& + h1&
_PutImage (x1&, y1&)-(x2&, y2&), MyImage&, 0
' Restore the source/destination
_Source SavedSource&
_Dest SavedDest&
' Cleanup
_FreeImage MyImage&
End Sub ' DrawString
