Visual Basic Code , VB.NET Code, VB Code
  Home   :  Code   :  Forums   :  Submit   :  Mailing List   :  About   :  Contact


Digitize Part of Bitmap Image


Digitize Part of Bitmap Image

Author
Message
Mark
Mark
Forum God
Forum God (142K reputation)

Group: Moderators
Posts: 1.1K, Visits: 11K
I'm not sure what z is but here is x and y. For this sample  I use 2 pictureboxes, an HScroll bar and a VScroll bar. All with their default names.  To run, place picture1 on your form. Then draw picture2 inside picture1. The scroll bars are placed on the form. Inside the form load event make sure you set the path to your picture and inside the mouse down event of picture set the location of you log file. See if this gives you some ideas.
Option Explicit

Private Sub Form_Load()
    Picture1.Move 0, 0, ScaleWidth - VScroll1.Width, ScaleHeight - HScroll1.Height
    
    With Picture2
        .BorderStyle = vbBSNone
        .MousePointer = vbCrosshair
        .AutoSize = True
        'Set the correct path
        .Picture = LoadPicture("picture path")
        .Move 0, 0
    End With
    
    With HScroll1
        .Top = Picture1.Height
        .Left = 0
        .Width = Picture1.Width
    End With
    
    With VScroll1
        .Top = 0
        .Left = Picture1.Width
        .Height = Picture1.Height
    End With
    
    HScroll1.Max = Picture2.Width - Picture1.Width
    VScroll1.Max = Picture2.Height - Picture1.Height
    HScroll1.LargeChange = HScroll1.Max / 10
    VScroll1.LargeChange = VScroll1.Max / 10
    HScroll1.SmallChange = HScroll1.Max / 25
    VScroll1.SmallChange = VScroll1.Max / 25
    
    VScroll1.Visible = (Picture1.Height < Picture2.Height)
    HScroll1.Visible = (Picture1.Width < Picture2.Width)
End Sub

Private Sub HScroll1_Change()
    Picture2.Left = -HScroll1.Value
    Picture2.SetFocus
End Sub

Private Sub Picture2_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim strLogFile As String
Dim strPoint As String
Dim xx As Integer
Dim yy As Integer
Dim ff As Integer

    'Set to the correct path
    strLogFile = "c:\testlogfile.txt"
    ff = FreeFile
    
    xx = X \ Screen.TwipsPerPixelX
    yy = Y \ Screen.TwipsPerPixelY
    
    strPoint = CStr(xx) & "," & CStr(yy)
    
    Open strLogFile For Append As ff
        Print #ff, strPoint
    Close ff
    
End Sub

Private Sub VScroll1_Change()
    Picture2.Top = -VScroll1.Value
    Picture2.SetFocus
End Sub

Private Sub Form_Resize()
    If Me.WindowState <> vbMinimized Then
        ' The Picture1 picture box dimensions are changed when the form
        ' size is changed.
        With Picture1
            .Height = Form1.Height
            .Width = Form1.Width
        End With
        
        ' Re-Initializes picture positions & scroll bars.
        Picture1.Move 0, 0, ScaleWidth - VScroll1.Width, ScaleHeight - HScroll1.Height
        Picture2.Move 0, 0
        
        With HScroll1
            .Top = Picture1.Height
            .Left = 0
            .Width = Picture1.Width
            .Max = Picture2.Width - Picture1.Width
        End With
        
        With VScroll1
            .Top = 0
            .Left = Picture1.Width
            .Height = Picture1.Height
            .Max = Picture2.Height - Picture1.Height
        End With
        
        ' Checks to see if scroll bars are needed
        VScroll1.Visible = (Picture1.Height < Picture2.Height)
        HScroll1.Visible = (Picture1.Width < Picture2.Width)
    End If
End Sub

Edited
8/26/2010 by Mark
CDRIVE
CDRIVE
Forum God
Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)

Group: Forum Members
Posts: 548, Visits: 2.6K
Just to let you know that I did receive your email but I can see that you're in very capable hands with Mark. Wink

________________________________________________________________ 

"So much to learn. So little time to do it. Wise men know it's later than one thinks"!

Mark's Syntax.Zip    Pause Sub

I don't answer programming questions via PMs. That's what the forum is for! 

La Vesey
La Vesey
Forum God
Forum God (3.6K reputation)Forum God (3.6K reputation)Forum God (3.6K reputation)Forum God (3.6K reputation)Forum God (3.6K reputation)Forum God (3.6K reputation)Forum God (3.6K reputation)Forum God (3.6K reputation)Forum God (3.6K reputation)

Group: Forum Members
Posts: 12, Visits: 49
TO: CDRIVE, 8-27-10



Thanks for your reply.



The reason I sent the email, is that no one was responding to my post of 8-5-10.



I am still learning how to use this site.



Perhaps most of the more advanced techs and programmers may NOT even look at this older VB 6 forum catagorie because they consider it vastly outdated?



Do you look at all posts in all forum catagaries?



If I have questions, then you want them in a post. Should the post be addressed to you?



The z value is a numeric variable which is the contour elevation value. This will need to be changed several times during each session.



La Vesey





La Vesey
La Vesey
Forum God
Forum God (3.6K reputation)Forum God (3.6K reputation)Forum God (3.6K reputation)Forum God (3.6K reputation)Forum God (3.6K reputation)Forum God (3.6K reputation)Forum God (3.6K reputation)Forum God (3.6K reputation)Forum God (3.6K reputation)

Group: Forum Members
Posts: 12, Visits: 49
TO: Mark --and-- others



Thanks very much for your reply and the code. You are the expert I have been looking for!!



