VB的图象控件能加载jpg 但是保存的时候却不能为jpg,牛啊,谁有决绝方法?

解决方案 »

  1.   

    http://yuanbo.webhostme.com/down/jpg.zip
    用此控件
      

  2.   

    SavePicture picture, stringexpressionSavePicture 语句的语法包含下面部分:参数 描述 
    picture 产生图形文件的 PictureBox 控件或 Image 控件。 
    stringexpression 欲保存的图形文件名。 
    Private Sub Form_Click ()
       ' 声明变量。
       Dim CX, CY, Limit, Radius   as Integer, Msg as String
       ScaleMode = vbPixels   ' 设置比例模型为像素。
       AutoRedraw = True ' 打开 AutoRedraw。
       Width = Height   ' 改变宽度以便和高度匹配。
       CX = ScaleWidth / 2   ' 设置 X 位置。
       CY = ScaleHeight / 2   ' 设置 Y 位置。
       Limit = CX   ' 圆的尺寸限制。
       For Radius = 0 To Limit   ' 设置半径。
          Circle (CX, CY), Radius, RGB(Rnd * 255, Rnd * 255, Rnd * 255)
          DoEvents   ' 转移到其它操作。
       Next Radius
       Msg = "Choose OK to save the graphics from this form "
       Msg = Msg & "to a bitmap file."
       MsgBox Msg
       SavePicture Image, "TEST.BMP"   ' 将图片保存到文件。
    End Sub
      

  3.   

    老大啊,你的只能保存bmp格式的啊,俺要保存jpg 的
      

  4.   

    保存在数据库中:
    '该函数保存图片。
    '参数1=保存的数据表名。参数2=主键,参数3=文件名
    Public Function SavePicture(ByVal vTableName As String, ByVal vid As String, ByVal vFileName As String) As Boolean
        
        Dim iStrm As New ADODB.Stream
        Dim iRs As New ADODB.Recordset
        Dim Con As New ADODB.Connection
        
        '连接数据源
        Con.Open "dsn=image"
        
        '读取文件到数据流
        With iStrm
            .Type = adTypeBinary
            .Open
            .LoadFromFile vFileName
        End With
        
        '存到数据库中
        Dim Sqlstring As String
        Sqlstring = "select * from " & vTableName & ";"
        iRs.Open Sqlstring, Con, adOpenKeyset, adLockOptimistic
        With iRs
            .AddNew
            .Fields("id") = vid
            .Fields("photo") = iStrm.Read
            .Update
        End With
        
        Set iStrm = Nothing
        Set iRs = Nothing
        Set Con = Nothing
        
    End Function
      

  5.   

    有的,但vb处理的比较慢,因此通常还是用控件。
    你搜一下csdn的老贴子。