Ver Mensaje Individual
  #15 (permalink)  
Antiguo 06/01/2009, 23:00
German2009
 
Fecha de Ingreso: enero-2009
Mensajes: 1
Antigüedad: 15 años, 4 meses
Puntos: 0
Respuesta: Resizar MDIform.picture (VB6)

Hola o todos un poco tarde pero seguro, aqui dejo como redimensionar una imagen y no deformarla, se puede ir redimensionando el MDI form y la imagen se agranda o achica pero sin deformarse rellenando en blanco los espacios del form que no corresponden en Width o Height de la imagen.
Se necesita dos PictureBox
ponerolos el MDI Form
1ro. picStretch (nombre PictureBox 1)
2do. picNothing (nombre PictureBox 2)
3ro. cargar picStretch con una imagen
4to. Abrir el pain y con el balde pintar de un color (color que quedará de fondo en el programa) y guardar la imagen (*.jpg).
5to. cargar picNoting con esa imagen del paint.
y por último el código....
Cita:
Private Sub MDIForm_Load()
'Call redimensionarImagenMDIForm
'MDIForm1.picStretch = LoadPicture("D:\Cristian\fotos\0001.jpg")
End Sub

Private Sub MDIForm_Resize()
Call redimensionarImagenMDIForm
End Sub

'Por las dudas coloquen esta funcion en un módulo

Public Function redimensionarImagenMDIForm()

Dim ImageWidth As Single
Dim ImageHeight As Single
Dim Red As Double

On Error Resume Next

MDIForm1.picStretch.Visible = False
MDIForm1.picStretch.AutoRedraw = True
MDIForm1.picStretch.Height = MDIForm1.Height
If (MDIForm1.picStretch.Picture.Height > MDIForm1.Height) Then
Red = (MDIForm1.Height) / MDIForm1.picStretch.Picture.Height
ImageHeight = MDIForm1.picStretch.Picture.Height * Red
ImageWidth = MDIForm1.picStretch.Picture.Width * Red
End If
If (ImageWidth > MDIForm1.Width) Then
Red = (MDIForm1.Width) / MDIForm1.picStretch.Picture.Width
ImageHeight = MDIForm1.picStretch.Picture.Height * Red
ImageWidth = MDIForm1.picStretch.Picture.Width * Red
End If

MDIForm1.picStretch.PaintPicture MDIForm1.picNothing.Picture, 0, 0, MDIForm1.Width, MDIForm1.Height, 0, 0
MDIForm1.picStretch.PaintPicture MDIForm1.picStretch.Picture, 0, 0, ImageWidth, ImageHeight, 0, 0
Set MDIForm1.Picture = MDIForm1.picStretch.Image

Resume: Exit Function
End Function
Espero que les sirva.
Saludos