2014-11-08 45 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