CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
不看会后悔的Windows XP之经验谈 简单快捷DIY实用家庭影院
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  VB >  基础类

picturebox中图片放大缩小问题

楼主scorpions215(asdf)2003-12-03 16:44:34 在 VB / 基础类 提问

在picture1中,用鼠标mousedown时有(x1,y1),mouseup时(x2,y2),怎么把鼠标圈住的里面的内容放大到整个picturebox中去?  
  问题点数:50、回复次数:10Top

1 楼TechnoFantasy((VB MVP)www.applevb.com)回复于 2003-12-03 16:54:04 得分 25

Private   Declare   Function   StretchBlt   Lib   "gdi32"   _  
                  (ByVal   hdc   As   Long,   ByVal   X   As   Long,   ByVal   Y   As   Long,   _  
                  ByVal   nWidth   As   Long,   ByVal   nHeight   As   Long,   ByVal   hSrcDC   As   Long,   _  
                  ByVal   xSrc   As   Long,   ByVal   ySrc   As   Long,   _  
                  ByVal   nSrcWidth   As   Long,   ByVal   nSrcHeight   As   Long,   ByVal   dwRop   As   Long)   As   Long  
  Private   Const   SRCCOPY   =   &HCC0020   '   (DWORD)   dest   =   source  
   
   
  Dim   x1   As   Long  
  Dim   y1   As   Long  
  Dim   x2   As   Long  
  Dim   y2   As   Long  
   
  Private   Sub   Form_Load()  
          Picture1.ScaleMode   =   3  
  End   Sub  
   
  Private   Sub   Picture1_MouseDown(Button   As   Integer,   Shift   As   Integer,   X   As   Single,   Y   As   Single)  
          x1   =   CLng(X)  
          y1   =   CLng(Y)  
  End   Sub  
   
  Private   Sub   Picture1_MouseUp(Button   As   Integer,   Shift   As   Integer,   X   As   Single,   Y   As   Single)  
          x2   =   CLng(X)  
          y2   =   CLng(Y)  
           
          StretchBlt   Picture1.hdc,   0,   0,   Picture1.Width   /   15,   Picture1.Height   /   15,   Picture1.hdc,   x1,   y1,   x2   -   x1,   y2   -   y1,   SRCCOPY  
  End   Sub  
  Top

2 楼scorpions215(asdf)回复于 2003-12-04 08:35:10 得分 0

一定要scalemodel=3么?我scalemodel=0行不行的  
  我是用scalemodel画出来的图,想把它放大的Top

3 楼szyhy810518()()回复于 2003-12-04 08:58:27 得分 0

StretchBlt   Picture1.hdc,   0,   0,   Picture1.Width   /   15,   Picture1.Height   /   15,   Picture1.hdc,   x1,   y1,   x2   -   x1,   y2   -   y1,   SRCCOPY  
   
  我要是得到这个函数的返回值好像就不会正确执行?Top

4 楼szyhy810518()()回复于 2003-12-04 08:59:34 得分 0

是跟踪调试的时候不会正确执行Top

5 楼scorpions215(asdf)回复于 2003-12-04 09:03:39 得分 0

for   i=1   to   10    
  picture1.line(m(i,1),m(i,2))-m(i-1,1)m(i-1,2)  
  next  
  的时候        
  要这线在(x1,y1),(x2,y2)  
  范围内画出来,超出范围的不画,怎么做?Top

