|
|
|
|
|
Dicas
|
|
Visual Basic (Imagem/Som/Multimídia)
|
|
|
Título da Dica: Girar Imagem
|
|
|
|
Postada em 14/9/2007 por Vilmar Brazão
Option Explicit
Private Type POINTAPI x As Long y As Long End Type
Dim Pt(0 To 2) As POINTAPI
Private Declare Function PlgBlt Lib "gdi32" ( _ ByVal hdcDest As Long, _ lpPoint As POINTAPI, _ ByVal hdcSrc As Long, _ ByVal nXSrc As Long, _ ByVal nYSrc As Long, _ ByVal nWidth As Long, _ ByVal nHeight As Long, _ ByVal hbmMask As Long, _ ByVal xMask As Long, _ ByVal yMask As Long _ ) As Long
Private Sub cmdGirarImagemCompleta_Click() Call Rotate90(picFoto) End Sub
Private Sub cmdGirarImagemHorizontal_Click() Call FlipHorizontal End Sub
Private Sub cmdGirarImagemVertical_Click() Call FlipVertical End Sub
Private Sub VerticalHorizontal_Click() Call FlipVerticalHorizontal End Sub
Private Sub Form_Load() With picFoto .AutoRedraw = True .AutoSize = True .BorderStyle = 0 .Appearance = 0 .ScaleMode = vbPixels 'Carregue sua figura aqui .Picture = LoadPicture(App.Path & "imagens3_raios_simultaneos.jpg") End With Me.ScaleMode = vbPixels End Sub
Private Sub Rotate90(picsrc As PictureBox) Dim picWidth As Long Dim picHeight As Long picWidth = picsrc.Width picHeight = picsrc.Height Pt(2).x = 0 Pt(2).y = 0 Pt(0).x = picHeight Pt(0).y = 0 Pt(1).x = picHeight Pt(1).y = picWidth If picWidth > picHeight Then picsrc.Height = picWidth Else picsrc.Width = picHeight End If Call PlgBlt(picsrc.hdc, Pt(0), picsrc.hdc, 0, 0, picWidth, picHeight, ByVal 0&, ByVal 0&, ByVal 0&) picsrc.Width = picHeight picsrc.Height = picWidth picsrc.Refresh End Sub
Private Sub FlipVertical() Dim H As Long Dim W As Long H = picFoto.Height W = picFoto.Width 'flip vertical picFoto.PaintPicture picFoto.Picture, 0, H, W, -H End Sub
Private Sub FlipHorizontal() Dim H As Long Dim W As Long H = picFoto.Height W = picFoto.Width 'flip horizontal picFoto.PaintPicture picFoto.Picture, W, 0, -W End Sub
Private Sub FlipVerticalHorizontal() Dim H As Long Dim W As Long H = picFoto.Height W = picFoto.Width 'flip ambos picFoto.PaintPicture picFoto.Picture, W, H, -W, -H End Sub
'Código adaptado do link abaixo: 'http://www.codeguru.com/forum/archive/index.php/t-414694.html
|
|
|
|
|