Your variable i is UInt32 but previewWidth and previewHeight aren't.  That
means when it calculates previewWidth*previewHeight it does so as UInt16 and
gets 11264 ( = 76800 % 65536).

So cast the operation as UInt32 instead.

  for(UInt32 i=0;i<(UInt32)previewWidth*previewHeight;i++)

-- 
Tim Kostka
http://www.nuprograms.com



"Keyur Patwa" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
>
>
> Hi guys,
>
> I am getting some stupid result with for loop!
> Can anyone please help me with this?
>
> previewWidth = 320; previewHeight = 240;
>
> for(UInt32 i=0;i<previewWidth*previewHeight;i++)
> {
> Red = bmpData[i] >> 11;
> Green = (bmpData[i] & (0x07e0))>>5;
> Blue = bmpData[i] & (0x001f);
> Avg = (Red+Green+Blue)/3;
>
> grayedImage[i] = ((UInt8)Avg);
> }
>
> The value of "i" outside this loop is 11,264 rather than 76,800.
> It doesn't go beyond 11,264 in the loop for value of "i";
>
> If tried to put an if(i>11264) in the for loop itself, but it never
> entered that statement!
>
> Instead of "i<previewWidth*previewHeight", I tried i<76800 but that
> crashes the application!
>
> I don't know why this is happening!
>
> Please help!
> Thanks,
> Keyur.
>
>
>
>



-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to