刚好我这几天写了一个
速度挺不错的
你要的话留下E-MailCPU:K6-2 350
操作系统:Windows 98 第二版 2222
速度测试情况(单位:秒):将图片旋转45度:
┏━━━━┳━━━━━┯━━━━━┓
┃ 160*160┃最邻近插值│双线内插值┃
┣━━━━╋━━━━━┿━━━━━┫
┃我的程序┃  0.040 │  0.072 ┃
┠────╂─────┼─────┨
┃内嵌汇编┃  ×  │  0.061 ┃
┠────╂─────┼─────┨
┃书上示例┃  0.060 │  0.125 ┃
┗━━━━┻━━━━━┷━━━━━┛┏━━━━┳━━━━━┯━━━━━┓
┃ 640*480┃最邻近插值│双线内插值┃
┣━━━━╋━━━━━┿━━━━━┫
┃我的程序┃  0.395 │  0.695 ┃
┠────╂─────┼─────┨
┃内嵌汇编┃  ×  │  0.555 ┃
┠────╂─────┼─────┨
┃书上示例┃  0.600 │  1.210 ┃
┗━━━━┻━━━━━┷━━━━━┛
┏━━━━┳━━━┯━━━┯━━━┓
┃特殊角度┃ 180度│ +90度│ -90度┃
┣━━━━╋━━━┿━━━┿━━━┫
┃ 160*160┃ 0.008│ 0.008│ 0.008┃
┠────╂───┼───┼───┨
┃ 640*480┃ 0.073│ 0.080│ 0.080┃
┗━━━━┻━━━┷━━━┷━━━┛
双线内插值:就是“平滑”复选框选中后使用的算法内嵌汇编:Seedling(叶子)我的内嵌汇编缩放图片的
书上示例:《Visual C++ 数字图像与图形处理》上的示例程序

