Path: utzoo!mnetor!uunet!kddlab!ccut!tansei!b39756 From: b39756@tansei.cc.u-tokyo.JUNET (Martin J. Duerst) Newsgroups: comp.sys.mac.programmer Subject: Re: Polygon question Message-ID: <1859@tansei.cc.u-tokyo.JUNET> Date: 26 Apr 88 02:24:11 GMT References: <24153@brunix.UUCP> <104700016@uiucdcsp> Reply-To: b39756@tansei.cc.u-tokyo.JUNET (Martin J. Duerst) Organization: Computer Center, University of Tokyo, Japan. Lines: 24 Here is another method to count bits. Hope this helps: Build up a table with 256 entries, one for each possible value of a byte, containing the number of '1' bits for the corresponding byte, like the following: 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, etc. (These are the values of the first few entries.) This table has to be built up only once for the whole program. For counting the bits, take each byte of your picture and look up the corresponding value in the table. Adding up all the values for all the bytes of your picture will give you the right result. Smaller or larger tables (e.g. size 2**16) are also possible, but may be use too much space or too much time to build up. 256 is a very convenient size. This should be quite fast if nicely implemented, but I didn't try it myself. Martin J. Duerst UUCP: See header. Dept. of Information Science BITNET: TU$KUNII@JPNSUT00 Faculty of Science (The '$' in the userid makes University of Tokyo this unaccessible from many 7-3-1 Hongo, Bunkyo-ku sites.) 113 Tokyo, Japan