有没有这样的功能?

hzc1 2006-08-25 02:02:54
有没有可以将文字反过来的功能,也就是文字的镜像。
我现在知道的也就是用StretchBlt来实现,还有没有其它的方法。
...全文
209 点赞 收藏 13
写回复
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
hzc1 2006-08-29
再顶
回复
xiaolingshi 2006-08-29
借助FLASH
回复
hzc1 2006-08-28
定义字符集可以达到我要的效果吗?如何做,最好能将代码告之,谢谢~~~~~
回复
leongwong 2006-08-28
楼主作图章吧?自己定义个字符集吧!
回复
hzc1 2006-08-28
谢谢各位的关注.
我需要的效果不是字符的排列顺序的翻转,而是单个字符的翻转。如“p”=>“q"
回复
hzc1 2006-08-28
再关注一吓子行不?
回复
应该是使用自定义字体的方法可以作到。
以前我找到过这样的资料,可以将字体定义成任何角度的。应该可以符合楼主的需要。
下面这一段代码是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 If

Private 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 Sub

Private 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 Sub

Private 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 Sub

Private 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 Long

RotateFont.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

'ÊͷŶÔÏó
foo = SelectObject(obj.hdc, CurFont)
foo = DeleteObject(rFont)

End Sub

楼主新建个工程,放一个按钮和一个PICTURE,就可以运行看效果了。

实在不好意思,我忘记是VB区的哪一个老大了,哈哈,罪过罪过。
回复
xiaolingshi 2006-08-26
楼主要的是这种效果吧
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
回复
YaDa 2006-08-26
刻图章?制泥版?
回复
缪军 2006-08-26
楼主要的是 q -> p 的效果
关注
回复
hzc1 2006-08-26
非常感谢关注。
我想要的效果是这样的,不是字的任意角度输出而是字的水平翻转。
可惜CSDN上不能放图片~~~~就像“话”==》“舌讠”大致这样子。
谢谢~~~~~
回复
LGQ1001 2006-08-25
StrReverse可以的
StrReverse("123")="321"
StrReverse("一二三")="三二一"
回复
hzc1 2006-08-25
没人知道吗?
回复
发动态
发帖子
VB基础类
创建于2007-09-28

7451

社区成员

VB 基础类
申请成为版主
社区公告
暂无公告