请问如何将字符进行左右翻转?

xusang 2004-09-14 02:12:54
我说的不是一串字符串倒着排这样的问题。
好像看书,你从纸的背面看一样。



...全文
398 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
GHGB 2004-09-15
  • 打赏
  • 举报
回复
虽然不是很懂,但是帮你顶顶吧
xusang 2004-09-15
  • 打赏
  • 举报
回复
太感谢,确实是这样的镜像,要好好研究研究。
fly_higher 2004-09-15
  • 打赏
  • 举报
回复
嗯~~~ 不懂! 能不能多加点注释啊?
northwolves 2004-09-14
  • 打赏
  • 举报
回复
Private Declare Function StretchBlt& Lib "GDI32" (ByVal hDC&, ByVal X&, ByVal Y&, ByVal nWidth&, ByVal nHeight&, ByVal hSrcDC&, ByVal XSrc&, ByVal YSrc&, ByVal nSrcWidth&, ByVal nSrcHeight&, ByVal dwRop&)
Private Const SRCCOPY = &HCC0020
Private WithEvents pic1 As PictureBox
Private WithEvents pic2 As PictureBox


Sub Form_Load()
Set pic1 = Controls.Add("vb.picturebox", "pic1", Me)
pic1.Visible = True
pic1.Move 0, 0, 1000, 500
Set pic2 = Controls.Add("vb.picturebox", "pic2", Me)
pic2.Visible = True
pic2.Move 1000, 0, 1000, 500
pic1.ScaleMode = 3
pic2.ScaleMode = 3
End Sub


Sub form_Click()
pic2.CurrentX = 0
pic2.CurrentY = 0
pic2.FontSize = 24
pic2.Print "镜像"
StretchBlt pic1.hDC, pic2.ScaleWidth, 0, -pic2.ScaleWidth, pic2.ScaleHeight, pic2.hDC, 0, 0, pic2.ScaleWidth, pic2.ScaleHeight, SRCCOPY
End Sub
xusang 2004-09-14
  • 打赏
  • 举报
回复
这样上下翻转的好实现,可怎么实现左右反转?这样出来不是“镜像”的效果。
starsoulxp 2004-09-14
  • 打赏
  • 举报
回复
有没有左右翻转的代码?
zhujiechang 2004-09-14
  • 打赏
  • 举报
回复
一个例子
'used with fnWeight
Const FW_DONTCARE = 0
Const FW_THIN = 100
Const FW_EXTRALIGHT = 200
Const FW_LIGHT = 300
Const FW_NORMAL = 400
Const FW_MEDIUM = 500
Const FW_SEMIBOLD = 600
Const FW_BOLD = 700
Const FW_EXTRABOLD = 800
Const FW_HEAVY = 900
Const FW_BLACK = FW_HEAVY
Const FW_DEMIBOLD = FW_SEMIBOLD
Const FW_REGULAR = FW_NORMAL
Const FW_ULTRABOLD = FW_EXTRABOLD
Const FW_ULTRALIGHT = FW_EXTRALIGHT
'used with fdwCharSet
Const ANSI_CHARSET = 0
Const DEFAULT_CHARSET = 1
Const SYMBOL_CHARSET = 2
Const SHIFTJIS_CHARSET = 128
Const HANGEUL_CHARSET = 129
Const CHINESEBIG5_CHARSET = 136
Const OEM_CHARSET = 255
'used with fdwOutputPrecision
Const OUT_CHARACTER_PRECIS = 2
Const OUT_DEFAULT_PRECIS = 0
Const OUT_DEVICE_PRECIS = 5
'used with fdwClipPrecision
Const CLIP_DEFAULT_PRECIS = 0
Const CLIP_CHARACTER_PRECIS = 1
Const CLIP_STROKE_PRECIS = 2
'used with fdwQuality
Const DEFAULT_QUALITY = 0
Const DRAFT_QUALITY = 1
Const PROOF_QUALITY = 2
'used with fdwPitchAndFamily
Const DEFAULT_PITCH = 0
Const FIXED_PITCH = 1
Const VARIABLE_PITCH = 2
'used with SetBkMode
Const OPAQUE = 2
Const TRANSPARENT = 1

Const LOGPIXELSY = 90
Const COLOR_WINDOW = 5
Const Message = "Hello !"

Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type

