c# - Get all pixel information of an image efficiently -
I created a program to get all the image pixel RGB color code from the picture. And the X position changes from zero to width and also by looping the Y.
OK, this is work, but the problem is that it can take any more than 20 minutes to image all the pixels (1000 * 604 height width) Can someone help?
I wonder if this process looks so long, how can we create programs like image bar code reader. I want to get all the pixel value from the image, here's my C # code below.
I have also uploaded my program, if you do not agree then check it out.
zero myimage () {mypic = new bitmap (pathname); Int imwid = mypic.Width; Int imhei = mypic.Height; Intel Total = IMWD * EHEILLY; For (int z = 0; zlt; iiii; z ++) {for (int i = 0; i & lt; imwd; i ++) {color pixel collar = mypic. Gatepixel (I, Z); Textbox2.AppendText ("" + pixelcolor.R + "" + pixelcolor.G + "" + Pixel Color. B + "" + Pixel Collar. A + Environment. NewLine); }}}}
Take a look at this:
var data = mypic.LockBits (new rectangle (point. Api, myupic size), image lockcode. Redrawight, myupic pixel format); Var pixel size = data Pixel format == pixel format.format 32bpaprabbb? 4: 3; // works with only 32 or 24 pixel-bit bitmaps! Var padding = data.Stride - (data.Width * pixelSize); Var bytes = new byte [data. Highlight * Data Strad]; Copy the // bytes to Marsh Marshal from bitmap. Copy (data scan, 0, bytes, 0, bytes lang); Var Index = 0; Var Builder = New StringBuilder (); For (var y = 0; y and lt; data. Height; y ++) {for (var x = 0; x & lt; data.Width; x ++) {color pixel color = color.form ARBB (Pixel size == 3? 255: bytes [index + 3], // one component if current bytes [index 2], // r component bytes [index + 1], // g component bytes [index] / b component ); Builder. Append (""). Append (pixel collar .r). Append (""). Append ("Pixel Collar."). Append ("") .Append (pixel collar.b) .Append ("") .Append (PixelRoller A.) Ependline (); Pointer + = pixel size; } Pointer + = padding; } // Copy the bytes back to the bitmap martial from the array. Copy (bytes, 0, data. Scan, bytes lang); Textbox2.Text = Builder. Toasting ();
There is only one example, read some good tutorials about lockbits
and what is usually to understand imaging clearly.
Comments
Post a Comment