解决方案 »

  1.   

    zyl910(910:分儿,我来了!) 大侠
    帮我看一下,这个程序有什么问题好吗?
      

  2.   

    Private Sub HsbDegree_Change()
        Picture2.Cls
        Label3.Caption = "图象旋转" & Str(HsbDegree.Value) & "度"
        Call PicRotate(Picture1, Picture2, 2 * 3.1416 * HsbDegree.Value / 360)
       Picture2.Refresh '好像没有刷新
    End Sub
      

  3.   

    Picture1.AutoReDraw = True
        Picture1.AutoReDraw = True
      

  4.   

    to zyl910(910:分儿,我来了!):请问一下,你是怎么得出这么精确的运行所用时间的?
    谢谢。。
      

  5.   

    Declare Function timeGetTime Lib "winmm.dll" Alias "timeGetTime" () As Long返回值的单位是毫秒
      

  6.   

    to  thirdapple(第三只苹果) :
    还是不行。
      

  7.   

    post by somebodyFunction CircumvolvingBits(FromPicture As PictureBox, ToPicture As PictureBox, Angle As Long, Zoom As Boolean)
    Const Pi = 3.14159265358979 '定义的Pi值,好象是越多越好,于是就定义了这么多位:)
    Dim x As Long, y As Long
    Dim X1 As Long, Y1 As Long
    Dim X2 As Double, Y2 As Double
    Dim X3 As Long, Y3 As Long '这里原来定义的是Double,但是老出问题,定义为Long就正常了
    Dim bit2Width As Long
    Dim bitWidth As Long
    Dim hOldMap As Long
    Dim Pic2Bits() As Byte
    Dim PicBits() As Byte
    Dim iBitmap As Long, iDC As Long
    Dim i2Bitmap As Long, i2DC As Long
    Dim bi24BitInfo As BITMAPINFO
    Dim bi24Bit2Info As BITMAPINFO
    Dim HuDu As Single
    Dim Pcolor As Long
        '清除图片框ToPicture
        ToPicture.Cls
        '将角度转换为弧度
        FromPicture.ScaleMode = vbPixels
        ToPicture.ScaleMode = vbPixels
        HuDu = Angle * Pi / 180
      If Zoom = True Then '如果要图片框随图片的旋转而伸缩的话
        If Angle < 90 Then '以下的代码都是运用三角函数进行的处理
           HuDu = Angle * Pi / 180
           ToPicture.Width = FromPicture.Width * Cos(HuDu) + FromPicture.Height * Sin(HuDu)
           ToPicture.Height = FromPicture.Height * Cos(HuDu) + FromPicture.Width * Sin(HuDu)
          If Angle = 0 Then
            HuDu = Angle * Pi / 180
            ToPicture.Width = FromPicture.Width
            ToPicture.Height = FromPicture.Height
           End If
        Else
          If Angle = 90 Then
            HuDu = Angle * Pi / 180
            ToPicture.Width = FromPicture.Height
            ToPicture.Height = FromPicture.Width
          End If
          If Angle < 180 And Angle > 90 Then
            Angle = Angle - 90
            HuDu = Angle * Pi / 180
            ToPicture.Width = FromPicture.Height * Cos(HuDu) + FromPicture.Width * Sin(HuDu)
            ToPicture.Height = FromPicture.Width * Cos(HuDu) + FromPicture.Height * Sin(HuDu)
          Else
            If Angle = 180 Then
            HuDu = Angle * Pi / 180
              ToPicture.Width = FromPicture.Width
              ToPicture.Height = FromPicture.Height
            End If
            If Angle < 270 And Angle > 180 Then
              Angle = Angle - 180
              HuDu = Angle * Pi / 180
              ToPicture.Width = FromPicture.Width * Cos(HuDu) + FromPicture.Height * Sin(HuDu)
              ToPicture.Height = FromPicture.Height * Cos(HuDu) + FromPicture.Width * Sin(HuDu)
            Else
            If Angle = 270 Then
              HuDu = Angle * Pi / 180
              ToPicture.Width = FromPicture.Height
              ToPicture.Height = FromPicture.Width
            End If
            If Angle < 360 And Angle > 270 Then
                Angle = Angle - 270
                HuDu = Angle * Pi / 180
                ToPicture.Width = FromPicture.Height * Cos(HuDu) + FromPicture.Width * Sin(HuDu)
                ToPicture.Height = FromPicture.Width * Cos(HuDu) + FromPicture.Height * Sin(HuDu)
              End If
            End If
          End If
        End If
      End If
      

  8.   

    With bi24BitInfo.bmiHeader '定义一个DIB位图结构
        .biBitCount = 32 '定义为32位的DIB位图(很方便,以前我用24位的走了不少弯路),32位DIB位图每个象素有四个字节,分别是R、G、B、Alpha
        .biCompression = BI_RGB
        .biPlanes = 1
        .biSize = Len(bi24BitInfo.bmiHeader)
        .biWidth = FromPicture.ScaleWidth
        .biHeight = FromPicture.ScaleHeight
        .biSizeImage = .biWidth * 4 * .biHeight
    End With
    iDC = CreateCompatibleDC(0) '创建位图hDC
    iBitmap = CreateDIBSection(iDC, bi24BitInfo, DIB_RGB_COLORS, ByVal 0&, ByVal 0&, ByVal 0&) '创建位图
    If iBitmap Then
      hOldMap = SelectObject(iDC, iBitmap) '使i2DC与i2Bitmap建立关联
    Else
      DeleteObject iDC
      Exit Function
    End If
    With bi24Bit2Info.bmiHeader '定义一个DIB位图结构
        .biBitCount = 32 '定义为32位的DIB位图(很方便,以前我用24位的走了不少弯路),32位DIB位图每个象素有四个字节,分别是R、G、B、Alpha
        .biCompression = BI_RGB
        .biPlanes = 1
        .biSize = Len(bi24BitInfo.bmiHeader)
        .biWidth = ToPicture.ScaleWidth
        .biHeight = ToPicture.ScaleHeight
        .biSizeImage = .biWidth * 4 * .biHeight
    End With
    i2DC = CreateCompatibleDC(0) '创建位图hDC
    i2Bitmap = CreateDIBSection(i2DC, bi24Bit2Info, DIB_RGB_COLORS, ByVal 0&, ByVal 0&, ByVal 0&) '创建位图
    If i2Bitmap Then
      hOldMap = SelectObject(i2DC, i2Bitmap) '使i2DC与i2Bitmap建立关联
    Else
      DeleteObject i2DC
      Exit Function
    End If
    BitBlt iDC, 0, 0, bi24BitInfo.bmiHeader.biWidth, bi24BitInfo.bmiHeader.biHeight, FromPicture.hDC, 0, 0, vbSrcCopy '将FromPicture上的图象拷贝到iDC中
    bitWidth = bi24BitInfo.bmiHeader.biWidth * 4 '横向的字节总数
    ReDim PicBits(0 To bitWidth * bi24BitInfo.bmiHeader.biHeight) As Byte '重新定义动态数组
    GetBitmapBits iBitmap, bi24BitInfo.bmiHeader.biSizeImage, PicBits(0) '将iBitmap读取到PicBits数组中
    BitBlt i2DC, 0, 0, bi24Bit2Info.bmiHeader.biWidth, bi24Bit2Info.bmiHeader.biHeight, ToPicture.hDC, 0, 0, vbSrcCopy '将ToPicture上的图象拷贝到i2DC中
    bit2Width = bi24Bit2Info.bmiHeader.biWidth * 4 '横向的字节总数
    ReDim Pic2Bits(0 To bit2Width * bi24Bit2Info.bmiHeader.biHeight) As Byte '重新定义动态数组
    GetBitmapBits i2Bitmap, bi24Bit2Info.bmiHeader.biSizeImage, Pic2Bits(0) '将i2Bitmap读取到Pic2Bits数组中
        '逐点旋转象素,并逐点复制
        For x = 1 To ToPicture.ScaleWidth - 1
            X1 = x - ToPicture.ScaleWidth \ 2
            For y = 1 To ToPicture.ScaleHeight - 1
                Y1 = y - ToPicture.ScaleHeight \ 2
                '旋转象素点
                X2 = X1 * Cos(-HuDu) + Y1 * Sin(-HuDu)
                Y2 = Y1 * Cos(-HuDu) - X1 * Sin(-HuDu)
                X3 = X2 + FromPicture.ScaleWidth \ 2
                Y3 = Y2 + FromPicture.ScaleHeight \ 2
                '如果象素点在待旋转位图内
                If X3 >= 1 And X3 <= FromPicture.ScaleWidth - 1 Then
                  If Y3 >= 1 And Y3 <= FromPicture.ScaleHeight - 1 Then
                    '逐点复制位图
                    If x * 4 + 2 + y * bit2Width <= bit2Width * bi24Bit2Info.bmiHeader.biHeight _
                     And x * 4 + y * bit2Width >= 0 _
                     And X3 * 4 + 2 + Y3 * bitWidth <= bitWidth * bi24BitInfo.bmiHeader.biHeight _
                     And X3 * 4 + Y3 * bitWidth >= 0 Then
                      Pic2Bits(x * 4 + y * bit2Width) = PicBits(X3 * 4 + Y3 * bitWidth)
                      Pic2Bits(x * 4 + 1 + y * bit2Width) = PicBits(X3 * 4 + 1 + Y3 * bitWidth)
                      Pic2Bits(x * 4 + 2 + y * bit2Width) = PicBits(X3 * 4 + 2 + Y3 * bitWidth)
                    End If
                  End If
                End If
            Next y
        Next x
    SetBitmapBits i2Bitmap, bi24Bit2Info.bmiHeader.biSizeImage, Pic2Bits(0) '将Pic2Bits赋与i2Bitmap
    BitBlt ToPicture.hDC, 0, 0, bi24Bit2Info.bmiHeader.biWidth, bi24Bit2Info.bmiHeader.biHeight, i2DC, 0, 0, vbSrcCopy '将i2DC拷贝到ToPicture中
    '释放对象
    If hOldMap Then DeleteObject SelectObject(iDC, hOldMap)
    If hOldMap Then DeleteObject SelectObject(i2DC, hOldMap)
    DeleteObject iDC '
    DeleteObject i2DC
    ToPicture.Refresh
    CircumvolvingBits = True '返回真值
    End Function
      

  9.   

    jennyvenus(JennyVenus)复制的是ThirdApple(第三只苹果)的http://expert.csdn.net/Expert/topic/900/900205.xml?temp=.7593653
      

  10.   

    我可以要一份么,大虾
    [email protected]
      

  11.   

    http://www.5ivb.net/zyl910/zyl910_Rotate.zip