Welcome Guest!
 VB.NET Helper
 Previous Message All Messages Next Message 
VB .NET Helper Newsletter  Rod Stephens
 Nov 28, 2011 08:39 PST 

Two quick notes.

O'Reilly is having a one-day CyberMonday Sale: 60% off 60 top ebooks
including my book "Start Here! Fundamentals of Microsoft .NET
Programming." Shop at http://bit.ly/s3vkkJ

I've also received no solutions yet for the "find the triangles" puzzles
so I'm going to wait another week before posting my solutions. See the
puzzles at:

    Puzzle: find the equilateral triangles in Visual Basic 6
    http://www.vb-helper.com/howto_triangle_puzzle.html

    Puzzle: find the equilateral triangles in Visual Basic .NET
    http://www.vb-helper.com/howto_net_triangle_puzzle.html
-----
Beginning Database Design Solutions
http://www.vb-helper.com/db_design.htm

    A good database design doesn't guarantee success, but a bad one
guarantees failure.
-----
Have a great week and thanks for subscribing!

Rod
RodSte-@vb-helper.com

Twitter feeds:
    VBHelper
    CSharpHelper
==========
==========

    VB.NET Contents:
1. New HowTo: Copy part of an image into a new PictureBox in Visual
Basic .NET
==========
++++++++++
      <VB.NET>
++++++++++
==========
1. New HowTo: Copy part of an image into a new PictureBox in Visual
Basic .NET
http://www.vb-helper.com/howto_net_copy_image_part.html
http://www.vb-helper.com/HowTo/howto_net_copy_image_part.zip

When you enter top, left, width, and height values and click the Copy
button, the program uses the following code to copy part of the image on
the left and display it on the right.

' Copy part of the original image.
Private Sub btnCopy_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnCopy.Click
    Dim top As Integer = Integer.Parse(txtTop.Text)
    Dim left As Integer = Integer.Parse(txtLeft.Text)
    Dim width As Integer = Integer.Parse(txtWidth.Text)
    Dim height As Integer = Integer.Parse(txtHeight.Text)

    ' Make a Bitmap to hold the result.
    Dim bm As New Bitmap(width, height)

    ' Associate a Graphics object with the Bitmap
    Using gr As Graphics = Graphics.FromImage(bm)
        ' Define source and destination rectangles.
        Dim src_rect As New Rectangle(left, top, width, height)
        Dim dst_rect As New Rectangle(0, 0, width, height)

        ' Copy that part of the image.
        gr.DrawImage(picOriginal.Image, dst_rect, src_rect,
GraphicsUnit.Pixel)
    End Using

    ' Display the result.
    picResult.Image = bm
End Sub

This code starts by getting the values you entered and making a Bitmap
to hold the result. It then makes a Graphics object associated with the
Bitmap.

It defines a source Rectangle to indicate the part of the original image
that should be copied and a destination Rectangle to indicate where that
part of the image should be drawn in the new Bitmap. It then calls the
Graphics object's DrawImage method to copy that part of the image.

The code finishes by displaying the new Bitmap in the PictureBox named
pixResult.
==========
Archives:
    http://www.topica.com/lists/VBHelper
    http://www.topica.com/lists/VB6Helper
    http://www.topica.com/lists/VBNetHelper

Twitter feeds:
    VBHelper
    CSharpHelper

Post questions at:
    http://www.topica.com/lists/VBHelperQA
	
 Previous Message All Messages Next Message 
  Check It Out!

  Topica Channels
 Best of Topica
 Art & Design
 Books, Movies & TV
 Developers
 Food & Drink
 Health & Fitness
 Internet
 Music
 News & Information
 Personal Finance
 Personal Technology
 Small Business
 Software
 Sports
 Travel & Leisure
 Women & Family

  Start Your Own List!
Email lists are great for debating issues or publishing your views.
Start a List Today!

© 2001 Topica Inc. TFMB
Concerned about privacy? Topica is TrustE certified.
See our Privacy Policy.