source: trunk/poppler/freetype-2.1.10/src/pcf/pcfutil.c @ 2

Last change on this file since 2 was 2, checked in by Eugene Romanenko, 15 years ago

First import

File size: 2.3 KB
RevLine 
[2]1/*
2
3Copyright 1990, 1994, 1998  The Open Group
4
5All Rights Reserved.
6
7The above copyright notice and this permission notice shall be included in
8all copies or substantial portions of the Software.
9
10THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
11IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
12FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
13OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
14AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
15CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16
17Except as contained in this notice, the name of The Open Group shall not be
18used in advertising or otherwise to promote the sale, use or other dealings
19in this Software without prior written authorization from The Open Group.
20
21*/
22/* $XFree86: xc/lib/font/util/utilbitmap.c,v 1.3 1999/08/22 08:58:58 dawes Exp $ */
23
24/*
25 * Author:  Keith Packard, MIT X Consortium
26 */
27
28/* Modified for use with FreeType */
29
30
31#include <ft2build.h>
32#include "pcfutil.h"
33
34
35  /*
36   *  Invert bit order within each BYTE of an array.
37   */
38
39  FT_LOCAL_DEF( void )
40  BitOrderInvert( unsigned char*  buf,
41                  int             nbytes )
42  {
43    for ( ; --nbytes >= 0; buf++ )
44    {
45      unsigned int  val = *buf;
46     
47
48      val = ( ( val >> 1 ) & 0x55 ) | ( ( val << 1 ) & 0xAA );
49      val = ( ( val >> 2 ) & 0x33 ) | ( ( val << 2 ) & 0xCC );
50      val = ( ( val >> 4 ) & 0x0F ) | ( ( val << 4 ) & 0xF0 );
51     
52      *buf = (unsigned char)val;
53    }
54  }
55
56
57  /*
58   *  Invert byte order within each 16-bits of an array.
59   */
60
61  FT_LOCAL_DEF( void )
62  TwoByteSwap( unsigned char*  buf,
63               int             nbytes )
64  {
65    unsigned char  c;
66
67
68    for ( ; nbytes >= 2; nbytes -= 2, buf += 2 )
69    {
70      c      = buf[0];
71      buf[0] = buf[1];
72      buf[1] = c;
73    }
74  }
75
76  /*
77   *  Invert byte order within each 32-bits of an array.
78   */
79
80  FT_LOCAL_DEF( void )
81  FourByteSwap( unsigned char*  buf,
82                int             nbytes )
83  {
84    unsigned char  c;
85
86
87    for ( ; nbytes >= 4; nbytes -= 4, buf += 4 )
88    {
89      c      = buf[0];
90      buf[0] = buf[3];
91      buf[3] = c;
92
93      c      = buf[1];
94      buf[1] = buf[2];
95      buf[2] = c;
96    }
97  }
98
99
100/* END */
Note: See TracBrowser for help on using the repository browser.