📄 subject_59022.htm
字号:
<p>
序号:59022 发表者:Henry Tony 发表日期:2003-11-05 15:08:36
<br>主题:如何将一幅指定大小的图像扩大/缩小为另一尺寸?
<br>内容:如何将一幅指定大小的图像扩大/缩小为另一尺寸?
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:michael 回复日期:2003-11-05 15:30:09
<br>内容: 用差值缩放算法。<BR><BR>BOOL COXDIB::ChangeSizeDIB(int cx, int cy)<BR>{<BR> int width=GetWidth();<BR> int height=GetHeight();<BR> int depth=GetColorDepth();<BR><BR> if((cx==width)&&(cy==height))<BR> return FALSE;<BR><BR> TRACE("width=%d,height=%d\n",width,height);<BR><BR> COXDIB bmp;<BR><BR> int tempcy,tempcx,startcx,startcy,endcx,endcy;<BR> double sx,sy,smin; //x和y方向的比例系数<BR> sx=double(cx)/(double)width;<BR> sy=double(cy)/(double)height;<BR><BR> smin=(sx>sy)?sy:sx;<BR> tempcy=(int)(smin*height); //放大后尺寸<BR> tempcx=(int)(smin*width);<BR> <BR> startcx=(cx-tempcx)/2; //起始座标 <BR> startcy=(cy-tempcy)/2;<BR> <BR> endcx=(cx+tempcx)/2; //终止 坐标<BR> endcy=(cy+tempcy)/2;<BR> <BR> bmp.CreateEmptyDIB(24,tempcx,tempcy);<BR> BYTE *ptr = (BYTE *)FindDIBBits(); <BR><BR> BYTE *bmpptr = (BYTE *) bmp.FindDIBBits(); <BR> <BR> long BytesPerLine = width*depth;<BR> if(BytesPerLine%4!=0)BytesPerLine=(BytesPerLine/4+1)*4;<BR> long bmpBytesPerLine = tempcx*depth;<BR> if(bmpBytesPerLine%4!=0)bmpBytesPerLine=(bmpBytesPerLine/4+1)*4;<BR><BR> StretchCopyInnerImageSelf(ptr, bmpptr, BytesPerLine ,<BR> bmpBytesPerLine, <BR> CSize(width,height), <BR> CPoint(0,height),<BR> CPoint(0,width), <BR> CPoint(0,tempcy), <BR> CPoint(0,tempcx));<BR><BR> CreateEmptyDIB(24,cx,cy);<BR> ptr = (BYTE *)FindDIBBits();<BR><BR> memset(ptr,255,cx*3*cy);<BR><BR> BytesPerLine = cx*3;<BR> if(BytesPerLine%4!=0)BytesPerLine=(BytesPerLine/4+1)*4;<BR><BR> int i,j;<BR> for(i=0;i<tempcy;i++)<BR> {<BR> for(j=0;j<tempcx;j++)<BR> {<BR> for(int k=0;k<depth;k++)<BR> {<BR> *(ptr+(startcy+i)*BytesPerLine+(j+startcx)*3+k) = *(bmpptr+i*bmpBytesPerLine+j*3+k);<BR>// *(ptr+(startcy+j)*BytesPerLine+startcx*3+1) = *(bmpptr+j*bmpBytesPerLine+i*3+1);<BR>// *(ptr+(startcy+j)*BytesPerLine+startcx*3+2) = *(bmpptr+j*bmpBytesPerLine+i*3+2);<BR> }<BR> }<BR> }<BR> return TRUE;<BR>}<BR>这段代码可以改变COXDIB对象的大小,用指针实现的。
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:Henry Tony 回复日期:2003-11-06 17:48:36
<br>内容:可不可以也连动态图像(视频)的扩大/缩小的方法也告诉小弟,不胜感激。
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:michael 回复日期:2003-11-06 20:18:02
<br>内容: 用DirectShow播放
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -