File: gmapbit.c

package info (click to toggle)
emoslib 000380%2Bdfsg-3
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 47,712 kB
  • ctags: 11,551
  • sloc: fortran: 89,643; ansic: 24,200; makefile: 370; sh: 355
file content (41 lines) | stat: -rwxr-xr-x 894 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/**
* Copyright 1981-2007 ECMWF
* 
* Licensed under the GNU Lesser General Public License which
* incorporates the terms and conditions of version 3 of the GNU
* General Public License.
* See LICENSE and gpl-3.0.txt for details.
*/

#include "bitmap.h"

fortint GMAPBIT(
  char ** bitmap,
  fortint * columnCount,
  fortint * row,
  fortint * column) {
/*
// Returns the bit at position (row,column) of bitmap.
//
// Called from FORTRAN:
//
// VALUE = GMAPBIT(BITMAP,COLCNT,N,M)
//
// where:
//
// BITMAP is an array containing the bitmap.
// COLCNT is the number of values per row.
// N is the row number (starting from 1)
// M is the column number (starting from 1)
//
*/
int bitNumber, byte, bit;
char value;

  bitNumber = ((*row)-1)*(*columnCount) + ((*column)-1);
  byte = bitNumber / 8;
  bit  = bitNumber % 8;
  value = ((*bitmap)[byte] >> (7-bit)) & 0x01;

  return (fortint) value;
}