Forums | developer.brewmp.com Forums | developer.brewmp.com

Developer

Forums

Forums:

Hi ,

I have to compute the RGB values separately for a bottom up DIB.
According to the doc,pDib->pBmp points to the beginning of the last row in memory.

Does that mean i need to read backwards?
i read 1 byte of the last row i.e R value,another byte i.e G value and then another byte i.e B value.
Then i read back 6 bytes that points to the second last row?

Please guide me if it is the right thing to do?

unsigned char* buf = dib->pBmp;
And at what time do i stop reading?

while( buf !=buf + (dib->nDepth*dib->nPitch)/8) ) is this correct?
since pitch is negative, does this condition hold true?

I have tried , but i seem to be doing something wrong somewhere.
Please help.

Thanks again.

If a 3x3 BMP looks like below (each alphabet representing a pixel ) & is written/stored bottom up in pDib->pBmp.
A B C
D E F
G H X
the COLOR-VALUE/PIXEL-VALUE(not necessarily a byte or 3 bytes) are stored/read in order G, H, X, D and so on.
- the no of bits used to store a PIXEL/COLOR value depend on dib->nDepth (in bits).
total length of the image (in bytes): is (dib->nPitch*dib->cy) as dib->nPitch is offset between each row & cy is the no. of rows.
COLORVALUE = pdib->pBmp[ y * |pdib->nPitch| + x*(dib->nDepth/8) ]; - in the above case
if you PUT y = 0 , x = 0 , you would get G
if you PUT y = 0 , x = 1 , you would get H and so on
if you PUT y = 1 , x = 0 , you would get D and so on
(Note if dib->nDepth is more than 8, then you need to read (dib->nDepth/8) bytes as the COLORVALUE from pdib->pBmp)
To get individual color values R-G-B, you need to decode COLORVALUE.
On a broad terms:-
- If pdib->cntRGB is non-zero, COLORVALUE is NativeColor, you get the RGB color value using IBitmap_NativeToRGB(). A 32 BIT RGB COlor would be returned. you may decode it.
- If pdib->cntRGB is zero, check nColorScheme; values may be:-
IDIB_COLORSCHEME_888 : 8 red, 8 green, 8 blue , or any other ColorScheme.
If so COLORVALUE is R-G-B. now you may decode it as per COLORSCHEME.
Read through DIB - Pixel values section in api ref. for more on decoding color values.
thanks.

If a 3x3 BMP looks like below (each alphabet representing a pixel ) & is written/stored bottom up in pDib->pBmp.
A B C
D E F
G H X
the COLOR-VALUE/PIXEL-VALUE(not necessarily a byte or 3 bytes) are stored/read in order G, H, X, D and so on.
- the no of bits used to store a PIXEL/COLOR value depend on dib->nDepth (in bits).
total length of the image (in bytes): is (dib->nPitch*dib->cy) as dib->nPitch is offset between each row & cy is the no. of rows.
COLORVALUE = pdib->pBmp[ y * |pdib->nPitch| + x*(dib->nDepth/8) ]; - in the above case
if you PUT y = 0 , x = 0 , you would get G
if you PUT y = 0 , x = 1 , you would get H and so on
if you PUT y = 1 , x = 0 , you would get D and so on
(Note if dib->nDepth is more than 8, then you need to read (dib->nDepth/8) bytes as the COLORVALUE from pdib->pBmp)
To get individual color values R-G-B, you need to decode COLORVALUE.
On a broad terms:-
- If pdib->cntRGB is non-zero, COLORVALUE is NativeColor, you get the RGB color value using IBitmap_NativeToRGB(). A 32 BIT RGB COlor would be returned. you may decode it.
- If pdib->cntRGB is zero, check nColorScheme; values may be:-
IDIB_COLORSCHEME_888 : 8 red, 8 green, 8 blue , or any other ColorScheme.
If so COLORVALUE is R-G-B. now you may decode it as per COLORSCHEME.
Read through DIB - Pixel values section in api ref. for more on decoding color values.
thanks.