6 楼szyhy810518()()回复于 2003-12-04 09:18:42 得分 25

 
  Private   Sub   Picture1_MouseDown(Button   As   Integer,   Shift   As   Integer,   X   As   Single,   Y   As   Single)  
          x1   =   CLng(X)  
          y1   =   CLng(Y)  
          blnMove   =   True  
  End   Sub  
   
  Private   Sub   Picture1_MouseMove(Button   As   Integer,   Shift   As   Integer,   X   As   Single,   Y   As   Single)  
          '应该是在(x1,y1),(x,y)范围内吧!  
   
          If   blnMove   Then  
                  With   Line1(0)  
                          .x1   =   x1  
                          .y1   =   y1  
                          .x2   =   x1  
                          .y2   =   Y  
                  End   With  
                  With   Line1(1)  
                          .x1   =   x1  
                          .y1   =   y1  
                          .x2   =   X  
                          .y2   =   y1  
                  End   With  
                  With   Line1(2)  
                          .x1   =   X  
                          .y1   =   y1  
                          .x2   =   X  
                          .y2   =   Y  
                  End   With  
                  With   Line1(3)  
                          .x1   =   x1  
                          .y1   =   Y  
                          .x2   =   X  
                          .y2   =   Y  
                  End   With  
          End   If  
           
          Label1.Caption   =   X   &   Space(10)   &   Y  
                   
  End   Sub  
   
  Private   Sub   Picture1_MouseUp(Button   As   Integer,   Shift   As   Integer,   X   As   Single,   Y   As   Single)  
           
          Dim   iIndex   As   Integer  
          Dim   lngResult   As   Long  
           
          x2   =   CLng(X)  
          y2   =   CLng(Y)  
           
          'StretchBlt   Picture1.hdc,   0,   0,   Picture1.Width   /   15,   Picture1.Height   /   15,   Picture1.hdc,   x1,   y1,   x2   -   x1,   y2   -   y1,   SRCCOPY  
           
          lngResult   =   StretchBlt(Picture1.hdc,   0,   0,   Picture1.Width   /   15,   Picture1.Height   /   15,   Picture1.hdc,   x1,   y1,   x2   -   x1,   y2   -   y1,   SRCCOPY)  
           
          If   lngResult   =   0   Then  
                  MsgBox   "FDf"  
          End   If  
           
          For   iIndex   =   0   To   3  
                  With   Line1(iIndex)  
                          .x1   =   0  
                          .y1   =   0  
                          .x2   =   0  
                          .y2   =   0  
                  End   With  
          Next  
           
          blnMove   =   False  
          Picture1.Refresh  
           
  End   Sub  
   
  Top

7 楼szyhy810518()()回复于 2003-12-04 09:28:20 得分 0

如何获得图片已经扩大到不能再扩大,即使整个picture1都显示一种颜色?Top

8 楼scorpions215(asdf)回复于 2003-12-04 09:39:46 得分 0

比如我picture1.scale(0,0)-(1000,1000)的时候  
  for   i=1   to   10    
  picture1.line(m(i,1),m(i,2))-m(i-1,1)m(i-1,2)  
  next  
  的时候        
  要这线在(100,100),(800,800)  
  范围内画出来,可能有线(700,700)-(900,900)  
  我要在范围内的显示,超出的不显示     用你刚才的方法可以么?  
  Top

9 楼scorpions215(asdf)回复于 2003-12-04 09:41:15 得分 0

我刚才说的图片不要放大了,就在范围内画线Top

10 楼scorpions215(asdf)回复于 2003-12-04 09:45:45 得分 0

是不是用pset的方法可以?还有没有别的方法Top

相关问题

  • 图片放大缩小问题?
  • 高分-图片放大缩小
  • 如何将一个图片加入到picturebox中后实现对其放大、缩小和移图的功能?
  • 怎么缩放图片?把图片放大,或缩小?散分!!!!!!!
  • 如何在图象框里放大,缩小图片。
  • 怎样让图片放大、缩小后还能够清晰?
  • 用程序怎么控制图片放大缩小的?
  • 怎样实现图片的缩小与放大
  • 请问如何放大缩小一张jpeg的图片?
  • 如何实现图片的局部放大和缩小

关键词

  • picture
  • clng
  • longdim
  • scalemodel
  • stretchblt
  • hdc
  • subprivate
  • single
  • 放大
  • byval

得分解答快速导航

  • 帖主:scorpions215
  • TechnoFantasy
  • szyhy810518

相关链接

  • Visual Basic类图书
  • Visual Basic类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
世纪乐知(北京)网络技术有限公司 版权所有, 京 ICP 证 020026 号
北京创新乐知广告有限公司 提供技术支持
Copyright © 2000-2007, CSDN.NET, All Rights Reserved
GongshangLogo