Subject: Re: coding issues
To: Brian Hechinger <wonko@4amlunch.net>
From: Michael <macallan18@earthlink.net>
List: port-macppc
Date: 01/24/2005 07:51:09
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello,

> ok, i'm trying to build some software, and i get this error:
>
> image.c:197: error: invalid operands to binary >>
> image.c:197: error: invalid operands to binary >>
> image.c:197: error: invalid operands to binary >>
> image.c:198: error: invalid operands to binary &
>
> here is the offending code:
>
> g = ( ((p >> 24) & 0xff)  + ((p >> 16) & 0xff) + ((p >> 8) & 0xff)) / 
> 3;
This seems to calculate the brightness of a pixel (average of the 
colour components)...

> p = (g << 24) | (g << 16) | (g << 8) | (p & 0xff);
... and this makes a grey one from the brightness value calculated 
above.

How are p and g declared? Should be uint32_t to be portable.

have fun
Michael
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (Darwin)

iQEVAwUBQfTvPcpnzkX8Yg2nAQIs8gf/csxof2MgvV+hOieDYCnC3I0UaitDOehq
gv1934O6ObHnuJiuePqaOY3dtIzfpIuZzZfso4olTxaOFcMD4rbbS98CWubHU97H
NmNB9+4ERBUNuxwqkABXr5fyW6T4vXRWgbtfctsAV6m1EsP/653/li1vBeFT/+1D
4BKzpXbV8Qn7mKFsT+LdYLWPp8fK6XXwBd/Jkdgow3q/v1RD4x8dDuQKq3R/dQbE
n5JcMhjH4jVk4Ik+BRBtWrIc0ODoUk/Hh/6BT8WPz7Pb/9hKCrp4IHDjk2KABLFD
CK4O9cF33H73g1l6UB9NIQPXM2dpVYElE8Y2ZTUyTIx4KVoyJD2XcA==
=BbHc
-----END PGP SIGNATURE-----