thanks shivendra for clarifying my doubts.
Here is my piece of code.I have RGB888 format color scheme.
bmp is the source bitmap(obtained from IImageDecoder_getBitmap()) dib is corresponding IDIB.
im creating another IDIB dib2 and modifying its pBmp data.
if (24 == dib->nColorScheme) {//implies its RGB 888 24 bit
uint32* buf32 = (uint32*)(dib->pBmp);
int row = dib->cy-1;
//compute rgb values from dib
while(buf32 != (uint32*)(dib->pBmp +((dib->nPitch)*(dib->cy)) && row>0){
uint32* tempBuf = buf32;
for(int count= 0;countcx-1;count++){
//below i read 8 bits every time .
//calculate rgb
unsigned int r=0,g=0,b=0;
memcpy(&r,tempBuf,sizeof(unsigned char));
tempBuf +=sizeof(unsigned char);
memcpy(&g,tempBuf,sizeof(unsigned char));
tempBuf +=sizeof(unsigned char);
memcpy(&b,tempBuf,sizeof(unsigned char));
NativeColor color = IBitmap_RGBToNative(IDIB_TO_IBITMAP(dib2), MAKE_RGB(r,g,b));
dib2->pBmp[row * dib->nPitch + count* dib->nDepth/8 ] = color;
}
buf32 += |dib->nPitch|;
row -=1;
}
}
IBitmap_BltIn(cmpbitmap,50,50,dib->cx,dib->cy,IDIB_TO_IBITMAP(dib2),0,0,AEE_RO_COPY);
1)Now my question is , what exactly do u mean by decode as per color scheme?
I assume that the bmp is already a decoded one.
2)Will the above line in BOLD work?here , im trying to modify dib2's pBmp data with the rgb values.
color value is calculated but the blit-in image is corrupted.
Is it because , for the source dib and dib2, pallette map is null and cntRgb is 0?
How else can i modify the dib2->pBmp values correctly to the new ones which i need to calculate from R-G-B??
3)final question ,, can i supply R-G-B values separately along with colorScheme etc values to construct a bitmap n draw on screen?
I dont want to point dib->pBmp to dib2->pBmp.(this is the easiest thing to do :-p)
Thanks a lot.
again.

thanks shivendra for clarifying my doubts.
Here is my piece of code.I have RGB888 format color scheme.
bmp is the source bitmap(obtained from IImageDecoder_getBitmap()) dib is corresponding IDIB.
im creating another IDIB dib2 and modifying its pBmp data.
if (24 == dib->nColorScheme) {//implies its RGB 888 24 bit
uint32* buf32 = (uint32*)(dib->pBmp);
int row = dib->cy-1;
//compute rgb values from dib
while(buf32 != (uint32*)(dib->pBmp +((dib->nPitch)*(dib->cy)) && row>0){
uint32* tempBuf = buf32;
for(int count= 0;countcx-1;count++){
//below i read 8 bits every time .
//calculate rgb
unsigned int r=0,g=0,b=0;
memcpy(&r,tempBuf,sizeof(unsigned char));
tempBuf +=sizeof(unsigned char);
memcpy(&g,tempBuf,sizeof(unsigned char));
tempBuf +=sizeof(unsigned char);
memcpy(&b,tempBuf,sizeof(unsigned char));
NativeColor color = IBitmap_RGBToNative(IDIB_TO_IBITMAP(dib2), MAKE_RGB(r,g,b));
dib2->pBmp[row * dib->nPitch + count* dib->nDepth/8 ] = color;
}
buf32 += |dib->nPitch|;
row -=1;
}
}
IBitmap_BltIn(cmpbitmap,50,50,dib->cx,dib->cy,IDIB_TO_IBITMAP(dib2),0,0,AEE_RO_COPY);
1)Now my question is , what exactly do u mean by decode as per color scheme?
I assume that the bmp is already a decoded one.
2)Will the above line in BOLD work?here , im trying to modify dib2's pBmp data with the rgb values.
color value is calculated but the blit-in image is corrupted.
Is it because , for the source dib and dib2, pallette map is null and cntRgb is 0?
How else can i modify the dib2->pBmp values correctly to the new ones which i need to calculate from R-G-B??
3)final question ,, can i supply R-G-B values separately along with colorScheme etc values to construct a bitmap n draw on screen?
I dont want to point dib->pBmp to dib2->pBmp.(this is the easiest thing to do :-p)
Thanks a lot.
again.