how to convert an array into a video and show it

Hi I am getting a float array from a TOF camera and i want to show it in a windows form.

the camera gives a lot of data. the important ones are the descriptor who contains the number of rows and columns (in pixels) the max value is 200 row X 200 columns.
Them the camera gives some float arrays of same size: distance , intensities(gray scale image), amplitude, and x, y and z coordenates for each pixel. There is also an unsigned array who contains falgs of each pixel.
The array for building the image is a "float Intensities[200*200]" sort by rows (0-199 fist row , 200-299 second row ... ). the value of each pixel vary from 0 to 32000 and is the one I use to build the image.
I already convert this array to bmp, the function to convert to bmp I used is:

Collapse | Copy Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
bool CameraClass::GreyImage(float *Array,float max,float min, int width, int height,LPCTSTR bmpfile){
	//Mediante la recta y=Ax+B donde x es un valor de Array
	//Variando min y max se logra modificar el contraste

	float B=min*255/(min-max);
	float A=(255-B)/max;
 

	//BYTE *Buffer;
	//Buffer= new BYTE [3*width*height];
	BYTE Buffer[3*200*200]; //deberia asignarse dinamicamente pero da error! 

	for (int i=0;i<height;i++){
		for(int j=0;j<width;j++){
		Buffer[3*(width*((height-1)-i)+j)]=(BYTE)(A*Array[width*i+j]+B);
		Buffer[3*(width*((height-1)-i)+j)+1]=(BYTE)(A*Array[width*i+j]+B);
		Buffer[3*(width*((height-1)-i)+j)+2]=(BYTE)(A*Array[width*i+j]+B);
		}
	}
	
	long paddedsize=width*height*3;
 
	// declare bmp structures 
	BITMAPFILEHEADER bmfh;
	BITMAPINFOHEADER info;
	
	// andinitialize them to zero
	memset ( &bmfh, 0, sizeof (BITMAPFILEHEADER ) );
	memset ( &info, 0, sizeof (BITMAPINFOHEADER ) );
	
	// fill the fileheader with data
	bmfh.bfType = 0x4d42;       // 0x4d42 = 'BM'
	bmfh.bfReserved1 = 0;
	bmfh.bfReserved2 = 0;
	bmfh.bfSize = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + paddedsize;
	bmfh.bfOffBits = 0x36;		// number of bytes to start of bitmap bits
	
	// fill the infoheader

	info.biSize = sizeof(BITMAPINFOHEADER);
	info.biWidth = width;
	info.biHeight = height;
	info.biPlanes = 1;			// we only have one bitplane
	info.biBitCount = 24;		// RGB mode is 24 bits
	info.biCompression = BI_RGB;	
	info.biSizeImage = 0;		// can be 0 for 24 bit images
	info.biXPelsPerMeter = 0x0ec4;     // paint and PSP use this values
	info.biYPelsPerMeter = 0x0ec4;     
	info.biClrUsed = 0;			// we are in RGB mode and have no palette
	info.biClrImportant = 0;    // all colors are important

	// now we open the file to write to
	HANDLE file = CreateFile ( bmpfile , GENERIC_WRITE, FILE_SHARE_READ,
		 NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
	if ( file == NULL )
	{
		CloseHandle ( file );
		return false;
	}
	
	// write file header
	unsigned long bwritten;
	if ( WriteFile ( file, &bmfh, sizeof ( BITMAPFILEHEADER ), &bwritten, NULL ) == false )
	{	
		CloseHandle ( file );
		return false;
	}
	// write infoheader
	if ( WriteFile ( file, &info, sizeof ( BITMAPINFOHEADER ), &bwritten, NULL ) == false )
	{	
		CloseHandle ( file );
		return false;
	}
	// write image data
	if ( WriteFile ( file, Buffer, paddedsize, &bwritten, NULL ) == false )
	{	
		CloseHandle ( file );
		return false;
	}
	
	// and close file
	CloseHandle ( file );
 
	//delete [] Buffer;

	return true;
}//OK 


Its works great but now i want to show the data avoiding the bmp, Driectly to a video window.

what is the easiest way?
Thanks for your help!
Last edited on
Topic archived. No new replies allowed.