dcsimg
Login | Register   
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: VB7
Expertise: Intermediate
Nov 18, 2002

WEBINAR:

On-Demand

Application Security Testing: An Integral Part of DevOps


DrawFlipImage - flipping an image on one or both axes

' Flip an image on one or both axes. The x and y
' parameters are the coordinates of the upper-left point
' Note: requires Imports System.Drawing.Imaging
'
' Example:
'   Dim gr As Graphics = Me.CreateGraphics
'   gr.Clear(Color.White)
'   Dim bmp As New Bitmap("logo.bmp")
'   DrawFlipImage(gr, bmp, 100, 20, False, False)
'   DrawFlipImage(gr, bmp, 300, 20, True, False)
'   DrawFlipImage(gr, bmp, 100, 120, False, True)
'   DrawFlipImage(gr, bmp, 300, 120, True, True)
'   bmp.Dispose()
'   gr.Dispose()

Sub DrawFlipImage(ByVal gr As Graphics, ByVal bmp As Bitmap, ByVal x As Single, _
    ByVal y As Single, ByVal flipX As Boolean, ByVal flipY As Boolean)
    ' Start with values of parallelogram's vertex as if no flipping occurs.
    Dim x0 As Single = x
    Dim y0 As Single = y
    Dim x1 As Single = x + bmp.Width
    Dim y1 As Single = y
    Dim x2 As Single = x
    Dim y2 As Single = y + bmp.Height

    ' Account for horizontal flipping.
    If flipX Then
        x0 = x + bmp.Width
        x1 = x
        x2 = x0
    End If
    ' Account for vertical flipping.
    If flipY Then
        y0 = y + bmp.Height
        y1 = y0
        y2 = y
    End If
    ' Create the points array.
    Dim points() As Point = {New Point(x0, y0), New Point(x1, y1), New Point(x2, _
        y2)}
    ' Draw the flipped image
    gr.DrawImage(bmp, points)
End Sub


' Note: This code is taken from Francesco Balena's
' "Programming Microsoft Visual Basic .NET" - MS Press 2002, ISBN 0735613753
' You can read a free chapter of the book at 
' http://www.vb2themax.com/HtmlDoc.asp?Table=Books&ID=101000
Francesco Balena
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date