LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with GetBitmapData

There is the following code in a function:

// ***************************************************************************
unsigned char *pucBits = NULL;
int hiBitmap;

int iWidth;
int iHeight;
int iRetVal =  0;


//Allocate memory for mask and bitmap
AllocBitmapData (hiBitmap, NULL, &pucBits, NULL);

//Get bitmap Data
iRetVal=GetBitmapData (hiBitmap, NULL, NULL, &iWidth, &iHeight, NULL, pucBits, NULL);

// ***************************************************************************

 

The problem is, the result of function GetBitmapData is different for 2 systems (one development system and one older test system).

 

Development system:
Intel Core 2 6400 2,13GHz
1 GB RAM
Windows XP, SP 3

 

Test system:
Intel Pentium III, 1GHz
256 MB RAM
Windows XP, SP 3


The results from the GetBitmapData function for both systems (bitmap is identic!):

 

result of development system:
iRetVal = 0
iWidth = 32
iHeight = 32
pucBits = FF FF FF 00

memory image of pucBits:

FF FF FF 00 FF FF FF 00 FF FF FF 00 FF FF FF 00 FF FF FF 00 FF FF FF 00 FF FF FF 00 FF FF FF 00 FF FF FF 00 FF
FF FF 00 FF FF FF 00 FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 FF FF FF 00 FF FF FF 00 FF FF FF 00 FF FF FF 00 FF FF FF 00 FF FF FF 00 FF FF FF 00 FF FF FF
00 FF FF FF 00 FF FF FF 00 FF FF FF 00 FF FF FF 00 FF FF FF 00 FF FF FF 00 FF FF FF 00 FF FF FF 00 FF FF FF 00
FF FF FF 00 FF FF FF 00 FF FF FF 00 FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF 00 00 00 FF 00 00
00 FF 00 00 00 FF 00 00 00 FF 00 00 00 FF 00 00 00 FF 00 00 00 FF 00 00 00 00 00 00 00 00 00 00 00 00 00 FF FF
FF 00 FF FF FF 00 FF FF FF 00 FF FF FF 00 FF FF FF 00 FF FF FF 00 FF FF FF 00 FF FF FF 00 FF FF FF 00 FF FF FF
00 FF FF FF 00 FF FF FF 00 FF FF FF 00 FF FF FF 00 FF FF FF 00 FF FF FF 00 FF FF FF 00 00 00 00 00 00 00 FF 00
00 00 FF 00 00 00 FF 00 00 00 FF 00 00 00 FF 00 00 00 FF 00 00 00 FF 00 00 00 FF 00 00 00 FF 00 00 00 FF 00 00


result of test system:
iRetVal = 0
iWidth = 32
iHeight = 32
pucBits = FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 00
memory image of pucBits:
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF 00 00 00 00 00 00 00 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF
00 00 FF 00 00 FF 00 00 00 00 00 00 00 00 00 00 00 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 00 00 00 FF 00 00
FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF

 

 

For following functions, which work with the result from GetBitmapData is it very fatal, if the result depend on the system.

 

What is the possible reason for the different results on the two systems? I think, the hardware from both systems is the main reason for different results. But why?

0 Kudos
Message 1 of 5
(4,175 Views)

You are calling AllocBitmapData() with an uninitialised bitmap handle - you have not set the first parameter to anything. This must correspond to a valid bitmap before you make the call. See the help for the function.

 

JR

0 Kudos
Message 2 of 5
(4,169 Views)

The bitmap handle is before intialised with

 

GetCtrlBitmap (hiPanel, hiCtrl, i, &hiBitmap);

 

 

 

// ***************************************************************************
unsigned char *pucBits = NULL;
int hiBitmap;

int iWidth;
int iHeight;
int iRetVal =  0;

.....

.....

.....

GetCtrlBitmap (hiPanel, hiCtrl, i, &hiBitmap);

...

....

....


//Allocate memory for mask and bitmap
AllocBitmapData (hiBitmap, NULL, &pucBits, NULL);

//Get bitmap Data
iRetVal=GetBitmapData (hiBitmap, NULL, NULL, &iWidth, &iHeight, NULL, pucBits, NULL);

 

....

....

....

// ***************************************************************************

 

 

Message Edited by Zaruma on 10-07-2009 05:23 AM
0 Kudos
Message 3 of 5
(4,165 Views)

OK...

 

Are the graphics card settings of the two systems exactly the same? For example, if the older PC is set to 16 bit colour and the new one to 32 bit colour, this could account for the discrepancy. If you pass the address of a variable for the 3rd parameter (pixel depth) in the call to GetBitmapData(), CVI will tell you this information programmatically.

 

JR

0 Kudos
Message 4 of 5
(4,158 Views)

the help for GetBitmapData() says, for parameter "bits":

If pixelDepth is 8 or less, the bits array contains indices into the colorTable array. If pixelDepth is greater than 8, the colorTable array is not used, and the bits array contains the actual RGB values.

 

the color table may differ from one system to another, because system colors may not be the same. if the color tables are not the same, the bitmap data will differ although they do represent the same graphic. can you make sure the color table is the same on the 2 systems ? the color table can be obtained in the corresponding parameter of the GetBitmapData() function.

0 Kudos
Message 5 of 5
(4,150 Views)