use remove_bullets to deal with muzzleflash
[rofl0r-openDOW.git] / utils / imgcombine.c
blob5a5541a7a88d0b22065f981af4f88c704820d78f
1 #include <leptonica/allheaders.h>
2 //RcB: LINK "-llept"
3 #include <stdio.h>
4 #include <assert.h>
6 int main(int argc, char**argv) {
8 if(argc != 4) {
9 dprintf(2, "imgcombine filea fileb out\n");
10 return 1;
12 const char *a = argv[1];
13 const char *b = argv[2];
14 const char *out = argv[3];
15 struct Pix* pa = pixRead(a);
16 struct Pix* pb = pixRead(b);
17 assert(pa->w == pb->w && pa->h == pb->h);
18 struct Pix* pa32 = pixConvertTo32(pa);
19 struct Pix* pb32 = pixConvertTo32(pb);
20 struct Pix* pout = pixCreate(pa32->w, pb32->h, 32);
21 int x, y;
22 for(y = 0; y < pa->h; y++)
23 for(x = 0; x < pa->w; x++)
24 if(((uint32_t*)pa->data)[y * pa->w + x] == 0)
25 ((uint32_t*)pout->data)[y * pa->w + x] = ((uint32_t*)pb->data)[y * pa->w + x];
26 else
27 ((uint32_t*)pout->data)[y * pa->w + x] = ((uint32_t*)pa->data)[y * pa->w + x];
28 pixWritePng(out, pout, 0);
29 return 0;