Get Pixels

Heres your chance to share your own tutorials with the community. Just post them on here. If your lucky they may even be posted on the main site.
6 posts Page 1 of 1
Contributors
User avatar
bjm0008
Dedicated Member
Dedicated Member
Posts: 69
Joined: Thu Aug 13, 2009 2:35 am

Get Pixels
bjm0008
If you are making a paint program and want to add a 'Ink Dropper' tool to your form this tutorial will come in handy.

First of all add a timer onto your form.

Image

And double click that timer and type in the following:
Code: Select all
Dim BMP As New Drawing.Bitmap(1, 1)
        Dim GFX As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(BMP)
        GFX.CopyFromScreen(New Drawing.Point(MousePosition.X, MousePosition.Y), _
        New Drawing.Point(0, 0), BMP.Size)
        Dim Pixel As Drawing.Color = BMP.GetPixel(0, 0)
        Me.BackColor = Pixel
Me.Backcolor = Pixel
Where it says "Me" That means Form1, Instead of Me you can use a picturebox, a panel, stuff like that.
Where it says "BackColor, That just means that the color of the pixel your cursor is on will be turned into Form1's Backcolor, Instead of backcolor you could use Forecolor or the Transparency Key.
(Forecolor = the text)
(Transpartency Key = a color that will appear transparent on the form)

Image

You can't see it but my cursor is on the little yellow square in next to "Pixels" ( The Icon )
Image
User avatar
Nery
Co-Admin Moderator
Co-Admin Moderator
Posts: 1117
Joined: Mon Sep 07, 2009 8:11 pm

Re: Get Pixels
Nery
Oh thats cool! This is some kind of Color Picker :)
User avatar
Normall
Member
Member
Posts: 49
Joined: Wed Nov 25, 2009 9:25 pm

Re: Get Pixels
Normall
What is this use for othe than color picking?
User avatar
bjm0008
Dedicated Member
Dedicated Member
Posts: 69
Joined: Thu Aug 13, 2009 2:35 am

Re: Get Pixels
bjm0008
Well, think of it.
What can this be used for?
I made it because I've seen paint programs on the site and I wanted people to know how they could start to make a 'ColorDropper' tool.
Image
User avatar
Nery
Co-Admin Moderator
Co-Admin Moderator
Posts: 1117
Joined: Mon Sep 07, 2009 8:11 pm

Re: Get Pixels
Nery
It can be used to get the hexadecimal or RGB properties of a color displayed in your screen: Its very handy sometimes!
User avatar
Usman55
VIP - Site Partner
VIP - Site Partner
Posts: 2821
Joined: Thu Dec 24, 2009 7:52 pm

Re: Get Pixels
Usman55
Hello Everyone!

I have also made a Color Picker File that works the same but has more features than this! I will upload it later!
Image
6 posts Page 1 of 1
Return to “Tutorials”