ScreenShot / Watermark

If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
10 posts Page 1 of 1
Contributors
User avatar
zachman61
VIP - Donator
VIP - Donator
Posts: 1892
Joined: Wed Dec 16, 2009 9:56 pm

ScreenShot / Watermark
zachman61
how can i make a program take a screenshot but have a watermark in it
Nailing my feet to the floor is easier than using my own muscles to balance, but you don't see me doing that :)
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

Re: ScreenShot / Watermark
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()
Lewis
Coding God
Coding God
Posts: 1564
Joined: Sun Dec 20, 2009 2:12 pm

Re: ScreenShot / Watermark
Lewis
Mandai you are one genius you have helped me aswell :)
Image
User avatar
mikethedj4
VIP - Site Partner
VIP - Site Partner
Posts: 2592
Joined: Thu Mar 25, 2010 4:36 am

Re: ScreenShot / Watermark
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!
User avatar
zachman61
VIP - Donator
VIP - Donator
Posts: 1892
Joined: Wed Dec 16, 2009 9:56 pm

Re: ScreenShot / Watermark
zachman61
your code does not work
Nailing my feet to the floor is easier than using my own muscles to balance, but you don't see me doing that :)
User avatar
hungryhounduk
VIP - Site Partner
VIP - Site Partner
Posts: 2870
Joined: Mon Jul 27, 2009 11:58 am

Re: ScreenShot / Watermark
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
Image
User avatar
zachman61
VIP - Donator
VIP - Donator
Posts: 1892
Joined: Wed Dec 16, 2009 9:56 pm

Re: ScreenShot / Watermark
zachman61
i fixed it i forgot to use imports
Nailing my feet to the floor is easier than using my own muscles to balance, but you don't see me doing that :)
User avatar
un kn0 wn
VIP - Donator
VIP - Donator
Posts: 269
Joined: Mon Mar 29, 2010 6:12 pm

Re: ScreenShot / Watermark
un kn0 wn
zachman61 wrote:
i fixed it i forgot to use imports
lol, Thx for the code m8.
User avatar
zachman61
VIP - Donator
VIP - Donator
Posts: 1892
Joined: Wed Dec 16, 2009 9:56 pm

Re: ScreenShot / Watermark
zachman61
i got it down to the right if anyone wants it
Nailing my feet to the floor is easier than using my own muscles to balance, but you don't see me doing that :)
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

Re: ScreenShot / Watermark
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.
10 posts Page 1 of 1
Return to “Coding Help & Support”