+ if(maskbitmap) {
+ if(maskWidth < width && maskHeight < height) {
+ for(y = 0; y < height; y++) {
+ for (x = 0; x < width; x++) {
+ pic[width*y+x].a = maskbitmap[(y*maskHeight/height)*maskWidth+(x*maskWidth/width)];
+ }
+ }
+ } else {
+ msg("<verbose> resampling %dx%d to mask size (%dx%d)", width, height, maskWidth, maskHeight);
+ gfxcolor_t*newpic=new gfxcolor_t[maskWidth*maskHeight];
+ double dx = width / maskWidth;
+ double dy = height / maskHeight;
+ double yy = 0;
+ for(y = 0; y < maskHeight; y++) {
+ double xx = 0;
+ for (x = 0; x < maskWidth; x++) {
+ newpic[maskWidth*y+x] = pic[int(yy)*width+int(xx)];
+ newpic[maskWidth*y+x].a = maskbitmap[maskWidth*y+x];
+ xx += dx;
+ }
+ yy += dy;
+ }
+ delete[] pic;
+ pic = newpic;
+ width = maskWidth;
+ height = maskHeight;
+ }
+ }