熱點推薦:
您现在的位置: 電腦知識網 >> 操作系統 >> Windows優化 >> 正文

文字文件轉化為圖片文件的簡易方法

2022-06-13   來源: Windows優化 

  加一個picture控件 一個Text控件 一個按扭控件 名字默認
  先把你要加載的文字加到Text控件之中控件高度調整恰當使文字容納並顯示完全並且把Text控件和Picture控件寬度大小調整一樣!!!如果不一樣那麼圖象就有可能放大或縮小(如果不需要這樣你可以在下面的代碼中自行修改)
  如果想要其他花樣 可以修改Text控件的文字屬性 比如FontName等等
  如果想要多花樣可以加入RichTextBox控件(代碼只要把text的改成RichTextBox的即可)這樣就可以顯示RTF文件了
  加入以下代碼到窗體:
  Private Declare Function ReleaseDC Lib user (ByVal hwnd As Long ByVal hdc As Long) As Long
  Private Declare Function GetDC Lib user (ByVal hwnd As Long) As Long
  Private Declare Function StretchBlt Lib gdi (ByVal hdc 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 nSrcWidth As Long ByVal nSrcHeight As Long ByVal dwRop As Long) As Long
  Private Const SRCCOPY = &HCC
  
  Private Sub Command_Click()
  Dim i As Long
  Dim wText As Long
  Dim hText As Long
  Dim w As Long
  Dim h As Long
  Dim hdcText As Long
  
  PictureAutoRedraw = True
  PictureCls
  wText = TextWidth
  hText = TextHeight
  w = PictureWidth
  h = PictureHeight
  hdcText = GetDC(Texthwnd)
  i = StretchBlt(Picturehdc w h hdcText wText hText vbSrcCopy)
  PictureRefresh
  SavePicture PictureImage D:\bmp
  ReleaseDC TexthwndhdcText
  End Sub
  

From:http://tw.wingwit.com/Article/os/youhua/201311/10800.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.