| | |
Scanner :Scanning image of a Picture control to a Rich Text Box
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Hello friends i made a small program like a scanner it will scan an image file to a Rich Text Box.
My friend helped me in providing the code to access the pixels of an image.Hope you will like the code.
Try it ....
This need :
Reference files :
Visual Basic For Applications
Visual Basic runtime objects and procedures
Visual basic objects and procedures
OLE Automation
Add
1 - Rich Text Box - Rt1
2 - One Common Dialog Control named cmd
3 - 2 Command Buttons
4 - One Picture Box &
5 - 2 HScroll s
Try to make the Picture control Atuosize to false.
My friend helped me in providing the code to access the pixels of an image.Hope you will like the code.
Try it ....
This need :
Reference files :
Visual Basic For Applications
Visual Basic runtime objects and procedures
Visual basic objects and procedures
OLE Automation
Add
1 - Rich Text Box - Rt1
2 - One Common Dialog Control named cmd
3 - 2 Command Buttons
4 - One Picture Box &
5 - 2 HScroll s
Try to make the Picture control Atuosize to false.
Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long) As Long Dim drawtag As String Function Pencil(col1 As Long) As Single Dim R As Single Dim G As Single Dim B As Single R = col1 And 255 G = (col1 And 65280) \ 256& B = (col1 And 16711680) \ 65535 Pencil = (R + B + G) / 765 End Function Function Brush(col1 As Long) As Long Dim R As Single Dim G As Single Dim B As Single R = col1 And 255 G = (col1 And 65280) \ 256& B = (col1 And 16711680) \ 65535 Brush = RGB(R, G, B) End Function Private Sub Command1_Click() On Error GoTo Err Dim Ix, Iy As Integer Dim col1 As Long Dim col2 As Single Dim col3 As String rt1.SelFontName = "Lucida Console" rt1.SelFontSize = 2 rt1.Text = vbNewLine rt1.Enabled = False For Iy = 1 To HScroll1.Value For Ix = 1 To HScroll2.Value col1 = GetPixel(Picture1.hdc, Ix, Iy) col2 = Pencil(col1) col3 = Mid(drawtag, Len(drawtag) - Int(col2 * (Len(drawtag) - 1)), 1) rt1.SelStart = Len(rt1.Text) - 2 rt1.SelLength = 1 rt1.SelText = col3 rt1.SelStart = Len(rt1.Text) - 2 rt1.SelLength = 1 rt1.SelColor = Brush(Picture1.Point(Ix + 1, Iy)) Next rt1.SelText = vbNewLine DoEvents Next Err: rt1.Enabled = True End Sub Private Sub Command2_Click() On Error Resume Next Dim filename As String cmd.ShowOpen filename = cmd.filename Picture1.Picture = LoadPicture(filename) End Sub Private Sub Form_Load() drawtag = "#" End Sub
Similar Threads
- Custom Links in Rich Text Box (VB.net) (VB.NET)
- text box should be replaced by rich text box (Visual Basic 4 / 5 / 6)
- rich text box (PHP)
- using rich text box to print its contents (C#)
- writing from bottom up in rich text box (VB.NET)
- Rich Text Box (Visual Basic 4 / 5 / 6)
- Rich Text Box Code (HTML and CSS)
- Please help me open a html document in a rich text box via the common dialog control (Visual Basic 4 / 5 / 6)
| Thread Tools | Search this Thread |
Tag cloud for Visual Basic 4 / 5 / 6
* 6 429 2007 access activex add age append application basic beginner birth bmp c++ calculator cd cells.find click client code college column component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sites sort sql sql2008 sqlserver struct table tags textbox time timer urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows



