保存的时候保存线条的起点坐标和终点坐标即可
读取的时候读取每个线条的起点坐标和终点坐标,然后在画:
picture1.line 起点坐标-终点坐标

解决方案 »

  1.   

    我需要保存成 。BMP 或。GIF 文件
      

  2.   

    可以用 bitblt 把需要的那块截取出来到另一个 picturebox 然后再保存
      

  3.   

    想要画多大保存多大的话,用 wxy_xiaoyu(然也) 的方法。
      

  4.   

    新建工程,在form上添加2个 picturebox以下代码:=================================
    Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC 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 dwRop As Long) As LongDim BegX As Integer, BegY, EndX, EndY
    Dim LDown As BooleanPrivate Sub Form_Load()
        Picture1.Move 0, 0, Me.Width, Me.Height
        Picture1.ZOrder 0
        Picture1.AutoRedraw = True
        Picture2.AutoRedraw = True
        
        LDown = False
    End Sub
    Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
        If Button = 1 Then
            BegX = x
            BegY = y
            LDown = True
        End If
    End SubPrivate Sub Picture1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
        If LDown = True Then
            Picture1.ZOrder 0
            Picture1.Line (EndX, EndY)-(BegX, BegY), Picture1.BackColor
            Picture1.Line (BegX, BegY)-(x, y)
            EndX = x
            EndY = y
            
            Picture2.Width = Abs(BegX - EndX)
            Picture2.Height = Abs(BegY - EndY)
            
            
            
        End If
    End SubPrivate Sub Picture1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
        LDown = False
        
        Picture2.Cls
        
        '''这里只写了有角度的线条截取,如果水平或垂直线条可以直接在PICTURE2上画,不用BITBLT
        If BegX < EndX And BegY < EndY Then
            BitBlt Picture2.hDC, 0, 0, Picture2.Width, Picture2.Height, Picture1.hDC, BegX / 15, BegY / 15, vbSrcCopy
        ElseIf BegX > EndX And BegY < EndY Then
            BitBlt Picture2.hDC, 0, 0, Picture2.Width, Picture2.Height, Picture1.hDC, EndX / 15, BegY / 15, vbSrcCopy
        ElseIf BegX < EndX And BegY > EndY Then
            BitBlt Picture2.hDC, 0, 0, Picture2.Width, Picture2.Height, Picture1.hDC, BegX / 15, EndY / 15, vbSrcCopy
        ElseIf BegX > EndX And BegY > EndY Then
            BitBlt Picture2.hDC, 0, 0, Picture2.Width, Picture2.Height, Picture1.hDC, EndX / 15, EndY / 15, vbSrcCopy
        End If
        
        Picture1.Cls
        
        Picture2.ZOrder 0
        Picture2.Move 0, 0
            
        SavePicture Picture2.Image, "c:\temp.bmp"
        MsgBox "Save TO “C:\temp.bmp”OK !"End SubPrivate Sub Picture2_Click()
        Picture2.ClsEnd Sub
      

  5.   

    写完了才想起来,最简单的方法是在 PICTURE1 上画完后算一下矩形的大小然后把 PICTURE2 的大小设置为正好符合的大小,判断直线方向,画一个对角线或者水平或者垂直线,然后直接保存
    我真笨! 舍近求远了
      

  6.   

    如果你对GDI函数比较熟悉的话
    保存为EMF是最好的选择在MSDN去检索“Metafile”,很详细的
      

  7.   

    BitBlt Picture2.hDC, 0, 0, Picture2.Width, Picture2.Height, Picture1.hDC, BegX / 15, BegY / 15, vbSrcCopy
    请问鼠标点的坐标值为什么要除以15呢?
      

  8.   

    因为 该死的(念错了,是Gates——盖茨)MicroSoft把VB默认的度量单位设为Twips一般情况下Twips是Pixel的15倍
      

  9.   

    wxy_xiaoyu(然也) ( )
    :
    你说的方法我很早就想到了,但是由于为止客户需要画多少LINE,采用PICBOX控件数组占用资源太大,此方法我认为不可取
      

  10.   

    有道理,才用LINE,就只需要一个PICbox,我确忘了采用LINE数组,谢谢楼上。