c# - Extract RGB information from image into an array -


i must save bitmap file, , access rgb of each pixel , save decimal code of each color of pixel (meaning red, green , blue) in separate matrix (array).

for hidding textfile in bmp lmage l need save each rgb code in seperate matrix...lm looking effiecient way,this code

this code run,but l cant show result of each matrix in text of lable.how can see output of each matrix?

 bitmap bmp1 = new bitmap(@"d:a.jpg");         picturebox1.image = bmp1;         color col = new color();         int w = int32.parse(bmp1.width.tostring());         int h = int32.parse(bmp1.height.tostring());          int[,] redstr = new int[w,h];         int[,] greenstr = new int[w, h];         int[,] bluestr = new int[w, h];         int red = 0, green = 0, blue = 0;         (int = 0; < w; i++)         {             (int j = 0; j < h; j++)             {                 col = bmp1.getpixel(i, j);                 red = col.r;                 green = col.g;                 blue = col.b;                 redstr[i, j] = red;                 greenstr[i, j] = green;                 bluestr[i, j] = blue;              }              } 

from following page ... https://msdn.microsoft.com/en-us/library/system.drawing.bitmap.getpixel.aspx

you can use access each pixel of image ...

private void getpixel_example(painteventargs e) {  // create bitmap object image file. bitmap mybitmap = new bitmap("yourfilename.jpg");  // color of pixel within mybitmap. color pixelcolor = mybitmap.getpixel(50, 50);  } 

then can check pixelcolour rgb components.

evidently need create 2d array (matrix) same dimensions image. , if need store separate rgb components, need 3d array.


Comments