Surface memcpy |乘法优化

来源:互联网 发布:淘宝店铺优惠券图片 编辑:程序博客网 时间:2024/04/28 18:32
for(int i=0;i<dst_height;i++) {memcpy(pDisplay+i*s*bytesofpix, pSrc, bytesofpix*dst_width);pSrc+=dst_width*bytesofpix;}

(1)while循环 代替 for循环

(2)值固定的变量提取到循环外面避免重复运算

(3)乘法用位移替代

int offset = bytesofpix>>1;int t= dst_width<<offset;int t2 = s<<offset;while(dst_height--){memcpy(pDisplay, pSrc, t);pDisplay += t2;pSrc+=(t);}



原创粉丝点击