求解位图缩放代码

圣诞老人123 2011-01-13 02:25:10
static void copyrow2(unsigned short *src, int src_w, unsigned short *dst, int dst_w) {
int i;
int pos, inc;
unsigned short pixel = 0;

pos = 0x10000;
inc = (src_w << 16) / dst_w;
for (i = dst_w; i > 0; --i) {
while (pos >= 0x10000) {
pixel = *src++;
pos -= 0x10000;
}
*dst++ = pixel;
pos += inc;
}
}

static void scretch2(unsigned short* src, int sw, int sh, int sstr, int srx, int sry, int srw, int srh,
unsigned short* dst, int dw, int dh, int dstr, int drx, int dry, int drw, int drh) {
int pos, inc;
int dst_max_row;
int src_row, dst_row;
unsigned short *srcp, *dstp;

pos = 0x10000;
inc = (srh << 16) / drh;
src_row = sry;
dst_row = dry;

for (dst_max_row = dst_row + drh; dst_row < dst_max_row; ++dst_row ) {
while (pos >= 0x10000) {
srcp = src + src_row * sstr + srx;
++src_row;
pos -= 0x10000;
}
dstp = dst + dst_row * dstr + drx;
copyrow2(srcp, srw, dstp, drw);
pos += inc;
}
}
哪位大神来帮我看看这段位图缩放代码 我实在看不懂 求解 帮我解释一下 拜托了
...全文
133 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
jixingzhong 2011-01-13
  • 打赏
  • 举报
回复
BMP位图文件结构及平滑缩放
http://www.programfan.com/article/showarticle.asp?id=1523

先了解一下基本原理。
dooX8086 2011-01-13
  • 打赏
  • 举报
回复
占位~~.

//pos 可能是当前处理像素的位置, 也可能是顏色 .. - -!!!..
//看到 scretch2 的参数,我只想到~矩阵,矩阵,矩阵~
zhutianjin4355255 2011-01-13
  • 打赏
  • 举报
回复
看不到你所有的代码,按我的理解猜测pos = 0x10000;while (pos >= 0x10000) {pos -= 0x10000;}
是调整图片在屏幕上的位置的
inc是什么 inc 是目标图片的宽或者高除去源图片的宽或高,换句话说就是就是放大倍数
圣诞老人123 2011-01-13
  • 打赏
  • 举报
回复
其中我最想知道的是pos = 0x10000;while (pos >= 0x10000) {pos -= 0x10000;}这个pos的作用是什么以及inc是什么 pos += inc 的含义

69,371

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