C# black lines on bitmap

388 Views Asked by At


I work with a camera that has its own API. The camera sends me an array of gray-scale image and I turn it to colorful.
However, when I do that, I get a picture that has black lines in it.
The image is this:

enter image description here


As you can see, the image has black lines in it and I don't understand why because the picture I get straight from the camera is alright and doesn't have black lines.

The code I use for getting the image is:

Camera.Memory.Lock(s32MemID);
Camera.Memory.ToIntPtr(s32MemID, out ptrImage);
short[] temp = new short[m_tMatrixArray.Length];
Marshal.Copy(ptrImage, temp, 0, temp.Length);
System.Buffer.BlockCopy(temp, 0, m_tMatrixArray, 0, temp.Length * sizeof(short));


The code I use for making the bitmap is:
colorArray is fine.

int[] data = new int[m_tMatrixArray.Length];
Color[] colorArray=new Color[256];
Color[] m_color = new Color[4096];
float l_dPaletteStepStep = (colorArray.Length - 1) / (float)m_color.Length;
getColorArray(colorArray);
for (int i = 0; i < m_color.Length; i++) m_color[i] = colorArray[(int)Math.Ceiling(i * l_dPaletteStepStep)];

for (int i = 0; i < m_tMatrixArray.Length; i++) data[i] = m_color[(int)m_tMatrixArray[i]].ToArgb(); 
Marshal.Copy(data,0,bmpData.Scan0,data.Length);
bmp.UnlockBits(bmpData);
Camera.Memory.Unlock(s32MemID);

videoImageControl.Image = bmp;
videoImageControl.Invalidate();



Thank you for your help.

0

There are 0 best solutions below