Results 1 to 2 of 2

Thread: Drawing to Bitmaps

  1. #1

    Thread Starter
    Frenzied Member System_Error's Avatar
    Join Date
    Apr 2004
    Posts
    1,111

    Drawing to Bitmaps

    Can someone help me with this?...

    I want to draw simple graphics such as rectangles or lines to a bitmap instead of using the Me.creategraphics method. The only problem is: I don't know how to draw to a bitmap.

  2. #2
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    here's a simple example i made for you , it makes a bitmap / then makes 4 rectangles in the bitmap ( different colours )
    VB Code:
    1. Dim bmp As New Bitmap(200, 200) '/// create a bitmap 200 x 200 in size
    2.         Dim grp As Graphics = Graphics.FromImage(bmp)
    3.         Dim rcts(3) As Rectangle
    4.         rcts(0) = New Rectangle(0, 0, 100, 100)
    5.         rcts(1) = New Rectangle(100, 0, 100, 100)
    6.         rcts(2) = New Rectangle(0, 100, 100, 100)
    7.         rcts(3) = New Rectangle(100, 100, 100, 100)
    8.         Dim p As New Pen(Color.Red, 5)
    9.         With grp
    10.             .DrawRectangles(p, rcts)
    11.             .FillRectangle(New SolidBrush(Color.Blue), rcts(0))
    12.             .FillRectangle(New SolidBrush(Color.Green), rcts(1))
    13.             .FillRectangle(New SolidBrush(Color.Yellow), rcts(2))
    14.             .FillRectangle(New SolidBrush(Color.Violet), rcts(3))
    15.         End With
    16.  
    17.         '/// test by putting the bitmap as a picturebox's image ( if you wish to do so )
    18.         PictureBox1.Image = bmp
    ~
    if a post is resolved, please mark it as [Resolved]
    protected string get_Signature(){return Censored;}
    [vbcode][php] please use code tags when posting any code [/php][/vbcode]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width