Is there a way to open an image and read each pixel value in vb.net?
Is there a way to open an image and read each pixel value in vb.net?
The greatest discovery of all men through lifetime is that a man can alter his life by altering his attitude!
I need more info on what you are trying to acheive. post a sample code or something.
However the code below shows how you can read pixel values of an image on a form with a picturebox named picImage
you can use the .R,.G and the .B individually or as an RGB Group to form a colorCode:Dim clr As Integer Dim xmax As Integer Dim ymax As Integer Dim x As Integer Dim y As Integer ' Get the bitmap and its dimensions. Dim bm As Bitmap = picImage.Image xmax = bm.Width - 1 ymax = bm.Height - 1 ' read the pixels For y = 0 To ymax For x = 0 To xmax With bm.GetPixel(x, y) clr = .R & .G & .B console.writeline(.R) console.writeline(.G) console.writeline(.B) console.writeline(clr) End With Next x Next y
You can further read the properties of the pixel using the .operator (dot operator)
Example: bm.GetPixel(x, y).GetBrightness
To read the pixels straight from a file use:
To manipulate the pixels use the SetPixel methodCode:Dim picFile as string= "C:\somepath\somepic.jpg" Dim bm As Bitmap As New Bitmap(picFile) 'this will replace Dim bm As Bitmap = picImage.Image
Last edited by ToxXxic; Oct 7, 2009 at 03:47 PM.
Code King aka Code WizZzard: Motivated By The Challenge, Driven By The Will To Succeed.
In The Land Of Programmers, The Code WizZzard Is KING. Sen on anything VB
ok i am going to try that code parry...
umm what about reading the values of a .img file (iso file)..do you have any idea on how to conduct this..I have done it using binary reader..is that the right way to use it so far it looks good?
The greatest discovery of all men through lifetime is that a man can alter his life by altering his attitude!
sounds like 2 different things to me:
1. Graphics - Image (jpg, png, gif, etc)
2. CD/DVD - Image (iso, img, bin, etc)
Cultured in Aggression and Koding like a Warrior!!
“Common sense is instinct. Enough of it is genius.” - George Bernard Shaw.
"The significant problems we face cannot be solved by the same level of thinking that created them." - Albert Einstein
The code you provided returned an error arithmetic operation resulted in an overflow.
Trying to figure out why was debugging it dont see the reason..
I am doing both: the 2. CD/DVD - Image (iso, img, bin, etc) I did that using binary readers code ran perfectly.
But for graphics i am getting an arithmetic overflow error
Last edited by Arch_Angel; Oct 7, 2009 at 02:34 AM. Reason: merged multiple posts
The greatest discovery of all men through lifetime is that a man can alter his life by altering his attitude!