source: trunk/indexers/mg/src/images/pbmtools.h@ 3745

Last change on this file since 3745 was 3745, checked in by mdewsnip, 21 years ago

Addition of MG package for search and retrieval

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 2.9 KB
Line 
1/**************************************************************************
2 *
3 * pbmtools.h -- Routines for dealing with portable bitmap files (PBM)
4 * Copyright (C) 1994 Stuart Inglis
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20 * $Id: pbmtools.h 3745 2003-02-20 21:20:24Z mdewsnip $
21 *
22 **************************************************************************/
23
24#ifndef __PBMTOOLS_H
25#define __PBMTOOLS_H
26
27#include "sysfuncs.h"
28#include "basictypes.h"
29
30#include "utils.h"
31#include "marklist.h"
32
33#define PBITS 32
34#define PSH 5
35
36
37/* The next two are ordered pixels col0=left, cols31=right */
38
39/*
40 #define pbm_getpixel(bitmap,c,r) \
41 ((bitmap[r][(c)>>PSH] >> ((PBITS-1)-((c)&(PBITS-1))))&1)
42 #define pbm_putpixel(bitmap,c,r,val) \
43 if((val)) \
44 bitmap[r][(c)>>PSH] |= (((unsigned)1<<(PBITS-1)) >> ((c)&(PBITS-1))); \
45 else \
46 bitmap[r][(c)>>PSH] &= ~(((unsigned)1<<(PBITS-1)) >> ((c)&(PBITS-1)))
47 */
48
49
50
51
52/* The next two defines are ordered pixel cols0=right, cols31=left */
53
54#define pbm_getpixel(bitmap,c,r) \
55 ((bitmap[r][(c)>>PSH] >> ((c)&(PBITS-1)))&1)
56#define pbm_putpixel(bitmap,c,r,val) \
57 if((val)) \
58 bitmap[r][(c)>>PSH] |= (1<<((c)&(PBITS-1))); \
59 else \
60 bitmap[r][(c)>>PSH] &= ~(1<<((c)&(PBITS-1)))
61
62
63#define pbm_putpixel_trunc(bitmap,c,r,val,cols,rows) \
64 if(((c)>=0)&&((c)<cols)&&((r)>=0)&&((r)<rows)) \
65 pbm_putpixel(bitmap,c,r,val)
66
67#define pbm_getpixel_trunc(bitmap,c,r,cols,rows) \
68 ((((c)>=0)&&((c)<cols)&&((r)>=0)&&((r)<rows)) ? \
69 pbm_getpixel(bitmap,c,r) : 0)
70
71
72
73
74int pbm_isapbmfile (FILE * fp);
75void pbm_freearray (Pixel *** bitmap, int rows);
76Pixel **pbm_copy (Pixel ** bitmap, int cols, int rows);
77Pixel **pbm_allocarray (int cols, int rows);
78Pixel **pbm_readfile (FILE * fp, int *cols, int *rows);
79Pixel **pbm_readnamedfile (char fn[], int *cols, int *rows);
80void pbm_writefile (FILE * fp, Pixel ** bitmap, int cols, int rows);
81void pbm_writenamedfile (char fn[], Pixel ** bitmap, int cols, int rows);
82
83void pbm_putpixel_range (Pixel ** bitmap, int c, int r, int val, int cols, int rows);
84int pbm_getpixel_range (Pixel ** bitmap, int c, int r, int cols, int rows);
85
86#endif
Note: See TracBrowser for help on using the repository browser.