473,320 Members | 1,957 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How to get the color of a pixel in C#

I have an object derived from Control and I place an icon in it during Paint
handler. I now want to get the color of a particular pixel in my control. In
C++ I could use CDC::GetPixel(x,y). Is there some way to do this in C#, and
if not, how do I do it in unmanaged code?
Thanks in advance.
Nov 15 '05 #1
1 10022
The GDI+ FAQ has an article on how to capture a control or the screen.
Essentially GDI+ DC's don't have a bitmap that you can peek so you have to
grab the bitmap from the window or screen and do getpixel on the captured
image.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Check out February's edition of Well Formed.
Non-client drawing, Graphics Transform stack and Flood-Filling
http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

Read my Blog at http://bobpowelldotnet.blogspot.com

"Valerie Hough" <su*****@hcs-usa.com> wrote in message
news:eH**************@TK2MSFTNGP10.phx.gbl...
I have an object derived from Control and I place an icon in it during Paint handler. I now want to get the color of a particular pixel in my control. In C++ I could use CDC::GetPixel(x,y). Is there some way to do this in C#, and if not, how do I do it in unmanaged code?
Thanks in advance.

Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Scott Schluer | last post by:
Is there a way to use the Image class to convert a color photo (GIF or JPEG) to a B&W photo? Thanks, Scott
2
by: sympatico | last post by:
im trying to read an image(*.bmp) from file and then color the black pixels in it to the color i want using argb. Below is the code of what im trying to do but this gives me an error "setPixel is...
2
by: dever | last post by:
I checked my color printers's Printersettings.SupportsColor, which all showed false. What is wrong that I could not use this property. Also, what other way to detect if a printer is color...
7
by: walter.alex | last post by:
November 16 2005 -- The recent launch of the new 5 year advertising solution from MillionPixelClick.com means the pixel advertising craze will continue unabated. Selling advertising space by the...
2
by: fripper | last post by:
I am using VB 2005 and want to generate a graphic in a picture box control where the color of each pixel is determined by particular values calculated for each pixel. These values are manipulated...
33
by: Dave (DreamIsle) | last post by:
Hello. I'm working on a layout that I need to be pixel specific. How can I get the font to stay precisely the height I need? Specifying line-height or font-size in px doesn't yield the results I...
30
by: Chaos | last post by:
As my first attempt to loop through every pixel of an image, I used for thisY in range(0, thisHeight): for thisX in range(0, thisWidth): #Actions here for Pixel thisX, thisY But it takes...
6
by: Hooyoo | last post by:
I want to get the color of the specified pixel in the screen. Firstly I get the position of the cursor: //Get the position of cursor. Point position = Cursor.Position; Next I want to get the...
8
by: JEO | last post by:
I have a Visual basic 3 App that I am converting to VBA in Microsoft Access 2003. The VB3 app successfully recolors a bitmap image with code using pixel locations when clicking on option buttons...
0
by: icebeta | last post by:
hi, I'm doing a project in c# that removes the green background in a picture, like a green screen effect in movies. i already made it partially working. but the problem is that it only remove...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.