ImageBuffer.Item Property

Gets or sets bytes in the image data of this ImageBuffer
Syntax:
[VB.NET]
Public Item( ByteIndex As Integer, LineIndex As Integer ) As Byte Public Item( ByteIndex As Integer ) As Byte
[C#]
Public byte Item[ int ByteIndex, int LineIndex ] Public byte Item[ int ByteIndex ]
Parameter Description
ByteIndex

Index of the selected byte in the selected line or the image.

LineIndex

Index of the selected line.

Remarks:

The image data is stored bottom-up: the bottom line has line index 0; the bottom left pixel has byte index 0. The bytes per pixel depend on the color format of this ImageBuffer.

Example:

The following example shows how to access the image data by addressing the bytes of the image buffer. It adds brightness to the image.

[VB.NET]
Dim Buf As ImageBuffer Buf = ICImagingControl1.ImageActiveBuffer   Dim p As Integer Dim imageSize As Integer imageSize = Buf.Lines * Buf.PixelPerLine * Buf.BitsPerPixel / 8   For p = 0 To imageSize - 1     Dim c As Integer       ' Get the value of the byte.     c = Buf(p)       ' Make it a bit brighter.     c = c + 20     If c > 255 Then c = 255       ' Write it back to the buffer.     Buf(p) = c Next
[C#]
ImageBuffer Buf = ICImagingControl1.ImageActiveBuffer;   int p = 0; int imageSize = Buf.Lines * Buf.PixelPerLine * Buf.BitsPerPixel / 8;   for (p = 0; p < imageSize; p++) {     // Get the value of the byte.     int c = Buf[p];       // Make it a bit brighter.     c = c + 20;     if (c > 255)     {         c = 255;     }       // Write it back to the buffer.     Buf[p] = (byte)c; }

The other access variant of specifying a line and a byte in the line is shown in the following example. It inverts an image buffer.

[VB.NET]
Dim Buf As ImageBuffer Buf = ICImagingControl1.ImageActiveBuffer   Dim y As Integer Dim x As Integer Dim lineWidth As Integer lineWidth = Buf.PixelPerLine * Buf.BitsPerPixel / 8   For y = 0 To Buf.Lines - 1     For x = 0 To lineWidth - 1         ' Invert the color value.         Buf(x, y) = 255 - Buf(x, y)     Next Next
[C#]
ImageBuffer Buf = ICImagingControl1.ImageActiveBuffer;   int y = 0; int x = 0; int lineWidth = Buf.PixelPerLine * Buf.BitsPerPixel / 8;   for (y = 0; y < Buf.Lines; y++) {     for (x = 0; x < lineWidth; x++)     {         // Invert the color value.         Buf[x, y] = (byte)(255 - Buf[x, y]);     } }
See also: ImageBuffer, ImageBuffer.Lines, ImageBuffer.PixelPerLine, ImageBuffer.BitsPerPixel

<< ImageAvailableEventArgs.ImageBuffer

This site is part of The Imaging Source Network. Other sites include Company Portal, Image Processing, Astronomy Cameras, Astronomy Cameras Blog, Blog caméras d'astronomie, Astronomy Cameras Competition, TX Text Control, TX Text Control Blog and Forums.