其中定义了一个commond为fileopen和一个picture,commondialog但是现在的问题是,在picture中打不开图形。不知道是为什么?请教各位大哥请帮帮小弟!请告诉我其中的原因!
Option Explicit
Dim x, y
Dim picturepixel(2, 30, 1500)
Dim r, g, b
Dim cPrivate Sub fileopen_Click()
Dim i, j
Dim pixel&
Dim picturename
CommonDialog1.Action = 1picturename = CommonDialog1.FileName
If picturename = "" Then
Exit SubPicture1.Picture = LoadPicture(picturename)
Form1.Refresh
x = Picture1.ScaleWidth
y = Picture1.ScaleHeight
c = 10 - Picture.ScaleWidth / 2
If y > 1500 Then y = 1500If x > 5500 Or y > 5500 Then
msgbox"图片太大,请减小尺寸!"
x = 0
y = 0
Exit Sub
End If
End If
For i = ((Picture1.ScaleWidth / 2) - 10) To (Picture1.ScaleWidth / 2) + 10
 For j = 0 To y
 pixel& = Picture1.Point(i, j)
 r = pixel& Mod 256
 g = ((pixel& And &HFF00) / 256&) Mod 256&
 b = (pixel& And &HFF0000) / 65536
 
 picturepixel(0, i + 10 - Picture1.ScaleWidth / 2, j) = r
 picturepixel(1, i + 10 - Picture1.ScaleWidth / 2, j) = g
 picturepixel(2, i + 10 - Picture1.ScaleWidth / 2, j) = b
 
 Next
Next

解决方案 »

  1.   

    你是自动放缩图片的功能吗?
    如果是这样,我有建议你使用API函数放缩图片
    StretchBlt
    一个例子,放大图片同理
    Private Function smallPic()  '将图片缩小至缩略图
    Dim PicErr As Long
    If Picture1.Width <= Picture2.Width And Picture1.Height <= Picture2.Height Then
       '显示原有大小
       PicErr = BitBlt(Picture1.hdc, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, Picture2.hdc, 0, 0, SRCCOPY)
    Else
       '将图片缩小
       Dim C_Width, C_Height As Integer
       If Picture1.Width > Picture1.Height Then   '缩小宽度
          '计算比例
          C_Width = Picture2.ScaleWidth
          C_Height = C_Width * (Picture1.ScaleHeight / Picture1.ScaleWidth)
       Else
          '计算比例
          C_Height = Picture2.ScaleHeight
          C_Width = C_Height * (Picture1.ScaleWidth / Picture1.ScaleHeight)
       End If
       PicErr = StretchBlt(Picture1.hdc, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, Picture2.hdc, 0, 0, C_Width, C_Height, SRCCOPY)
    End If
    End Function
      

  2.   

    http://www.yesky.com/20010130/155732_1.shtml
      

  3.   

    x = 0
    y = 0
    改为:
    x = Picture1.ScaleWidth
    y = Picture1.ScaleHeight
    图片尺寸都没了,还怎么看。