1 /**
2  ** bitblt1b.c ---- bitblt from a 1bpp context
3  **
4  ** Copyright (c) 2001 Josu Onandia
5  ** [e-mail: jonandia@fagorautomation.es].
6  **
7  ** This file is part of the GRX graphics library.
8  **
9  ** The GRX graphics library is free software; you can redistribute it
10  ** and/or modify it under some conditions; see the "copying.grx" file
11  ** for details.
12  **
13  ** This library is distributed in the hope that it will be useful,
14  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
15  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  **
17  **/
18 
19 #include "libgrx.h"
20 #include "clipping.h"
21 
GrBitBlt1bpp(GrContext * dst,int dx,int dy,GrContext * src,int x1,int y1,int x2,int y2,GrColor fg,GrColor bg)22 void GrBitBlt1bpp(GrContext *dst,int dx,int dy,
23                   GrContext *src,int x1,int y1,int x2,int y2,
24                   GrColor fg, GrColor bg)
25 {
26   int oldx1,oldy1;
27   int oldx2,oldy2;
28   int dstx2,dsty2;
29 
30   if(dst == NULL) dst = CURC;
31   if(src == NULL) src = CURC;
32 
33   if(src->gc_driver->num_planes != 1 || src->gc_driver->bits_per_pixel != 1)
34     return;
35 
36   isort(x1,x2); oldx1 = x1;
37   isort(y1,y2); oldy1 = y1;
38   cxclip_ordbox(src,x1,y1,x2,y2);
39   oldx1 = (dx  += (x1 - oldx1));
40   oldy1 = (dy  += (y1 - oldy1));
41   oldx2 = dstx2 = dx + x2 - x1;
42   oldy2 = dsty2 = dy + y2 - y1;
43   clip_ordbox(dst,dx,dy,dstx2,dsty2);
44   x1 += (dx - oldx1);
45   y1 += (dy - oldy1);
46   x2 -= (oldx2 - dstx2);
47   y2 -= (oldy2 - dsty2);
48   mouse_block(src,x1,y1,x2,y2);
49   mouse_addblock(dst,dx,dy,dstx2,dsty2);
50 
51   (dst->gc_driver->drawbitmap)((dx + dst->gc_xoffset),(dy + dst->gc_yoffset),
52     (x2 - x1 + 1),(y2 - y1 + 1),src->gc_baseaddr[0],src->gc_lineoffset,
53     /*alex:the offset should anyway be the x1,y1 point in src, as clipped*/
54     (x1 + (y1 * (src->gc_lineoffset << 3))),fg,bg);
55 
56   mouse_unblock();
57 }
58 
59