02-28-2008 02:15 PM - edited 02-28-2008 02:24 PM
__declspec
(dllexport) float WriteToFrontPanel(unsigned int *ptrRGB)HWND Labview;
BITMAPV4HEADER bih;
ZeroMemory(&bih,
sizeof(BITMAPV4HEADER));bih.bV4Size =
sizeof(BITMAPV4HEADER);bih.bV4Width = 1000;
bih.bV4Height = -1000;
bih.bV4Planes = 1;
bih.bV4BitCount = 32;
bih.bV4V4Compression = BI_RGB;
int temp = 0;Labview = FindWindow(NULL,
"Window.vi");HDC bit_dc = CreateCompatibleDC(NULL);
HBITMAP hBit = CreateDIBitmap(GetDC(Labview), (LPBITMAPINFOHEADER)&bih, CBM_INIT, ptrRGB, (LPBITMAPINFO)&bih, DIB_RGB_COLORS);SelectObject(bit_dc, hBit);
BitBlt(GetDC(Labview), 0, 0, 1000, 1000, bit_dc, 0, 0, SRCCOPY); temp = ReleaseDC(Labview, GetDC(Labview));DeleteDC(bit_dc);
DeleteObject(hBit);
return temp;
}
The function commands and descriptions are at www.msdn.com if anyone is interested in following the discussion.
Thanks for your time,
Austin
02-28-2008 05:17 PM
02-29-2008 05:10 AM
02-29-2008 08:49 AM - edited 02-29-2008 08:50 AM
04-03-2008 07:39 AM
04-09-2008 10:40 AM
04-10-2008 12:37 PM
04-10-2008 01:27 PM
__declspec(dllexport) float WriteToFrontPanel(unsigned int *ptrRGB)
BITMAPV4HEADER bih;
ZeroMemory(&bih, sizeof(BITMAPV4HEADER));
bih.bV4Size = sizeof(BITMAPV4HEADER);
bih.bV4Width = 1000;
bih.bV4Height = -1000;
bih.bV4Planes = 1;
bih.bV4BitCount = 32;
bih.bV4V4Compression = BI_RGB;
int temp = 0;
Labview = FindWindow(NULL, "Window.vi"); //change this to the name of the window you want to draw to
HDC bit_dc = CreateCompatibleDC(NULL);
HDC hTempDC = GetDC(Labview);
HBITMAP hBit = CreateDIBitmap(hTempDC, (LPBITMAPINFOHEADER)&bih, CBM_INIT, ptrRGB, (LPBITMAPINFO)&bih, DIB_RGB_COLORS);
SelectObject(bit_dc, hBit);
BitBlt(hTempDC, 0, 0, 1000, 1000, bit_dc, 0, 0, SRCCOPY);
temp = ReleaseDC(Labview, hTempDC);
DeleteDC(bit_dc);
DeleteDC(hTempDC);
DeleteObject(hBit);
return temp;
}
Before, everywhere there was a hTempDC I was creating unneeded ones that weren't being closed, which caused my overflow problem. By created a DC and equating it to the one I need, I can simply destroy the created one in the end and not have to worry about overflowing. And yes, I am drawing to a Labview window, and yes I don't have control over the windows re-paint commands. I just have to be creative to creative when using this BitBlt method to find ways around the repainting calls. Even with this hassle, I feel the BitBlt method in a Labview window is orders of magnitude better than those cursed intensity graphs that sink a VI's performance and hog CPU time.
Austin
04-15-2008 04:40 AM
04-15-2008 04:40 AM