~ubuntu-branches/ubuntu/hardy/texmacs/hardy

« back to all changes in this revision

Viewing changes to src/Resource/Bitmap_fonts/bitmap_ops.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Ralf Treinen
  • Date: 2004-04-19 20:34:00 UTC
  • Revision ID: james.westby@ubuntu.com-20040419203400-g4e34ih0315wcn8v
Tags: upstream-1.0.3-R2
ImportĀ upstreamĀ versionĀ 1.0.3-R2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
/******************************************************************************
 
3
* MODULE     : bitmap_ops.cpp
 
4
* DESCRIPTION: operation on character bitmaps
 
5
* COPYRIGHT  : (C) 1999  Joris van der Hoeven
 
6
*******************************************************************************
 
7
* This software falls under the GNU general public license and comes WITHOUT
 
8
* ANY WARRANTY WHATSOEVER. See the file $TEXMACS_PATH/LICENSE for more details.
 
9
* If you don't have this file, write to the Free Software Foundation, Inc.,
 
10
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
11
******************************************************************************/
 
12
 
 
13
#include "bitmap_font.hpp"
 
14
#include "ps_device.hpp"
 
15
 
 
16
bitmap_char
 
17
join (bitmap_char bmc1, bitmap_char bmc2) {
 
18
  int x1= min (-bmc1->xoff, -bmc2->xoff);
 
19
  int y1= min (bmc1->yoff- bmc1->height, bmc2->yoff- bmc2->height);
 
20
  int x2= max (bmc1->width- bmc1->xoff, bmc2->width- bmc2->xoff);
 
21
  int y2= max (bmc1->yoff, bmc2->yoff);
 
22
  bitmap_char bmr (x2-x1, y2-y1, -x1, y2, max (bmc1->depth, bmc2->depth));
 
23
 
 
24
  int i, j, dx, dy;
 
25
  dx= -bmc1->xoff- x1, dy= y2- bmc1->yoff;
 
26
  for (j=0; j<bmc1->height; j++)
 
27
    for (i=0; i<bmc1->width; i++)
 
28
      bmr->set_x (i+dx, j+dy, bmc1->get_x (i, j));
 
29
 
 
30
  dx= -bmc2->xoff- x1; dy= y2- bmc2->yoff;
 
31
  for (j=0; j<bmc2->height; j++)
 
32
    for (i=0; i<bmc2->width; i++)
 
33
      bmr->set_x (i+dx, j+dy,
 
34
                  max (bmr->get_x (i+dx, j+dy), bmc2->get_x (i, j)));
 
35
 
 
36
  return bmr;
 
37
}
 
38
 
 
39
bitmap_char
 
40
move (bitmap_char bmc, SI x, SI y) {
 
41
  x += PIXEL/2; y += PIXEL/2; abs_round (x, y);
 
42
  int xx= x/PIXEL, yy= y/PIXEL;
 
43
  int ww= bmc->width, hh= bmc->height;
 
44
  bitmap_char bmr (ww, hh, bmc->xoff- xx, bmc->yoff+ yy, bmc->depth);
 
45
 
 
46
  int i, j;
 
47
  for (j=0; j<hh; j++)
 
48
    for (i=0; i<ww; i++)
 
49
      bmr->set_x (i, j, bmc->get_x (i, j));
 
50
  bmr->lwidth= bmc->lwidth;
 
51
  return bmr;
 
52
}
 
53
 
 
54
bitmap_char
 
55
hor_flip (bitmap_char bmc) {
 
56
  int i, j;
 
57
  int ww= bmc->width, hh= bmc->height;
 
58
  bitmap_char bmr (ww, hh, bmc->xoff, bmc->yoff, bmc->depth);
 
59
  for (j=0; j<hh; j++)
 
60
    for (i=0; i<ww; i++)
 
61
      bmr->set_x (ww-1-i, j, bmc->get_x (i, j));
 
62
  bmr->lwidth= bmc->lwidth;
 
63
  return bmr;
 
64
}
 
65
 
 
66
bitmap_char
 
67
ver_flip (bitmap_char bmc) {
 
68
  int i, j;
 
69
  int ww= bmc->width, hh= bmc->height;
 
70
  bitmap_char bmr (ww, hh, bmc->xoff, bmc->yoff, bmc->depth);
 
71
  for (j=0; j<hh; j++)
 
72
    for (i=0; i<ww; i++)
 
73
      bmr->set_x (i, hh-1-j, bmc->get_x (i, j));
 
74
  bmr->lwidth= bmc->lwidth;
 
75
  return bmr;
 
76
}
 
77
 
 
78
bitmap_char
 
79
pos_rotate (bitmap_char bmc) {
 
80
  int i, j;
 
81
  int ww= bmc->width, hh= bmc->height;
 
82
  bitmap_char bmr (hh, ww, bmc->yoff, bmc->width- bmc->xoff, bmc->depth);
 
83
  for (j=0; j<hh; j++)
 
84
    for (i=0; i<ww; i++)
 
85
      bmr->set_x (j, ww-1-i, bmc->get_x (i, j));
 
86
  return bmr;
 
87
}
 
88
 
 
89
bitmap_char
 
90
hor_extend (bitmap_char bmc, int pos, int by) {
 
91
  int i, j;
 
92
  int ww= bmc->width, hh= bmc->height;
 
93
  bitmap_char bmr (ww+ by, hh, bmc->xoff, bmc->yoff, bmc->depth);
 
94
  for (j=0; j<hh; j++)
 
95
    for (i=0; i<(ww+by); i++)
 
96
      bmr->set_x (i, j, bmc->get_x (i<pos? i: (i<pos+by? pos: i-by), j));
 
97
  return bmr;
 
98
}
 
99
 
 
100
bitmap_char
 
101
ver_extend (bitmap_char bmc, int pos, int by) {
 
102
  int i, j;
 
103
  int ww= bmc->width, hh= bmc->height;
 
104
  bitmap_char bmr (ww, hh+by, bmc->xoff, bmc->yoff, bmc->depth);
 
105
  for (j=0; j<(hh+by); j++)
 
106
    for (i=0; i<ww; i++)
 
107
      bmr->set_x (i, j, bmc->get_x (i, j<pos? j: (j<pos+by? pos: j-by)));
 
108
  return bmr;
 
109
}