In reference to my previous post, if
UInt8 *grayedImage = (UInt8*) MemPtrNew((320*240)* sizeof(UInt8));
Is declared like above, my program crashes on the assignment statement
in the loop below.
for(UInt32 i=0;i<76800;i++,k++)
{
Red = bmpData[i] >> 11;
Green = (bmpData[i] & (0x07e0))>>5;
Blue = bmpData[i] & (0x001f);
Avg = (Red+Green+Blue)/3;
// It crashes here in the next line because of the insufficient
memory
grayedImage[k] = ((UInt8)Avg);
}
Can anybody tell me what should I do to be able to store the entire
image data i.e. 320*240 bytes?
Please reply,
Thanks,
Keyur.
-----Original Message-----
From: Keyur Patwa [mailto:[EMAIL PROTECTED]
Sent: Tuesday, May 18, 2004 4:12 PM
To: Palm Developer Forum
Subject: Memory allocation issue!
Thanks Tim & Ben,
U guys are great! I got the "for loop problem" solved!
My another problem is, if I am not wrong, I can not allocate more than
64K of memory in my code right!
Now, I am capturing a 320*240 image and in order to convert it to gray
scale and store the result I have to declare something like this,
UInt8 *grayedImage = (UInt8*) MemPtrNew((320*240)* sizeof(UInt8));
Currently I am doing this and it doesn't generate any error or exception
but it doesn't give me proper data so I assume that 64K memory
limitation is playing role here. Please correct me if I am wrong!
Can anyone suggest what should I do to solve this problem?
Thanks,
Keyur.
-----Original Message-----
From: Tim Kostka [mailto:[EMAIL PROTECTED]
Sent: Tuesday, May 18, 2004 2:13 PM
To: Palm Developer Forum
Subject: Re: for loop problem!
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
--
For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/
--
For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/