The reason I sent the email, is that no one was responding to my post of 8-5-10.



I am still learning HOW to use this site.



Perhaps most of the more advanced techs and programmers may NOT even look at this older VB 6 forum catagorie because they consider it vastly outdated?



Do you look at all posts in all forum catagaries?



If I have questions, then you want them in a post. Should the post be addressed to you?



The z value is a numeric variable which is the contour elevation value. This will need to be changed several times during each session. Each session will load (open) a different bitmap image, either a bmp or jpg.



I will study your code very carefully, it may be helpful if you could insert more comment lines to explain what each section or sub does. I know generally what they do I think, but not speciffically what they do.



La Vesey



Keithuk
Keithuk
Forum God
Forum God (298K reputation)

Group: Moderators
Posts: 1.9K, Visits: 5.5K
La Vesey (8/27/2010)
TO: Mark --and-- others

Do you look at all posts in all forum catagaries?

If I have questions, then you want them in a post. Should the post be addressed to you?

No you don't have to look at all posts in all forums. I just click on the Recent Posts link in the top right. If you come here often then you only need to look for posted added today as I do.

You would be better posting a new topic rather than emailing individuals but thats up to you..

Yes VB6 is old but I still love it, I do have VB.Net 2008 and 2010 but its like programming in a new language apart from the basic VB keywords. Wink

Keith

I've been programming with VB for 17 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.

CDRIVE
CDRIVE
Forum God
Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)

Group: Forum Members
Posts: 548, Visits: 2.6K
La Vesey (8/27/2010)
TO: Mark --and-- others


Perhaps most of the more advanced techs and programmers may NOT even look at this older VB 6 forum catagorie because they consider it vastly outdated?


La Vesey

What???!!!??? If you mean that VB6 leaves a foot print < 1/4 that of NET, then yeah! So what's so advanced about NET? Yes, I know it can multi-thread.

MS should have named NET- "MSBus"! Why MSBus? Because "Thrown under the bus" is a favorite expression here in the U.S. It's not an expression that's used to convey affection. 

________________________________________________________________ 

"So much to learn. So little time to do it. Wise men know it's later than one thinks"!

Mark's Syntax.Zip    Pause Sub

I don't answer programming questions via PMs. That's what the forum is for! 

La Vesey
La Vesey
Forum God
Forum God (3.6K reputation)Forum God (3.6K reputation)Forum God (3.6K reputation)Forum God (3.6K reputation)Forum God (3.6K reputation)Forum God (3.6K reputation)Forum God (3.6K reputation)Forum God (3.6K reputation)Forum God (3.6K reputation)

Group: Forum Members
Posts: 12, Visits: 49
To: Mark and others, 8-30-10



Please do not be offended at the contents of this post. I am exposing my ignorance here

which requires crushing my pride. Consider the source, and have patience!



This post has questions about Marks' code of 8-26-10, post 29547, the subject matter has not changed.



1. It may be good to change the mouse cursor to a crosshair, as that would increase the accuracy of the points from the MouseDown events.



2. You said I could draw in In picture 2, what do you expect that i would draw? My plan is to only be selecting and storing points (or nodes), (which could be connected via lines), and is it not correct that the points will not show up unless you assign a symbol or a large dot locator? Drawing lines between the points is not primary for my purpose, but I guess it can be a "chrome plated" extra, to have a visable record of the points. (I had planned to plot the points in a different prog. which I already have).



3. Will the form size be changed in your code during this process? If so why?

I already know that all bitmap images I intend to load are larger than the screen size which is 1024 by 768 or approx that.



4. The primary goal in the program is to store -- write out the screen coordinates of the mousedown clicks inside the bitmap image, in the true text ascii format. Most drawing programs will ---NOT--- do that. Some will export to DXF format, I could not get CorelDraw 5 to do that.



5. The Z is a numeric variable which will need to be input (changed during the process) for each contour line which will have a different value.



6. In the MouseDown function event, what does the shift do and why do I need it?



7. To explain my goal in another way, I could do this on any drawing program, even the low end windows paint, but then I would have to record the X and Y values on paper by hand, and then type them in for use in the next step.



Thanks for you help! La Vesey





Mark
Mark
Forum God
Forum God (142K reputation)

Group: Moderators
Posts: 1.1K, Visits: 11K
These look more like statements than questions. Try asking clearly one question at a time and maybe we and work through it that way. So what is your biggest remaining question? And remember, only one question.
La Vesey
La Vesey
Forum God
Forum God (3.6K reputation)Forum God (3.6K reputation)Forum God (3.6K reputation)Forum God (3.6K reputation)Forum God (3.6K reputation)Forum God (3.6K reputation)Forum God (3.6K reputation)Forum God (3.6K reputation)Forum God (3.6K reputation)

Group: Forum Members
Posts: 12, Visits: 49
Okay Mark, 9-1-10

Others -- feel free to reply also to this post and my others - unless that would violate the rules!



What is the simplest way to change the mouse cursor to a crosshair.

Need to see some sample code, that will fit into the main code you have already listed.



Thanks! La Vesey

CDRIVE
CDRIVE
Forum God
Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)

Group: Forum Members
Posts: 548, Visits: 2.6K
This is one way.


Option Explicit

Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
   Picture1.MousePointer = 2
End Sub



________________________________________________________________ 

"So much to learn. So little time to do it. Wise men know it's later than one thinks"!

Mark's Syntax.Zip    Pause Sub

I don't answer programming questions via PMs. That's what the forum is for! 

GO


Similar Topics


Reading This Topic


Login
Existing Account
Email Address:


Password:


Social Logins

Select a Forum....

















A1VBCode Forums


Search