Results 1 to 9 of 9

Thread: [RESOLVED] [2008] image overlay

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2006
    Posts
    607

    Resolved [RESOLVED] [2008] image overlay

    Hey guys,
    I have a screenshot application but I want to add a feature to it. Basically I want to add an image overlay .. like a highlight of the image.



    you see how thats highlighting the text, I wanna do that but put it on top of an image.

    My program will have two variables available, the orignal image (saved on harddisk) and the Rectangle of the image the user wants to highlight.

    An alternative is I want to darken the "outside" of the rectangle while the inside stays the regular color giving it that emphsized look.

  2. #2
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: [2008] image overlay

    You took a screenshot of a webpage but are referring to rectangles so I want to be sure; is your question regarding ASP.Net or VB.Net and Winforms?
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2006
    Posts
    607

    Re: [2008] image overlay

    Its winforms. I just took the screenshot of that because thats how I want myne to be.

    pretend the screenshot is not the text but its an image. pretend the "chat with ..." isnt there, so just pretend the whole screenshot is white.

    now on the white image i wanna draw a rectangle with a yellow background but with a low opacity so it looks like a highlight.

  4. #4
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: [2008] image overlay

    Easiest way may be using the PictureBox and settings its Opacity.

    Check out this thread; it may help with setting the opacity.
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2006
    Posts
    607

    Re: [2008] image overlay

    Alright I checked that thread but I dont know if It could help me.

    I think i may need to provide more details:

    I have a image saved on harddrive which I can create a new Bitmap Object from.

    I have a rectangle that specfies an area on that image.

    I want to put a yellow overlay on top of that rectangle but still be opaque enough to view the contents underneath.

    Even though its winforms, theres not really a UI (the UI is hidden).

    EDIT: I have found what I needed however it is in chsarp and uses unsafe code (which was what I was looking for initially). I posted in vb because im active here so I know some of the members

  6. #6
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: [2008] image overlay

    Oh I understand now. So you have an image but you want to highlight a specific part of that image, correct? Unfortunately I'm not very good with GDI+ so I'm not really sure what your solution should be but I would imagine you could fill that rectangle on the bitmap and provide the alpha channel so it's see through.
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  7. #7
    PowerPoster boops boops's Avatar
    Join Date
    Nov 2008
    Location
    Holland/France
    Posts
    3,201

    Re: [2008] image overlay

    Hi Masfenix,

    I wonder whether I could help here. Assuming the text you want to highlight appears against a uniform background, it shouldn't be too difficult to copy the text rectangle with a transparent background. For example, assuming bmp is your bitmap and rect is the rectangle, and the background colour is white then:
    vb Code:
    1. Dim HighlightedText As Bitmap = _
    2.        bmp.Clone(rect, Imaging.PixelFormat.DontCare)
    3. HighlightedText.MakeTransparent(Color.White)
    If you don't know the background colour behind the text that gets a bit more complicated. Possibly you could capture the colour of the top left pixel of the rectangle with bmp.HighlightedText.GetPixel(0,0).

    In the Paint Event or OnPaint Sub, paint rect in yellow, then paint the bitmap HighlightedText on top of it:
    vb Code:
    1. e.Graphics.FillRectangle(Brushes.Yellow, rect)
    2. e.Graphics.DrawImage(HighlightedText, rect)
    All the best, BB.
    Last edited by boops boops; Dec 7th, 2008 at 05:35 PM.

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2006
    Posts
    607

    Re: [2008] image overlay

    Actually I figured it out. Its not relaly text to say. Basically what it is is that it grabs a screenshot of the desktop. The user is able to use a "transparent form" as a camera to select a rectangle.

    So my program now has a full desktop image and a rectangle that specifies the stuff thats highlighted.

    And I changed my gameplan, instead of putting an overlay I put the contrast down on the whole image but not inside the box.

    I just went pixel by pixel skipping the pixels if they were inside the rectangle and just changing their values to a -30 contrast. Ofcourse this was done using unsafe code.

  9. #9
    PowerPoster boops boops's Avatar
    Join Date
    Nov 2008
    Location
    Holland/France
    Posts
    3,201

    Re: [2008] image overlay

    I'm glad for you that you figured it out. But it would have been kinder if you had marked the thread resolved before I went to the trouble of replying.

    I enjoy trying to solve problems with the bits of knowledge I have (such as they are) but not so much if it turns out to be unnecessary.

    regards, BB

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width