1 #include <leptonica/allheaders.h>
2 #pragma RcB2 LINK "-llept"
6 void copy_rect(int x
, int y
, int w
, int h
, void* inbuf
, unsigned in_pitch
, void* outbuf
) {
7 uint32_t*ptr
= (uint32_t*) inbuf
;
8 uint32_t*out
= (uint32_t*) outbuf
;
10 for(iy
= y
; iy
< y
+h
; iy
++) for (ix
= x
; ix
< x
+w
; ix
++) {
11 *out
++ = ptr
[iy
*in_pitch
+ ix
];
15 int main(int argc
, char**argv
) {
17 dprintf(2, "%s in.png out.png\n", argv
[0]);
20 const char *in
= argv
[1];
21 const char *out
= argv
[2];
22 struct Pix
* pin
= pixRead(in
);
23 struct Pix
* pin32
= pixConvertTo32(pin
);
24 struct Pix
* pout
= pixCreate(59, 16*30, 32);
26 int xo
= 0, yo
= 0, i
;
27 uint32_t *od
= (void*) pout
->data
;
28 for(i
= 0; i
< 30; i
++) {
29 int xi
= 3 + (i
% 5) * 64;
30 int yi
= 5 + (i
/ 5) * 23;
31 copy_rect(xi
, yi
, 59, 16, (void*) pin32
->data
, pin32
->w
, od
);
34 pixWritePng(out
, pout
, 0);