This should work, and it doesn't even need input bmp or jpg files. Don't know if it works with GCC, I made it a long time ago.
Code:
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#define mlx 3
int scx, scy, mly, ofs;
unsigned char *scr;
unsigned char sct[160*120*3];
#define bmfh ((BITMAPFILEHEADER *)scr)
#define bmih ((BITMAPINFOHEADER *)&scr[sizeof(BITMAPFILEHEADER)])
#define pts 12
double px[64], py[64], pca[64], pcb[64], pcc[64];
double cca, ccb, ccc;
void dodot(int, int, unsigned char *, unsigned char *, unsigned char *);
int WINAPI WinMain(HANDLE ha, HANDLE hrubbish, LPSTR cl, int sh)
{
int x, y, z, w;
double a, b, c, s, t, u;
FILE *f;
srand((unsigned)time(0));
scx=GetSystemMetrics(SM_CXSCREEN);
scy=GetSystemMetrics(SM_CYSCREEN);
mly=(scx*3+3)&0xFFFFFFFC;
ofs=sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER);
if((scr=(unsigned char *)malloc(mly*scy+ofs))==0) return(0);
memset(scr, 0, mly*scy+ofs);
bmfh->bfType=0x4D42;
bmfh->bfSize=mly*scy+ofs;
bmfh->bfOffBits=ofs;
bmih->biSize=sizeof(BITMAPINFOHEADER);
bmih->biWidth=scx;
bmih->biHeight=scy;
bmih->biPlanes=1;
bmih->biBitCount=24;
bmih->biCompression=BI_RGB;
bmih->biXPelsPerMeter=bmih->biYPelsPerMeter=32768;
cca=rand()%128+64;
ccb=rand()%128+64;
ccc=rand()%128+64;
for(x=0;x<pts;++x) {
px[x]=rand()%(160/*scx*/-1)+.5;
py[x]=rand()%(120/*scy*/-1)+.5;
do {
a=rand()%1025-512;
b=rand()%1025-512;
c=rand()%1025-512;
} while((s=a*a+b*b+c*c)>512*512||s<16*16);
s=sqrt(s)/64.; a/=s; b/=s; c/=s;
pca[x]=a; pcb[x]=b; pcc[x]=c;
}
for(x=0;x<160;++x) for(y=0;y<120;++y)
dodot(x, y, &sct[x*3+y*480], &sct[x*3+y*480+1], &sct[x*3+y*480+2]);
c=158.951231/(scx-1);
s=118.951232/(scy-1);
for(x=0;x<scx;++x) for(y=0;y<scy;++y) {
a=x*c; b=y*s; z=(int)a*3+(int)b*480;
t=modf(a, &a); u=modf(b, &b); a=1-t; b=1-u;
for(w=0;w<3;++w)
scr[x*mlx+y*mly+w+ofs]=
(char)(sct[w+z]*a*b+sct[w+z+3]*t*b+sct[w+z+480]*a*u+sct[w+z+483]*t*u);
}
if((f=fopen("C:\\WallGen.bmp", "wb"))!=0) {
fwrite(scr, mly*scy+ofs, 1, f);
fclose(f);
SystemParametersInfo(20, 0, "C:\\WallGen.bmp", 3);
}
free(scr);
return(0);
}
void dodot(int x, int y, unsigned char *p, unsigned char *q, unsigned char *r)
{
int z;
double a, b, c, s, t;
a=b=c=t=0;
for(z=0;z<pts;++z) {
s=((x-px[z])*(x-px[z]))+((y-py[z])*(y-py[z]));
a+=pca[z]/s; b+=pcb[z]/s; c+=pcc[z]/s; t+=1./s;
} a/=t; b/=t; c/=t;
if((s=a*a+b*b+c*c)<1.)
a=b=c=rand()%129-64;
else {
s=sqrt(s)/64.; if((s<.9&&s>.8)||(s<.7&&s>.6)||(s<.5&&s>.4)||(s<.3&&s>.2)||(s<.1&&s>.0)) s=-s; a/=s; b/=s; c/=s;
}
*p=(char)(cca+a);
*q=(char)(ccb+b);
*r=(char)(ccc+c);
}