Function drawpixmaptext(Text:String, pix:TPixmap, x:Int, y:Int, font:TImageFont, RED:Int = 255, Green:Int = 255, Blue:Int = 255)Local newx:IntLocal theight:Int IF font = Null then return theight = font.Height() For Local I:Int = 0 To Text.Length - 1 Local tempText:String = Mid(Text, I + 1, 1) Local asciiVal:Int = Asc(tempText) Local n:Int = font.CharToGlyph(asciiVal) If n<0 Continue Local glyph:TImageGlyph = font.LoadGlyph(n) Local image:TImage = glyph._image Local tempix:TPixmap If image <> Null tempix = LockImage(image) UnlockImage(glyph._image) If tempix Local tx:Float = glyph._x Local ty:Float = glyph._y For Local yy:Int = 0 To glyph._h - 1'Height - 1 For Local xx:Int = 0 To glyph._w - 1'tempix.width - 1 If newx + x + xx + tx < pix.width And y + yy + ty < pix.Height Then Local Alpha:Float = RGBA_alpha(ReadPixel(tempix, xx, yy)) Local alphan:Float = Float(Alpha:Float / 255.0) Local anti:Float = 1.0 - alphan:Float Local ured:Int = RED'RGBA_Red(ReadPixel(tempix, xx, yy)) Local ugrn:Int = Green'RGBA_Green(ReadPixel(tempix, xx, yy)) Local ublu:Int = Blue'RGBA_Blue(ReadPixel(tempix, xx, yy)) Local newred:Int = ((RGBA_Red(ReadPixel(pix, newx + x + xx + tx, ty + y + yy)) * anti) + (ured * alphan:Float)) Local newgrn:Int = ((RGBA_Green(ReadPixel(pix, newx + x + xx + tx, ty + y + yy)) * anti) + (ugrn * alphan:Float)) Local newblu:Int = ((RGBA_Blue(ReadPixel(pix, newx + x + xx + tx, ty + y + yy)) * anti) + (ublu * alphan:Float)) Local newAlpha:Int = ((RGBA_alpha(ReadPixel(pix, newx + x + xx + tx, ty + y + yy)) * anti) + (Alpha * alphan:Float)) If newred > 255 Then newred = 255 If newgrn > 255 Then newgrn = 255 If newblu > 255 Then newblu = 255 If newAlpha > 255 Then newAlpha = 255 WritePixel(pix, newx + x + xx + tx, y + yy + ty, ToRGBA(newred, newgrn, newblu, newAlpha)) EndIf Next Next EndIf EndIf newx = newx + glyph.Advance() NextEnd FunctionFunction RGBA_Red:Int(rgba:Int) Return (rgba Shr 16) & $FFEnd Function Function RGBA_Green:Int(rgba:Int) Return (rgba Shr 8) & $FFEnd Function Function RGBA_Blue:Int(rgba:Int) Return rgba & $FFEnd Function Function RGBA_alpha:Int(rgba:Int) Return (rgba:Int Shr 24) & $FFEnd Function Function ToRGBA:Int(r:Int, g:Int, b:Int, a:Int) 'return (a << 24) | (r << 16) | (g << 8) | (b); Return ((A Shl 24) | (R Shl 16) | (G Shl 8) | B)End FunctionFunction TextWidthFont:Int(Text:String, Font:TImageFont) Local width:Int = 0 For Local n:Int = 0 Until Text.Length Local I:Int = font.CharToGlyph(Text[n]) If I < 0 Continue width:+font.LoadGlyph(I).Advance() Next Return widthEnd Function
'RemStrictGraphics 640,480,0Local pixmap:TPixmap = CreatePixmap(128, 128, PF_RGBA8888)Local font:TImageFont = TImageFont.CreateDefault()DrawPixmapText("R", pixmap, 10, 10, font, 255, 0, 0)DrawPixmapText(" A", pixmap, 10, 10, font, 255, 127, 0)DrawPixmapText(" I", pixmap, 10, 10, font, 255, 255, 0)DrawPixmapText(" N", pixmap, 10, 10, font, 0, 255, 0)DrawPixmapText(" B", pixmap, 10, 10, font, 0, 255, 255)DrawPixmapText(" O", pixmap, 10, 10, font, 255, 0, 255)DrawPixmapText(" W", pixmap, 10, 10, font, 127, 0, 255)DrawPixmapText(" :)", pixmap, 10, 10, font, 255, 255, 255)While Not (KeyDown(KEY_ESCAPE) Or AppTerminate()) Cls DrawPixmap(pixmap,0,0) FlipWend'EndRem