Page 1 of 1

ScreenShot / Watermark

Posted: Thu Jun 17, 2010 9:44 pm
by zachman61
how can i make a program take a screenshot but have a watermark in it

Re: ScreenShot / Watermark

Posted: Fri Jun 18, 2010 1:27 am
by mandai
You can use this:
Code: Select all
Dim thisScreen As Rectangle = Screen.PrimaryScreen.Bounds

PictureBox1.Image = New Bitmap(thisScreen.Width, thisScreen.Height)
Dim gfx As Graphics = Graphics.FromImage(PictureBox1.Image)
gfx.CopyFromScreen(0, 0, 0, 0, PictureBox1.Image.Size) 'take the screenshot

Dim watermark As Bitmap = Bitmap.FromFile("watermark.png") 'load our watermark image

watermark.MakeTransparent(Color.White) 'choose this depending on your watermark background (optional)

Dim cm As ColorMatrix = New ColorMatrix()
cm.Matrix33 = 0.5F 'transparency level

Dim ia As ImageAttributes = New ImageAttributes()
ia.SetColorMatrix(cm)

'draw to top left
gfx.DrawImage(watermark, New Rectangle(0, 0, watermark.Width, watermark.Height), 0, 0, watermark.Width, watermark.Height, GraphicsUnit.Pixel, ia)
gfx.Dispose()
ia.Dispose()
watermark.Dispose()
PictureBox1.Refresh()

Re: ScreenShot / Watermark

Posted: Fri Jun 18, 2010 8:13 pm
by Lewis
Mandai you are one genius you have helped me aswell :)

Re: ScreenShot / Watermark

Posted: Sat Jun 19, 2010 5:19 am
by mikethedj4
Lewis-Froom wrote:
Mandai you are one genius you have helped me aswell :)
I gotta agree! Mandai, is very helpful along with so many other users here!

Re: ScreenShot / Watermark

Posted: Tue Jun 22, 2010 12:52 am
by zachman61
your code does not work

Re: ScreenShot / Watermark

Posted: Tue Jun 22, 2010 3:50 pm
by hungryhounduk
your code does not work
Zachman

Instead of just posting that above...be a bit more specific, ie: post your code with the error, then maybe people will spot the error and help u out cooll;

Chris

Re: ScreenShot / Watermark

Posted: Tue Jun 22, 2010 6:29 pm
by zachman61
i fixed it i forgot to use imports

Re: ScreenShot / Watermark

Posted: Fri Jun 25, 2010 5:19 pm
by un kn0 wn
zachman61 wrote:
i fixed it i forgot to use imports
lol, Thx for the code m8.

Re: ScreenShot / Watermark

Posted: Tue Jun 29, 2010 2:40 am
by zachman61
i got it down to the right if anyone wants it

Re: ScreenShot / Watermark

Posted: Tue Jun 29, 2010 11:40 pm
by mandai
Bottom right would be:
Code: Select all
gfx.DrawImage(watermark, New Rectangle(PictureBox1.Image.Width - watermark.Width, PictureBox1.Image.Height - watermark.Height, watermark.Width, watermark.Height), 0, 0, watermark.Width, watermark.Height, GraphicsUnit.Pixel, ia)
The only part that changed is the destRect X and Y parameters.