Private Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Long, ByVal nIndex As Long) As Long
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Private Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hdc As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function GetDC Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Declare Function CreateEllipticRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
Private Declare Function CreateFont Lib "gdi32" Alias "CreateFontA" (ByVal nHeight As Long, ByVal nWidth As Long, ByVal nEscapement As Long, ByVal nOrientation As Long, ByVal fnWeight As Long, ByVal fdwItalic As Boolean, ByVal fdwUnderline As Boolean, ByVal fdwStrikeOut As Boolean, ByVal fdwCharSet As Long, ByVal fdwOutputPrecision As Long, ByVal fdwClipPrecision As Long, ByVal fdwQuality As Long, ByVal fdwPitchAndFamily As Long, ByVal lpszFace As String) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
Private Declare Function TextOut Lib "gdi32" Alias "TextOutA" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal lpString As String, ByVal nCount As Long) As Long
Private Declare Function MulDiv Lib "kernel32" (ByVal nNumber As Long, ByVal nNumerator As Long, ByVal nDenominator As Long) As Long
Private Declare Function SetBkMode Lib "gdi32" (ByVal hdc As Long, ByVal nBkMode As Long) As Long
Private Declare Function GetSysColorBrush Lib "user32" (ByVal nIndex As Long) As Long
Private Declare Function FillRect Lib "user32" (ByVal hdc As Long, lpRect As RECT, ByVal hBrush As Long) As Long
Private Declare Function SetRect Lib "user32" (lpRect As RECT, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Dim mDC As Long, mBitmap As Long
Private Sub Form_Click()
Unload Me
End Sub
Private Sub Form_Load()
'KPD-Team 1999
'URL: http://www.allapi.net/
'E-Mail: KPDTeam@Allapi.net
Dim mRGN As Long, Cnt As Long, mBrush As Long, R As RECT
'Create a device context, compatible with the screen
mDC = CreateCompatibleDC(GetDC(0))
'Create a bitmap, compatible with the screen
mBitmap = CreateCompatibleBitmap(GetDC(0), Me.Width / Screen.TwipsPerPixelX, Me.Height / Screen.TwipsPerPixelY)
'Select the bitmap nito the device context
SelectObject mDC, mBitmap
'Set the bitmap's backmode to transparent
SetBkMode mDC, TRANSPARENT
'Set the rectangles' values
SetRect R, 0, 0, Me.Width / Screen.TwipsPerPixelX, Me.Height / Screen.TwipsPerPixelY
'Fill the rect with the default window-color
FillRect mDC, R, GetSysColorBrush(COLOR_WINDOW)

For Cnt = 0 To 350 Step 30
'Select the new font into the form's device context and delete the old font
DeleteObject SelectObject(mDC, CreateMyFont(24, Cnt))
'Print some text
TextOut mDC, (Me.Width / Screen.TwipsPerPixelX) / 2, (Me.Height / Screen.TwipsPerPixelY) / 2, Message, Len(Message)
Next Cnt

'Create an elliptical region
mRGN = CreateEllipticRgn(0, 0, Me.Width / Screen.TwipsPerPixelX, Me.Height / Screen.TwipsPerPixelY)
'Set the window region
SetWindowRgn Me.hWnd, mRGN, True

'delete our elliptical region
DeleteObject mRGN
End Sub
Function CreateMyFont(nSize As Integer, nDegrees As Long) As Long
'Create a specified font
CreateMyFont = CreateFont(-MulDiv(nSize, GetDeviceCaps(GetDC(0), LOGPIXELSY), 72), 0, nDegrees * 10, 0, FW_NORMAL, False, False, False, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, DEFAULT_PITCH, "Times New Roman")
End Function
Private Sub Form_Paint()
'Copy the picture to the form
BitBlt Me.hdc, 0, 0, Me.Width / Screen.TwipsPerPixelX, Me.Height / Screen.TwipsPerPixelY, mDC, 0, 0, vbSrcCopy
End Sub
Private Sub Form_Unload(Cancel As Integer)
'clean up
DeleteDC mDC
DeleteObject mBitmap
End Sub
flyingZFX 2004-09-14
  • 打赏
  • 举报
回复
用API
xusang 2004-09-14
  • 打赏
  • 举报
回复
我在图形框中已经画出了text,但我搜索了一下映像算法,什么也找不到。能具体说说么?
  • 打赏
  • 举报
回复
方法很多,先说两个不同的思路吧:
1。在图形框PICTUREBOX中DRAW出TEXT,然后用取像素函数结合映像算法按“照镜子”的效果再绘制出来。
2。如果需要大量使用这种反排效果,干脆就用字库编辑软件来把字库文件编辑一下全部“照过镜子”后再先存成新文字文件,之后把字体设置成所安装的这个新字库就成了。

7,762

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