Hi all,

I have a picturebox with scalemode pixel

dim height as integer
dim width as integer

height = picbox.scaleHeight
width = picbox.scaleWidth

picbox.PaintPicture pic, 0, 0, height, width, 0, 0, picheight, picwidth

note: picheight and picwidth are the height and the width of pic (in pixel) that has been calculated with autosize picturebox in other form.

My problem is: the picture cannot be drawn for the entire picturebox... there is a gap on the right and bottom in the picturebox... why is it happens?

Note: my project is to zoom out the pic... to fit the picbox

Thanks

scalemode the same for all? because this works (as a test)

``Picture2.PaintPicture Picture1.Picture, 0, 0, Picture2.ScaleWidth, Picture2.ScaleHeight, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight``

and picture2 is set at double the size of picture1...

Properties changed at design time
AutoRedraw
ScaleMode = vbPixels
Picture1.AutoSize = True 'while picture2.autosize = false

Good Luck

The problem is from Height to ScaleHeight and ScaleHeight to Height

Get the Height and Width of the Image from the Picture object rather than from AutoSize

To Get the Height and Width of the Image

``````Private Sub Form_Load()

Dim img As StdPicture
'Image Height and Width is in HiMetrix Unit and Change it to Pixel
MsgBox (" Height = " & HiMetrixToPixelY(img.Height) & " px Width = " & HiMetrixToPixelX(img.Width) & " px")
End Sub

'Function to Change Height from HiMetrix to Pixel
Private Function HiMetrixToPixelY(yHiM) As Long
HiMetrixToPixelY = Me.ScaleY(yHiM, vbHimetric, vbPixels)
End Function
'Function to Change Width from HiMetrix to Pixel
Private Function HiMetrixToPixelX(xHiM) As Long
HiMetrixToPixelX = Me.ScaleX(xHiM, vbHimetric, vbPixels)
End Function``````

I have shown u to convert one unit to another

The Problem may be from PaintPicture method call
Syntax is
PaintPicture picture, x1, y1, destWidth, destHeight, x2, y2, srcWidth, srcHeight, opcode

But u have interchanged the parameters width for height and height for width in the `picbox.PaintPicture pic, 0, 0, height, width, 0, 0, picheight, picwidth` I hope this may help u

good one thanks.. it has been solved now... thanks a lot

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.