+ int x1 = x*maskWidth/width;
+ int y1 = y*maskHeight/height;
+ int x2 = (x+1)*maskWidth/width;
+ int y2 = (y+1)*maskHeight/height;
+ int xx,yy;
+ unsigned int alpha=0;
+ unsigned int count=0;
+ for(xx=x1;xx<x2;xx++)
+ for(yy=y1;yy<y2;yy++) {
+ alpha += maskbitmap[yy*maskWidth+xx];
+ count ++;
+ }
+ if(count) {
+ pic[width*y+x].a = alpha / count;
+ } else {
+ pic[width*y+x].a = maskbitmap[y1*maskWidth+x1];
+ }