08-05-2005 12:47 PM
(bminfo->bmiColors[j]).rgbBlue = j;
(bminfo->bmiColors[j]).rgbGreen = j;
(bminfo->bmiColors[j]).rgbRed = j;
(bminfo->bmiColors[j]).rgbReserved = 0;
}
delete bminfo;
There is much more processing here but even when commenting out the entire file except for these lines the same things happen. These lines were copied from an SDK provided by the makers of the camera that we are using LabVIEW to control. With this code, the program works fine and produces a great image. However, a memory error occurs at runtime in the VI with the following information:
Debug Error!
Program: C:\Program Files\National Instruments\LabVIEW 7.0\LanView.exe
DAMAGE: after Normal Block (#47) at 0x05182188
Upon clicking ignore, the program executes and produces an image from the camera. Yet if I try to click run again, the following error message occurs:
LABVIEW: An exception occurred within the external code called by the Call Library Node. This might have corrupted LabVIEW's memory. Save any work to a new location and restart LabVIEW.
VI "RUNCAM.vi" was stopped at Call Library Function Node 0x188 of SubVI "RUNCAM.vi".
Whether I run the VI again or not, about 10 seconds after these error messages LabVIEW crashes to the desktop without a prompt. If I remove the "delete bminfo;" line, the first error message does not occur, but the second one does if I attempt to run the VI again without restarting LabVIEW. This method also crashes LabVIEW to the desktop. It seems that when I change the RGBQUAD information, LabVIEW cannot properly release the bitmapinfo's memory and crashes with a memory overflow. Is there any reason why this code would do this? When I remove the code everything runs fine except the image is quite distorted. Is there any other way to set up the RGBQUAD information? Thanks in advance for any help on this matter.
Andy Briggs
Department of Physics and Astronomy
Johns Hopkins University
08-05-2005 01:10 PM
08-05-2005 02:11 PM
Thank you for your quick replay Chaos. I thought I would provide some information about the DLL. It controls a Camera connected to the computer by use of a DLL (called Pcclib.dll) provided by the manufacturer. However, I must write my own DLL that can be run in LabVIEW and calls functions from Pcclib.dll to control the camera and record images. Before I can store images from the camera I must set up the bitmap information. For image processing a class called CImageData is used so setting up image processing would be done as such:
CImageData* m_imagedata;
m_imagedata = new CImageData();
m_imagedata->Init(imagesize); //secures image data buffer and sets up BITMAPFILEHEADER information
//set up BITMAPINFO structure
bminfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bminfo->bmiHeader.biWidth = im_width;
bminfo->bmiHeader.biHeight = im_height;
bminfo->bmiHeader.biPlanes = 1;
bminfo->bmiHeader.biBitCount = 8;
bminfo->bmiHeader.biCompression = 0;
bminfo->bmiHeader.biSizeImage = 0;
bminfo->bmiHeader.biXPelsPerMeter = 0;
bminfo->bmiHeader.biYPelsPerMeter = 0;
bminfo->bmiHeader.biClrUsed = 256;
bminfo->bmiHeader.biClrImportant = 0;
//now must set up RGBQUAD information, problems here
for(int j=0; j<256;j++)
{
(bminfo->bmiColors[j]).rgbBlue = j;
(bminfo->bmiColors[j]).rgbGreen = j;
(bminfo->bmiColors[j]).rgbRed = j;
(bminfo->bmiColors[j]).rgbReserved = 0;
}
//setup bitmap info
m_imagedata->SetBmpInfo(bminfo);
From here I transfer the frame and save it to disk. However, I must use the type BITMAPINFO* for the SetBmpInfo function. I could do something like this:
RGBQUAD bmRGBquad [256];
for(int i=0;i<256;i++)
{
bmRGBquad[i].rgbBlue = i;
bmRGBquad[i].rgbGreen = i;
bmRGBquad[i].rgbRed = i;
bmRGBquad[i].rgbReserved = 0;
}
But this:
bminfo->bmiColors = bmRGBquad;
will not work since as you pointed out, bmiColors has size 1. This does not make sense as I specifically entered:
bminfo->bmiHeader.biBitCount = 8;
so as can be seen here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/bitmaps_1rw2.asp when it talks about biBitCount it says that bmicolors should contain 256 entries. It doesn't seem possible to dynamically allocate more memory for bmiColors though. Yet I must be able to change this property before passing bminfo into the SetBmpInfo function. I admit I am somewhat new to programming and LabVIEW, yet sadly I am the most experienced in my lab. Again, thank you for your help.
Andy Briggs
Department of Physics and Astronomy
Johns Hopkins University
08-05-2005 02:51 PM
08-05-2005 03:04 PM
08-05-2005 03:13 PM
08-05-2005 03:27 PM - edited 08-05-2005 03:27 PM
Message Edited by Chaos on 08-05-2005 03:29 PM
08-05-2005 04:01 PM
08-05-2005 04:21 PM
Note The bmiColors member should not contain palette indexes if the bitmap is to be stored in a file or transferred to another application.
Unless the application has exclusive use and control of the bitmap, the bitmap color table should contain explicit RGB values.
Saving it is exactly what I need to do so am I right in interpretting this as I need to give specific RGB values?
08-05-2005 04:32 PM