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.
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
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 

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-Froom wrote:Mandai you are one genius you have helped me aswellI gotta agree! Mandai, is very helpful along with so many other users here!
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 

your code does not workZachman
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
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 

zachman61 wrote:i fixed it i forgot to use importslol, Thx for the code m8.
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 

Bottom right would be:
Code: Select all
The only part that changed is the destRect X and Y parameters.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)
10 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023