pcfutil.c

Go to the documentation of this file.
00001 /*
00002 
00003 Copyright 1990, 1994, 1998  The Open Group
00004 
00005 Permission to use, copy, modify, distribute, and sell this software and its
00006 documentation for any purpose is hereby granted without fee, provided that
00007 the above copyright notice appear in all copies and that both that
00008 copyright notice and this permission notice appear in supporting
00009 documentation.
00010 
00011 The above copyright notice and this permission notice shall be included in
00012 all copies or substantial portions of the Software.
00013 
00014 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00015 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00016 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
00017 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
00018 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
00019 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00020 
00021 Except as contained in this notice, the name of The Open Group shall not be
00022 used in advertising or otherwise to promote the sale, use or other dealings
00023 in this Software without prior written authorization from The Open Group.
00024 
00025 */
00026 /* $XFree86: xc/lib/font/util/utilbitmap.c,v 1.3 1999/08/22 08:58:58 dawes Exp $ */
00027 
00028 /*
00029  * Author:  Keith Packard, MIT X Consortium
00030  */
00031 
00032 /* Modified for use with FreeType */
00033 
00034 
00035 #include <ft2build.h>
00036 #include "pcfutil.h"
00037 
00038 
00039   /*
00040    *  Invert bit order within each BYTE of an array.
00041    */
00042 
00043   FT_LOCAL_DEF( void )
00044   BitOrderInvert( unsigned char*  buf,
00045                   size_t          nbytes )
00046   {
00047     for ( ; nbytes > 0; nbytes--, buf++ )
00048     {
00049       unsigned int  val = *buf;
00050 
00051 
00052       val = ( ( val >> 1 ) & 0x55 ) | ( ( val << 1 ) & 0xAA );
00053       val = ( ( val >> 2 ) & 0x33 ) | ( ( val << 2 ) & 0xCC );
00054       val = ( ( val >> 4 ) & 0x0F ) | ( ( val << 4 ) & 0xF0 );
00055 
00056       *buf = (unsigned char)val;
00057     }
00058   }
00059 
00060 
00061   /*
00062    *  Invert byte order within each 16-bits of an array.
00063    */
00064 
00065   FT_LOCAL_DEF( void )
00066   TwoByteSwap( unsigned char*  buf,
00067                size_t          nbytes )
00068   {
00069     unsigned char  c;
00070 
00071 
00072     for ( ; nbytes >= 2; nbytes -= 2, buf += 2 )
00073     {
00074       c      = buf[0];
00075       buf[0] = buf[1];
00076       buf[1] = c;
00077     }
00078   }
00079 
00080   /*
00081    *  Invert byte order within each 32-bits of an array.
00082    */
00083 
00084   FT_LOCAL_DEF( void )
00085   FourByteSwap( unsigned char*  buf,
00086                 size_t          nbytes )
00087   {
00088     unsigned char  c;
00089 
00090 
00091     for ( ; nbytes >= 4; nbytes -= 4, buf += 4 )
00092     {
00093       c      = buf[0];
00094       buf[0] = buf[3];
00095       buf[3] = c;
00096 
00097       c      = buf[1];
00098       buf[1] = buf[2];
00099       buf[2] = c;
00100     }
00101   }
00102 
00103 
00104 /* END */

Generated on Tue Jul 5 14:13:48 2011 for ROOT_528-00b_version by  doxygen 1.5.1