Old Nick
Advanced Member level 1
Hi,
I've written some code to display the output from a 64x64 camera array we've designed, the problem I'm having is that painting the array to a window takes too long (around a second or so!)
I'm using a function containing
where g_RGB is the voltage output og the individual pixels.
This function is called after every pixel read and the window updated.
the painting is done in
}
this code is in Cls_OnCommand
g_RGB is calculated elsewhere.
I've tried writing all the values to an array/buffer, then repainting the window after a complete frame grab (using a loop). Is there another way to display this 64x64 array to the screen which will be faster, or am I just stuck with this? I was hoping for 10 frames per sec, which I'm nowhere near.
I'm not a C expert, and am using prettymuch straight C to write this.
I've written some code to display the output from a 64x64 camera array we've designed, the problem I'm having is that painting the array to a window takes too long (around a second or so!)
I'm using a function containing
Code:
hPenArray=CreatePen(PS_SOLID,0,RGB(g_RGB,0,0));
hPenOld = SelectObject(hdc, hPenArray);
lb.lbColor=RGB(g_RGB,0,0);
lb.lbStyle = BS_SOLID;
hBrush = CreateBrushIndirect(&lb);
hBrushOld = SelectObject(hdc, hBrush);
for (y=0;y<64;y++)
{
for (x=0;x<64;x++)
Rectangle(hdc, g_X*150, (g_Y+1)*150, (g_X+1)*150, g_Y*150);
.
.
.
where g_RGB is the voltage output og the individual pixels.
This function is called after every pixel read and the window updated.
the painting is done in
Code:
void Cls_OnPaint(HWND hwnd)
{
PAINTSTRUCT ps;
RECT rectCl;
BeginPaint(hwnd, &ps);
SetMapMode(ps.hdc, MM_HIMETRIC);
GetClientRect(hwnd, &rectCl);
SetViewportOrgEx(ps.hdc, 0, rectCl.bottom, NULL);
SetWindowOrgEx(ps.hdc, -500, -500, NULL);
TextOut(ps.hdc, 0, 15000, g_pathName, strlen(g_pathName));
TextOut(ps.hdc, 0, 14000, g_fileName, strlen(g_fileName));
drawArray (hwnd, ps.hdc);
drawGraph (hwnd, ps.hdc);
EndPaint(hwnd, &ps);
this code is in Cls_OnCommand
Code:
for (row=0;row<64;row++)
{
// cbDOut(boardNum,PortNumB,row); //send row address to camera
for (col=0;col<64;col++)
{
// UDStat = cbDOut(boardNum, PortNumA, col); //send column address to camera
captureData(Chan0, &(DataArrayA[row][col]), photoNumber, row, col);
captureData(Chan0, &(DataArrayB[row][col]), photoNumber, row, col);
captureData(Chan0, &(DataArrayC[row][col]), photoNumber, row, col);
captureData(Chan0, &(DataArrayD[row][col]), photoNumber, row, col);
g_X=col;
g_Y=row;
InvalidateRect(hwnd, NULL, FALSE);
UpdateWindow(hwnd);
}
g_RGB is calculated elsewhere.
I've tried writing all the values to an array/buffer, then repainting the window after a complete frame grab (using a loop). Is there another way to display this 64x64 array to the screen which will be faster, or am I just stuck with this? I was hoping for 10 frames per sec, which I'm nowhere near.
I'm not a C expert, and am using prettymuch straight C to write this.