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

Developer

Forums

Forums:

Hi all,

i have written following codes to get pixel RGB value but i m always getting native and RGB value both as 0 for any x and y value in below code ...can any one tell me whats issue in that??
Prompt reply will be gr88..

void ReadPixel(barcode *pMe)
{
uint32 imgSize;
NativeColor nColor;
RGBVAL rgb;

void* imgData = ISHELL_LoadResDataEx(pMe->a.m_pIShell, BARCODE_RES_FILE, IMG, RESTYPE_IMAGE,NULL,&imgSize);
byte* imgRawData= (byte*)imgData + (*(byte*)imgData);
ISHELL_CreateInstance(pMe->a.m_pIShell,AEECLSID_JPEGDECODER,(void**)&pMe->pImgDec);
IIMAGEDECODER_QueryInterface(pMe->pImgDec,AEEIID_FORCEFEED,(void**)&pMe->pIFrcFd);
IFORCEFEED_Reset(pMe->pIFrcFd);
IFORCEFEED_Write(pMe->pIFrcFd, imgRawData, imgSize);
IFORCEFEED_Write(pMe->pIFrcFd, 0, 0);
IIMAGEDECODER_GetBitmap(pMe->pImgDec,&pMe->pBitmap);

IBITMAP_GetPixel(pMe->pBitmap, x, y, &nColor);
rgb = IBITMAP_NativeToRGB(pMe->pBitmap, nColor);

}

You probably should be checking the return values for all of the calls you are making as one or more of them are probably failing. In particular, I think that IFORCEFEED_Write(pMe->pIFrcFd, imgRawData, imgSize) may be a problem because, while it looks like you are accounting for the image data offset in imgRawData, it doesn't look like you are doing that for imgSize. So you are getting a few extra bytes of data at the end of your image and that may be causing IIMAGEDECODER_GetBitmap(pMe->pImgDec,&pMe->pBitmap) to fail or produce an incorrect bitmap.

You probably should be checking the return values for all of the calls you are making as one or more of them are probably failing. In particular, I think that IFORCEFEED_Write(pMe->pIFrcFd, imgRawData, imgSize) may be a problem because, while it looks like you are accounting for the image data offset in imgRawData, it doesn't look like you are doing that for imgSize. So you are getting a few extra bytes of data at the end of your image and that may be causing IIMAGEDECODER_GetBitmap(pMe->pImgDec,&pMe->pBitmap) to fail or produce an incorrect bitmap.

Greg wrote:You probably should be checking the return values for all of the calls you are making as one or more of them are probably failing. In particular, I think that IFORCEFEED_Write(pMe->pIFrcFd, imgRawData, imgSize) may be a problem because, while it looks like you are accounting for the image data offset in imgRawData, it doesn't look like you are doing that for imgSize. So you are getting a few extra bytes of data at the end of your image and that may be causing IIMAGEDECODER_GetBitmap(pMe->pImgDec,&pMe->pBitmap) to fail or produce an incorrect bitmap.
Hi Greg,
Thanks for reply ..one more query I have .as currently i m working on barcode application in that from camera picture i need to read barcode by image processing .
Here my question is as in barcode we have different width for different line so how to get RGB value for each line correctly is that GET_PIXEL() is usefull??
any suggestion for such kind of application?

Greg wrote:You probably should be checking the return values for all of the calls you are making as one or more of them are probably failing. In particular, I think that IFORCEFEED_Write(pMe->pIFrcFd, imgRawData, imgSize) may be a problem because, while it looks like you are accounting for the image data offset in imgRawData, it doesn't look like you are doing that for imgSize. So you are getting a few extra bytes of data at the end of your image and that may be causing IIMAGEDECODER_GetBitmap(pMe->pImgDec,&pMe->pBitmap) to fail or produce an incorrect bitmap.
Hi Greg,
Thanks for reply ..one more query I have .as currently i m working on barcode application in that from camera picture i need to read barcode by image processing .
Here my question is as in barcode we have different width for different line so how to get RGB value for each line correctly is that GET_PIXEL() is usefull??
any suggestion for such kind of application?