Nate Bross Posted November 17, 2005 Posted November 17, 2005 Hi, I have a bitmap, say it's 800x600 pixels. I have a form that is fullscreen (1024x768), but I only want to draw a portian of the bitmap, say 400x400 pixels to the form. Any sugestions? Private Sub Form1_OnPaint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint e.Graphics.DrawImage(BackBuffer, New Point(0, 0)) End Sub I would like to draw the top left region, 400x400 pixels out of 800x600 of BackBuffer onto the form. I appreciate any advice you might have. Quote ~Nate� ___________________________________________ Please use the [vb]/[cs] tags on posted code. Please post solutions you find somewhere else. Follow me on Twitter here.
jo0ls Posted November 17, 2005 Posted November 17, 2005 Bobs GDI+ faq has some help: http://www.bobpowell.net/drawing_an_image.htm Here is one of the overloads: [Visual Basic] Overloads Public Sub DrawImage( _ ByVal image As Image, _ ByVal destRect As Rectangle, _ ByVal srcRect As Rectangle, _ ByVal srcUnit As GraphicsUnit _ ) Use it like this: Dim sourceRectangle As New Rectangle(0, 0, 400, 400) Dim targetRectangle As New Rectangle(0, 0, 400, 400) e.Graphics.DrawImage(backbuffer, targetRectangle, sourceRectangle, GraphicsUnit.Pixel) Quote
Nate Bross Posted November 17, 2005 Author Posted November 17, 2005 Thanks man, I feel silly the overload was right there, I must have missed it. Thanks alot. Quote ~Nate� ___________________________________________ Please use the [vb]/[cs] tags on posted code. Please post solutions you find somewhere else. Follow me on Twitter here.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.