Click here to Skip to main content
12,690,986 members (32,848 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as



does anybod know how to access pixel data?

, 21 Mar 2011 CPOL
Hi,This is the easiest way but slow:System.Drawing.Bitmap oBitmap=new Bitmap("MyFile.bmp");System.Drawing.Color color= oBitmap.GetPixel(Y,X);oBitmap.SetPixel(X, Y, color);The faster way might be using Windows API functions.Hope this can help you.


Members may post updates or alternatives to this current article in order to show different approaches or add new features.

8 Sep 2011
Hi,While this reply is late I thought best to include the answer in case any other fall across this question.Lets assume you have read your image in as a colour image:Image My_Image = new Image("filename_string");To access each individual pixel of My_Image you...
19 Dec 2011
Viktor Signaievskyi
The fastest way in C# to deal with pixels it to use pointer to bitmap:The code snippet is:public int DoSomeStuffWithPixels(ref Bitmap b){ BitmapData bmData = b.LockBits(new Rectangle(0, 0, b.Width, b.Height), ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb); System.IntPtr...
29 Sep 2011
Member 7773377
5 alternatives  
Hey guys, I was wondering if anybody could help me out...I'm taking only my second delve into c# and I've been trying to get my hed round this for a few days and would really appriciate the helpBasically I need to be able to read and draw individual pixels from an image. The overall goal...
21 Mar 2011
Sergey Alexandrovich Kryukov
With System.Drawing, the faster way of accessing bits is System.Drawing.Bitmap.LockBits. See[^] for complete help and a code sample.System.Drawing.Bitmap.GetPixel/SetPixel method are too slow and are note used ofter; good enough if you need...
11 May 2014
Raul Juarez
Hey Guys,Please check that the RGB values are not in the same order.In the example://Redbyte Red_val = My_Image.Data[y,x,0];//Greenbyte Green_val = My_Image.Data[y,x,1];//Bluebyte Blue_val = My_Image.Data[y,x,2];In reality://Bluebyte Blue_val =...


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

aidin Tajadod
Web Developer Volt
United States United States
No Biography provided

| | Privacy | Terms of Use | Mobile
Web02 | 2.8.170117.1 | Last Updated 21 Mar 2011
Article Copyright 2011 by aidin Tajadod
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid