有没有可以将文字反过来的功能,也就是文字的镜像。
我现在知道的也就是用StretchBlt来实现,还有没有其它的方法。

解决方案 »

  1.   

    StrReverse可以的
    StrReverse("123")="321"
    StrReverse("一二三")="三二一"
      

  2.   

    应该是使用自定义字体的方法可以作到。
    以前我找到过这样的资料,可以将字体定义成任何角度的。应该可以符合楼主的需要。
    下面这一段代码是VB区的老大给出来的,我转抄一下:
    Option Explicit#If Win32 Then
    Private Type LOGFONT_TYPE
                        lfHeight   As Long
                        lfWidth   As Long
                        lfEscapement   As Long
                        lfOrientation   As Long
                        lfWeight   As Long
                        lfItalic   As Byte
                        lfUnderline   As Byte
                        lfStrikeOut   As Byte
                        lfCharSet   As Byte
                        lfOutPrecision   As Byte
                        lfClipPrecision   As Byte
                        lfQuality   As Byte
                        lfPitchAndFamily   As Byte
                        lffacename   As String * 32
            End Type
    Private Declare Function CreateFontIndirect Lib "gdi32" Alias "CreateFontIndirectA" (lpLogFont As LOGFONT_TYPE) As Long
    #Else
    Private Type LOGFONT_TYPE
                    lfHeight   As Integer
                    lfWidth   As Integer
                    lfEscapement   As Integer
                    lfOrientation   As Integer
                    lfWeight   As Integer
                    lfItalic   As String * 1
                    lfUnderline   As String * 1
                    lfStrikeOut   As String * 1
                    lfCharSet   As String * 1
                    lfOutPrecision   As String * 1
                    lfClipPrecision   As String * 1
                    lfQuality   As String * 1
                    lfPitchAndFamily   As String * 1
                    lffacename   As String * 32
            End Type
    Private Declare Function CreateFontIndirect Lib "GDI" (lpLogFont As Any) As Integer
    #End If
    #If Win32 Then
    Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
    Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
    #Else
    Private Declare Function SelectObject Lib "GDI" (ByVal hdc As Integer, ByVal hObject As Integer) As Integer
    Private Declare Function DeleteObject Lib "GDI" (ByVal hObject As Integer) As Integer
    #End IfPrivate Sub Command1_Click()
    Picture1.Cls
    Picture1.fontname = "arial"
    Picture1.Fontsize = 40
    Picture1.FontBold = True
    TextCircle Picture1, "CSDN-libralibra", Picture1.ScaleWidth / 2, Picture1.ScaleHeight, Picture1.ScaleHeight * 0.8, -1
            
    End SubPrivate Sub TextCircle(obj As Object, txt As String, X As Long, Y As Long, radius As Long, startdegree As Double)
    Dim foo     As Integer, TxtX       As Long, TxtY       As Long, checkit       As Integer
    Dim twipsperdegree     As Long, wrktxt       As String, wrklet       As String, degreexy       As Double, degree       As Double
    twipsperdegree = (radius * 3.14159 * 2) / 360
    If startdegree < 0 Then
            Select Case startdegree
            Case -1
                    startdegree = Int(360 - (((obj.TextWidth(txt)) / twipsperdegree) / 2))
            Case -2
                    radius = (obj.TextWidth(txt) / 2) / 3.14159
                    twipsperdegree = (radius * 3.14159 * 2) / 360
            End Select
    End If
    For foo = 1 To Len(txt)
            wrklet = Mid$(txt, foo, 1)
            degreexy = (obj.TextWidth(wrktxt)) / twipsperdegree + startdegree
            DegreesToXY X, Y, degreexy, radius, radius, TxtX, TxtY
            degree = (obj.TextWidth(wrktxt) + 0.5 * obj.TextWidth(wrklet)) / twipsperdegree + startdegree
            RotateText 360 - degree, obj, obj.fontname, obj.Fontsize, (TxtX), (TxtY), wrklet
            wrktxt = wrktxt & wrklet
    Next foo
    End SubPrivate Sub DegreesToXY(CenterX As Long, CenterY As Long, degree As Double, radiusX As Long, radiusY As Long, X As Long, Y As Long)
    Dim convert     As Double        convert = 3.141593 / 180
            X = CenterX - (Sin(-degree * convert) * radiusX)
            Y = CenterY - (Sin((90 + (degree)) * convert) * radiusY)End SubPrivate Sub RotateText(Degrees As Integer, obj As Object, fontname As String, Fontsize As Single, X As Integer, Y As Integer, Caption As String)
    Dim RotateFont     As LOGFONT_TYPE
    Dim CurFont     As Long, rFont       As Long, foo       As LongRotateFont.lfEscapement = Degrees * 10
    RotateFont.lffacename = fontname & Chr$(0)
    If obj.FontBold Then
            RotateFont.lfWeight = 800
    Else
            RotateFont.lfWeight = 400
    End If
    RotateFont.lfHeight = (Fontsize * -20) / Screen.TwipsPerPixelY
    rFont = CreateFontIndirect(RotateFont)
    CurFont = SelectObject(obj.hdc, rFont)obj.CurrentX = X
    obj.CurrentY = Y
    obj.Print Caption'&Ecirc;&Iacute;·&Aring;&para;&Ocirc;&Iuml;ó
    foo = SelectObject(obj.hdc, CurFont)
    foo = DeleteObject(rFont)End Sub楼主新建个工程,放一个按钮和一个PICTURE,就可以运行看效果了。实在不好意思,我忘记是VB区的哪一个老大了,哈哈,罪过罪过。
      

  3.   

    非常感谢关注。
    我想要的效果是这样的,不是字的任意角度输出而是字的水平翻转。
    可惜CSDN上不能放图片~~~~就像“话”==》“舌讠”大致这样子。
    谢谢~~~~~
      

  4.   

    楼主要的是 q -> p 的效果
    关注
      

  5.   

    楼主要的是这种效果吧
    Function reversestring(revstr As String) As String
    ' revstr: 要翻转的字符串
    ' 返回值:翻转后的字符串
    Dim doreverse As Long
    reversestring = ""
    For doreverse = Len(revstr) To 1 Step -1
    reversestring = reversestring & Mid$(revstr, doreverse, 1)
    Next
    End Function
      

  6.   

    谢谢各位的关注.
    我需要的效果不是字符的排列顺序的翻转,而是单个字符的翻转。如“p”=>“q"