|
-
Dec 7th, 2008, 01:37 PM
#1
Thread Starter
Fanatic Member
[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.
-
Dec 7th, 2008, 02:21 PM
#2
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?
-
Dec 7th, 2008, 02:24 PM
#3
Thread Starter
Fanatic Member
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.
-
Dec 7th, 2008, 02:41 PM
#4
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.
-
Dec 7th, 2008, 02:55 PM
#5
Thread Starter
Fanatic Member
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
-
Dec 7th, 2008, 02:58 PM
#6
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.
-
Dec 7th, 2008, 05:26 PM
#7
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:
Dim HighlightedText As Bitmap = _
bmp.Clone(rect, Imaging.PixelFormat.DontCare)
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:
e.Graphics.FillRectangle(Brushes.Yellow, rect)
e.Graphics.DrawImage(HighlightedText, rect)
All the best, BB.
Last edited by boops boops; Dec 7th, 2008 at 05:35 PM.
-
Dec 7th, 2008, 05:38 PM
#8
Thread Starter
Fanatic Member
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.
-
Dec 7th, 2008, 06:24 PM
#9
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|