Drawing Selection Rectangles RRS feed

  • Question

  • User-549357364 posted
    I need to draw a visible selection rectangle over an image that is displayed and know the end points for the rectangle when user has made the selection.

    The selection has to be made with mouse like in photoshop or any other image editor.
    Thanks in advance
    Monday, September 26, 2005 11:23 PM

All replies

  • User-819801985 posted

    You'll need to use Javascript to draw the rectangle and get the coordinates.  Try looking here or here for ideas how to do this.

    Tuesday, September 27, 2005 1:52 AM
  • User-549357364 posted

    Thank You.

    Also, is there a way using GDI+ functions like drawRectangle.

    I am able to draw static rectangles on screen but they hide all the buttons and images in the background. The Code is as follows

    Is there a way to show the drawn rectangle without hiding the image or server controls in the background.

    Can i use the mouse to define the starting and ending points for the rectangle.

    b = New Bitmap(100, 100)


    Page.Response.ContentType = "image/jpeg"

    g = Graphics.FromImage(b)

    redpen = New Pen(Color.Red, 1)

    g.DrawRectangle(redpen, 100, 100, 300, 300)

    b.Save(Page.Response.OutputStream, format.Jpeg)



    Tuesday, September 27, 2005 4:56 AM
  • User-819801985 posted

    Yes, you can use gdi+ to draw rectangles, but what you're really doing is drawing them on the Server, then ASP.Net is creating the HTML for the browser with your rectangles included.  The completed page is then pushed over the wire to finally be rendered in the user's browser.

    As far as your buttons being hidden, I would need to look closer at your actual code.  If you are using absolute positioning, then most likely, you need to make sure that your rectangles appear in the HTML before the buttons, etc.  Also, if you are using any CSS z-index values on these various elements, then that could be a reason for this layering.

    Unfortunately, if you want to capture the user's mouse movements, you'll need to do so using client-side script.

    An alternative to this would be to author a Windows Forms application (this is where gdi+ shines!), or a Java Applet to be embedded in your page and run in the context of the browser, although this gets much more complicated.

    I hope this helps to further answer your questions.

    Tuesday, September 27, 2005 9:42 AM
  • User-549357364 posted
    I think i will use client side script or a flash program to do this work.
    Thanks again for your support.
    Wednesday, September 28, 2005 6:52 AM