2014-11-08 46 views
1

我試圖從PictureBox導出圖片,但問題是導出圖片的高度(寬度工作完美)。VB6 PictureBox高度

我還發現,VB6邊界必須導出圖片的大小重大影響,所以我將它設置爲0。

只需打開VB6拖放圖片框(和其重命名爲myPic)...

這是我的代碼:

Option Explicit 

Private Sub Form_Load() 

    myPic.AutoRedraw = True 

    myPic.BorderStyle = 0 
    myPic.Appearance = 0 
    myPic.Width = 100 * Screen.TwipsPerPixelX 'WORKING PERFECTLY!!! 
    myPic.Height = 100 * Screen.TwipsPerPixelY 'NOT RETURN 100px !!! Why ? 93px instead 
    myPic.ScaleMode = vbPixels 

    myPic.PaintPicture LoadPicture(App.Path & "\Source.bmp"), 0, 0, 100, 100 
    myPic.Picture = myPic.Image 

    SavePicture myPic.Picture, App.Path & "\Exported.bmp" 

End Sub 

任何想法?

在此先感謝!

回答

0

我想你的代碼,和它的作品,因爲我覺得你想要的結果:它顯示在100x100的圖片框source.bmp,並出口到100×100像素

我使用的代碼,bmp是:

Option Explicit 

Private Sub Form_Load() 
    With Picture1 
    .AutoRedraw = True 
    .ScaleMode = vbPixels 
    .BorderStyle = 0 
    .Appearance = 0 
    .Width = 100 * Screen.TwipsPerPixelX 'WORKING PERFECTLY!!! 
    .Height = 100 * Screen.TwipsPerPixelY 'NOT RETURN 100px !!! Why ? 93px instead 
    .PaintPicture LoadPicture("c:\temp\Source.bmp"), 0, 0, 100, 100 
    .Picture = .Image 
    SavePicture .Picture, "c:\temp\Exported.bmp" 
    End With 'Picture1 
End Sub 

我只是把.Scalemode放在最頂端,因爲我認爲它屬於它的位置,但是你的代碼也適用於.Scalemode。

請問您可以添加您嘗試重新縮放的圖片嗎?

對於我用下面的圖片源,這是300×300像素:

enter image description here

,結果爲:

enter image description here