none
Select part of picturebox? RRS feed

  • Question

  • Hi,

    How can i make a select tool (rectangular) to select part of a picturebox image and then delete it or copy it to the clipboard?
    • Edited by bbbclock Sunday, January 17, 2010 11:47 PM
    Sunday, January 17, 2010 9:30 PM

All replies

  • Not a small task - to do it really well, you should study up on System.Drawing, specifically using Points, Sizes, Rectangles, and System.Drawing.Graphics objects related to Forms Controls like the PictureBox.
    It never hurts to try. In a worst case scenario, you'll learn from it.
    Sunday, January 17, 2010 9:33 PM
  • What do you mean by delete it?  Replace the selected area with a single fixed color?  Select a rectangular area or a free form area?  Please clarify your desires.
    Sunday, January 17, 2010 9:35 PM
  • Public Class Form1
    
        Dim XStart As Integer
        Dim YStart As Integer
        Dim BM As Bitmap
        Private Sub PictureBox1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
            XStart = e.X
            YStart = e.Y
        End Sub
    
        Private Sub PictureBox1_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUp
            If e.X > XStart AndAlso e.Y > YStart Then
                BM = New Bitmap(e.X - XStart, e.Y - YStart, System.Drawing.Imaging.PixelFormat.Format32bppArgb)
                Dim BR As Brush = Brushes.White
                Dim G As Graphics = Graphics.FromImage(BM)
                G.FillRectangle(BR, 0, 0, BM.Width, BM.Height)
                PictureBox1.Invalidate()
            Else
                BM = Nothing
            End If
        End Sub
    
        Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
            If Not BM Is Nothing Then
                e.Graphics.DrawImage(BM, XStart, YStart)
            End If
        End Sub
    End Class
    Sunday, January 17, 2010 10:02 PM
  • I want to be able to select part of an image (a rectangle), and then delete it or copy it to the clipboard.

    @Acamar: That code works well for deleting part of an image, thankyou! 


    Is there any way I can have the 'select effect' that is, the dotted lines which appear as you are selecting a part of the image?

    How can I select part of the image and copy it to the clipboard?
    Sunday, January 17, 2010 11:46 PM
  • The select effect is known as rubber banding.  There should be plenty of references to it on the www.

    To select the region, use the start and current (e.X, e.Y) positions in the mouse up event to define a rectangle (it's the same rectangle used to draw the white area).  Use that rectangle to define and create a new bitmap (as per the example in the original code). Use one of the overloads of the graphics draw method to copy from the source rectangle in the picture box to the bitmap you have created, then put the bitmap on the clicpboard.
    Monday, January 18, 2010 12:08 AM
  • Thanks, I'll look it up.


    Okay, I understand most of that, except how might I 'use one of the overloads of the graphics draw method to copy from the source rectangle in the picture box to the bitmap you have created, then put the bitmap on the clicpboard'?

    I would hugely appreciate a quick code snippet :)
    Monday, January 18, 2010 12:36 AM
  • The Graphics.DrawImage message has a large number of overloads.  One of them allows drawing from a rectangular area in a source image into a destination image. 
    http://msdn.microsoft.com/en-us/library/ms142038.aspx

    Exactly how you would do that depends on how you put the image into the picturebox.  Is it the picturebox image property?  If so, then your source is that image property, the source rectangle is the selected area (from the above code) and the destination is the bitmap you create at position (0,0). If it's the background, or one of the other image properties, you procedure will be slightly different. If it is the original image placed into the picturebox, you may need to do some scaling conversion, depending on the properties you have used for the picturebox (zoom, stretch etc).  This would required converting the absolute rectangle positions to percentages of the picturebox size, and then converting them from percentages back to pixels in the original image. 

    The code above shows how to create a bitmap of a specific size and how to get the graphics object of that bitmap.  Except for the destination object and the point location, it's the same as the example at the above MSDN reference.

    How will you indicate that the selected portion is to be placed on the clipboard?  Should it happen when the area is selected (mouse button up event)?  Or will there be a button "Paste"?   If it's in the button up then you have all the values you need - if it happens in some other events you may need to re-arrange variables so they are available to that other code.

    Once you have the bitmap, use the clipboard object and the SetDataObject method to place it on the clipboard:
    http://msdn.microsoft.com/en-us/library/system.windows.forms.clipboard.aspx

    Monday, January 18, 2010 12:52 AM
  • The image is drawn on the picturebox, I'm trying to add a select feature into my paint application.

    I've used most of the code from here to create my program:


    As its drawn on using a paint event, how can I select parts of the image?


    If you are familiar with and understand the code in the link above, I'd be willing to offer some payment for you to code some extra features for me, if you're interested :)
    Monday, January 18, 2010 4:22 AM
  • If you're seriously looking to contract out your system.drawing programming, start somewhere like www.guru.com or else go look at (my site) www.painter-enterprises.com if you want some idea of what freelancers are actually charging and what they're charging for.
    It never hurts to try. In a worst case scenario, you'll learn from it.
    Monday, January 18, 2010 3:59 PM
  • Andrew,

    If that is the case, what would you charge to complete this simple select tool?
    Tuesday, January 19, 2010 2:31 AM
  • bbbclock,

    Trujade showed you already that you have a way of asking and replying, which does not invite to answer.

    Nobody here is oblied to help you. They do it, but at least espect a little bit of friendly behaviour from those who are helped.

    You are among those who need to change their identifier name often, because else they don't get any answer anymore.
    Success
    Cor
    Tuesday, January 19, 2010 6:00 AM
  • How it's drawn on is not relevant to your problem.  How it's selected is important, and that happens in the mouse event, where you can get access to things like mouse position (as in the above example to determine the selected area.  Use the coordinate data from the 'clear' example to give you the information you need for the 'select' routine, and look up the link provided for how to use the DrawImage method to draw from a rectangular area of an image into a bitmap.  The code is actually just a small re-arrangement of the example already provided.
    Wednesday, January 20, 2010 3:28 AM
  • Has anyone mentioned the DrawReversibleFrame method of the System.Windows.Forms.ControlPaint class ?

    This mehod draws (or hides) a dashed frame just like the MS Paint Selection tool.
    Easy to use...
    Just remember that you dont have to Invalidate your control after calling this method.

    Example:
    ControlPaint.DrawReversibleFrame(rect, Color.White, FrameStyle.Dashed)

    There are another method to draw (and hide) a straight line: ControlPaint.DrawReversibleLine

    Check: http://support.microsoft.com/kb/314945/en-us
    And http://www.codeproject.com/KB/GDI-plus/Freehand_Drawing.aspx


    Good Luck


    Federico Colombo
    Wednesday, January 20, 2010 5:12 AM
  • Hi,

    @Cor: I aplogise if I sometimes come across that way, its just because english isn't my first (or best) language.


    @Frederico: Thanks! I'll look into that :)

    @Acamar: Okay, I've looked at the links and I've made some code which sort of works. Some of it is related to the link I supplied above if it seems wierd. It works, except the rectangle is the wrong size (I think I've just got some of the XStarts etc to draw the rectangle mixed up, which ones?:) and the actual things I draw in the paint application on the picturebox aren't copied to the clipboard, just the background.)

    Anyway, here it is:

    Public Class Form1
        Dim instance As Clipboard
        Dim XStart As Integer
        Dim YStart As Integer
        Dim BM As Bitmap
    
        Private Sub PictureBox1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
            XStart = e.X
            YStart = e.Y
        End Sub
    
        Private Sub PictureBox1_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUp
            If e.X > XStart AndAlso e.Y > YStart Then
                Dim Rect As New Rectangle(YStart - e.Y, YStart - e.Y, e.X - XStart, e.X - XStart)
                Dim bm As New Bitmap(rect.Width, rect.Height)
                Using gr As Graphics = Graphics.FromImage(bm)
                    gr.TranslateTransform(-rect.X, -rect.Y)
                End Using
    
                Clipboard.SetDataObject(bm)
            Else
                BM = Nothing
            End If
        End Sub
    
        Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
            If Not BM Is Nothing Then
                e.Graphics.DrawImage(BM, XStart, YStart)
            End If
        End Sub
    End Class

    Whats wrong with it/what should I improve? :)

    Thankyou!
    Wednesday, January 20, 2010 5:37 AM
  • Your changes have overwritten much of the code that I provided, so the changes I suggested won't work.  I would recommend getting back to the code where the selected portion of the image was being cleared properly.   Your declaration

    Dim bm As New Bitmap(rect.Width, rect.Height)
    

    conflicts with an object of the same name declared at a higher level: at the least that will confuse you but at worst it s going to mean that the rectangle drawing will be wrong.   For pasting to the clipboard you need to create a new bitmap: use a different variable name, such as BP.

    I don't know why you have used a TranslateTransform - I never mentioned that, and I can't see how it is relevant to what you are trying to do.  You might be mixing code from two different sources.  There are many diffrent ways of approaching your problem, and if you mix code from different sources the result will not work.

    If the correct part of the image in the picturebox is being cleared, then you know that the rectangle used to draw the cleared portion of the picturebox refers to the part you want to copy.  This is the rectangle used in the line:
    G.FillRectangle(BR, 0, 0, BM.Width, BM.Height)
    

    So you would create a new bitmap of BM.Width width and BM.Height height.

    Then you would use the DrawImage method to draw a rectangle from the picturebox image (at the location, for the size) into the new bitmap.  That's the image you paste on the clipboard.

        Private Sub PictureBox1_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUp
            If e.X > XStart AndAlso e.Y > YStart Then
                BM = New Bitmap(e.X - XStart, e.Y - YStart, System.Drawing.Imaging.PixelFormat.Format32bppArgb)
                Dim BR As Brush = Brushes.White
                Dim G As Graphics = Graphics.FromImage(BM)
                G.FillRectangle(BR, 0, 0, BM.Width, BM.Height)
    
                Dim BP As Bitmap = New Bitmap(BM.Width, BM.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb)
                Dim Gr = Graphics.FromImage(BP)
                Gr.DrawImage(PictureBox1.Image, 0, 0, New Rectangle(XStart, YStart, BP.Width, BP.Height), GraphicsUnit.Pixel)
                Clipboard.SetDataObject(BP)
    
                PictureBox1.Invalidate()
            Else
                BM = Nothing
            End If
        End Sub
    

    That's the code I was recommending, and it almost works.  However, now I have coded it I see that there is some strange relation between dimension of the image property of the PictureBox and the pixel positions of the mouse and I don't know where that comes from.  I will write it down as yet another reason not to use a picturebox.  You could transfer the whole picturebox thing to the form, and I believe you wouldn't have that issue (although I haven't tested it).

    You could apply an arbitrary percentage factor to the width and height calculation for the new bitmap - in my case it comes out at 1.275.  But that may be suitable for a particular image and/or a particular screen size. Note that this is a scaling problem for the width and height of the new bitmap - the width and height for the image copy is fine because that is based on the destination bitmap size..






     

    Wednesday, January 20, 2010 7:58 AM
  • Thankyou!!

    Yes, I know. I've sort of mixed together two sets of code, which is probably why it was messed up :D

    Thankyou for the code (especially the explanation of it). It refuses to work for me though? When I click and drag its fine, but when the mouseup event occurs it triggers an error. 

    Here is a copy of it:

    System.ArgumentNullException was unhandled
      Message="Value cannot be null. Parameter name: image"
      ParamName="image"
      Source="Microsoft.VisualBasic"
      StackTrace:
           at Microsoft.VisualBasic.CompilerServices.Symbols.Container.InvokeMethod(Method TargetProcedure, Object[] Arguments, Boolean[] CopyBack, BindingFlags Flags)
           at Microsoft.VisualBasic.CompilerServices.NewLateBinding.CallMethod(Container BaseReference, String MethodName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack, BindingFlags InvocationFlags, Boolean ReportErrors, ResolutionFailure& Failure)
           at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateCall(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack, Boolean IgnoreReturn)
           at howto_net_drawing_framework.Form1.picCanvas_MouseUp(Object sender, MouseEventArgs e) in
           at System.Windows.Forms.MouseEventHandler.Invoke(Object sender, MouseEventArgs e)
           at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
           at System.Windows.Forms.Control.WndProc(Message& m)
           at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
           at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
           at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
           at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
           at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
           at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
           at howto_net_drawing_framework.Form1.Main() in 
           at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
           at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           at System.Threading.ThreadHelper.ThreadStart()
      InnerException: 
    

    What could be wrong?

    Thanks! :)
     
    • Edited by bbbclock Saturday, January 30, 2010 11:25 PM
    Wednesday, January 20, 2010 9:04 AM
  • Message="Value cannot be null. Parameter name: image"

    hmm I wonder what can be wrong .
    Coding4fun Be a good forum member mark posts that contain the answers to your questions or those that are helpful
    Please format the code in your posts with the button . Makes it easier to read .
    Wednesday, January 20, 2010 9:08 AM
  • Message="Value cannot be null. Parameter name: image"

    hmm I wonder what can be wrong .
    Thanks for your help. /sarcasm

    Obviously its something to do with the bitmap not being recognised as having content, but why? The code seems fine. Maybe its something to do with the way I'm drawing objects onto the picturebox with my paint app? The code I'm using is from here: http://www.vb-helper.com/howto_net_drawing_framework.html

    hmm :)

    Wednesday, January 20, 2010 9:56 AM
  • The code above assumes that you are getting the picturebox to display an image by setting the picturebox image property to a value.  The other guesses I floated were that it might be the background property of one of the other image properties, but since you didn't indicate which it was, I had to guess.

    What is the method you are using to display the image in the picturebox control?

    Wednesday, January 20, 2010 10:04 AM
  • I tried to explain when you asked, I'm DRAWING on the picturebox, as in lines, shapes etc, using the paint method. See the link above for the code I'm using (I'm not totally sure what 'method' it is).

    Thanks!
    Wednesday, January 20, 2010 10:22 AM
  • In that case, there is no picturebox image.  Don't draw on a picturebox - you will have all sorts of problems getting that to work properly.  Draw on a bitmap.  In the paint event, copy the bitmap into the picturebox image.  

    Then change the above code so that the source for the copy is the bitmap you are drawing onto, instead of the picturebox image.
    Wednesday, January 20, 2010 8:18 PM
  • I tried to explain when you asked, I'm DRAWING on the picturebox, as in lines, shapes etc, using the paint method. See the link above for the code I'm using (I'm not totally sure what 'method' it is).

    Thanks!

    And then what?  Use the pointer to select the shapes you have drawn.  If you want the author to modify the code to your requirements, use the Q & A on the VB Helper site. 
    Wednesday, January 20, 2010 10:33 PM
  • In that case, there is no picturebox image.  Don't draw on a picturebox - you will have all sorts of problems getting that to work properly.  Draw on a bitmap.  In the paint event, copy the bitmap into the picturebox image.  

    Then change the above code so that the source for the copy is the bitmap you are drawing onto, instead of the picturebox image.

    That sounds good, but unfortunately I've got no idea how to modify the code from VB helper to make it draw on a bitmap! :(

    Any ideas?

    Thanks!
    Wednesday, January 20, 2010 11:25 PM
  • And then what?  Use the pointer to select the shapes you have drawn.  If you want the author to modify the code to your requirements, use the Q & A on the VB Helper site. 

    What do you mean, 'and then what'? 
    Wednesday, January 20, 2010 11:26 PM
  • And then what?  How does this thread relate to the code you are using?  The code you are using doesn't provide a PictureBox.Image.  Modifying the shapes drawn on the saved image, is very difficult.
    Wednesday, January 20, 2010 11:39 PM
  • I never suggested the code used a Picturebox.image, Acamar simply assumed that. I also provided a link very early on to show the code I was using and what content was on the picturebox.

    How can I modify the code from VB Helper so that this select code will function? :) 


    Thursday, January 21, 2010 1:45 AM
  • Your query was:
    "How can i make a select tool (rectangular) to select part of a picturebox image"

    and the code examples all referred to dragging the cursor across a picturebox to select a part of the image, so I think it was a reasonable assumption that you were dealing with a picturebox image. But I did also ask.

    If you want to select a portion from comes another image then simply use the code examples provided, but make the source image that other image instead of the picturebox image.  Note my previous comments re automatic sizing that may have occurred when that other image was copied to the picturebox image - you may need to calculate the position and size as a percentage of the picture box size so you can translate them using the same proportion of the original image size - this is part of the problem of using the picturebox.

    If you want modifications to VBHelper code you should ask at the VBHelper site - they are the people who know what their code looks like and what may need to be changed.

    Thursday, January 21, 2010 1:57 AM
  • Thanks for your response,


    Okay, I have an idea as to how I might get it to work, here are the steps:

    1. Draw lines etc on picturebox as normal.
    2. Select a section of the picturebox (visible with rubberband effect).
    3. Click a 'copy selection' button.
    4. Save the contents of the picturebox to an image file as normal (without save file dialog box).
    5. Set that image file to the picturebox background.
    6. Use Acamars code to save the selection to the clipboard.
    7. Change the picturebox background back to nothing.
    8. Delete the temporary saved image file.


    Steps 4-8 would be done all at once on the button press event.

    I would hugely appreciate some help implementing this.

    I mostly need help with steps 2,3 and 6. The rest I can probably do.



    Wow, this is getting far more complicated than I expected. Thanks so much for your help! :)

    Thursday, January 21, 2010 9:33 AM
  • It seems that you have a problem with accessing the image that is drawn on the picturebox, and you have come up with a workaroud that involves saving something to a file and reading it back.  That is not necessary.

    Don't draw to the picturebox - it creates too many complications. A picturebox is designed to provide a surface on which an existing image can be displayed - it shouldn't be used for any more advanced functions than that.  Draw to a bitmap instead.  Create a bitmap the same size as the picturebox, draw to it, and set the picturebox image property to the bitmap each time the bitmap changes.  You may beed to invalidate the picturebox o get the changes to show.

    When you need to copy the selected area, copy it from the bitmap, as copying from the picturebox image property doesn't seem to work properly.  I believe you have the code for doing all that.  Creating a bitmap is the same as the examples given.  Drawing to a bitmap will be exactly the same as drawing to a picturebox image except for the source of the graphics object.  Selecting an area has been covered.  Copying a rectangle from one bitmap to another has been covered, although you will have to change the image source from the example given, becasue that assumed th epicturebox image property instead of a bitmap. Setting the copied bitmap into the clipboard has been covered.

    Thursday, January 21, 2010 11:09 AM
  • You explain drawing to a bitmap instead of a picturebox as if it is easy, but frankly with the code I'm using from the above site I can't see how to do it.

    It sounds like it would be much, much easier, I just don't know how to do it.

    Could you check out the code from the URL i listed above?

    Thanks so much! :)
    Thursday, January 21, 2010 1:12 PM
  • You are already drawing in the PictureBox Paint event.  What is the code you are using there? Whatever it is, it will be something like a DrawRectangle or FillEllipse method of a graphics object.   You will use exactly the same methods to draw to a bitmap, except that the graphic object you use will be derived from the bitmap instead of the picturebox.  The process of creating a bitmap and getting a graphic obect for it has been included in a  previous example.  So the only thing you need to do is to use your current drawing code and move your drawing command from the picturebox paint event to the event where you are creating the bitmap and its graphic object.  There's not reason for you to change the drawing code at all - just change the surface you are drawing to.

    Thursday, January 21, 2010 9:05 PM
  • Thats what I mean, theres isn't any code in the picturebox paint event other than m_Picture.Draw(e.Graphics). Every shape in the code has a different class (which don't mention a picturebox).

    Where do I create a bitmap? In a mousedown event, paint event or what?


    The code which is normal for a paint program is clearly very different in the version I'm using, could you just give it a quick look?

    Thanks! :)
    Thursday, January 21, 2010 10:30 PM
  • I don't understand.  What's m_Picture?  That sounds like a private variable in a class.

    The usual code that I would expect to see in the picturebox paint event, if that's where you are doing the drawing, would be something like:

        Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
            e.Graphics.FillEllipse(Brushes.Black, 50, 50, 20, 30)
            e.Graphics.DrawRectangle(Pens.Red, 12, 25, 17, 22)
        End Sub
    

    To make the change you need to get that drawing as a bitmap, just use that code, but use it with a graphics object created from the bitmap, not the graphics object provided in the Paint function for the picturebox.

    You would place the code in that part of your program where the decision is made to draw the circle or rectangle or whatever.  That might be a button click or a mouse click or a drag and drop operation or a menu selection - it depends on your code and what the program is trying to do.  How does the user decide to draw something at some particular location on the picturebox?








    Thursday, January 21, 2010 11:08 PM
  • Why don't you just look at the code so you know what I'm talking about?


    None of what you are saying makes sense in regards to this code! :)
    Thursday, January 21, 2010 11:23 PM
  • Is it possible that you are trying to make changes to code that you didn't write yourself?  That would explain the references to the VB Helper site.  In order to change code that you didn't write, it is essential that you to go through it line by line and make sure that you understand the significance of every part of the code.  It's not essential to fully understand the syntax - you can look that up at any time - but you must ensure that you are aware of the reason behind every routine that exists in the code, and the actual technique that has been used to achieve the result that the routine requires.  Someone else can't do that for you.

    The alternative is to write the code for yourself.  That way, you can be quite sure you understand what it is doing, and if it is wrong then it is easy to fix. And if it isn't easy to fix, you can post it here(it's your own code) and someone may be able to help.
    Friday, January 22, 2010 12:24 AM
  • Is it possible that you are trying to make changes to code that you didn't write yourself?  That would explain the references to the VB Helper site.  In order to change code that you didn't write, it is essential that you to go through it line by line and make sure that you understand the significance of every part of the code.  It's not essential to fully understand the syntax - you can look that up at any time - but you must ensure that you are aware of the reason behind every routine that exists in the code, and the actual technique that has been used to achieve the result that the routine requires.  Someone else can't do that for you.

    The alternative is to write the code for yourself.  That way, you can be quite sure you understand what it is doing, and if it is wrong then it is easy to fix. And if it isn't easy to fix, you can post it here(it's your own code) and someone may be able to help.
    Obviously I'm making changes to code I didn't write, I've said that many times. 

    I'm at a loss as to why you wouldn't have just looked at the code I linked, saving yourself all the time you wasted typing the last 6 lengthy messages. Clearly you won't however.

    Thanks anyway.
    Friday, January 22, 2010 4:13 AM
  • Obviously I'm making changes to code I didn't write, I've said that many times. 
    I don't believe you have said any such thing, as the only code you have posted was mostly what I suggested.  But if that's what's happening you should direct your queries to whoever wrote that code - that only seems sensible to me, and I believe it has already been recommended.

    I am happy to show you how to solve the problem as you posted it (and I think I have done that) but I'm not interested in re-writing someone else's code to make it function differently - that's the sort of task that whoever wrote it would probably be very pleased to do for you.  For all anyone knows, the original code may have been written for a completely different purpose, and it may be impossible to make it do what you want.  Again, the person who wrote it would be able to determine whether or not that's the case.
    Friday, January 22, 2010 4:55 AM
  • Obviously I'm making changes to code I didn't write, I've said that many times. 
    I don't believe you have said any such thing, as the only code you have posted was mostly what I suggested.  But if that's what's happening you should direct your queries to whoever wrote that code - that only seems sensible to me, and I believe it has already been recommended.

    I am happy to show you how to solve the problem as you posted it (and I think I have done that) but I'm not interested in re-writing someone else's code to make it function differently - that's the sort of task that whoever wrote it would probably be very pleased to do for you.  For all anyone knows, the original code may have been written for a completely different purpose, and it may be impossible to make it do what you want.  Again, the person who wrote it would be able to determine whether or not that's the case.
    Actually I mentioned it MANY times:

    The code I'm using is from here: http://www.vb-helper.com/howto_net_drawing_framework.html
     See the link above for the code I'm using (I'm not totally sure what 'method' it is).
    modify the code from VB helper to make it draw on a bitmap!
    but frankly with the code I'm using from the above site I can't see how to do it.
    The code which is normal for a paint program is clearly very different in the version I'm using, could you just give it a quick look?

    However if you don't want to edit someone elses code thats fine. Thanks.
    Friday, January 22, 2010 1:24 PM