Results 1 to 13 of 13

Thread: Saving image created with System.Drawing.Graphics [resolved]

  1. #1

    Thread Starter
    Frenzied Member Ultimasnake's Avatar
    Join Date
    Feb 2002
    Location
    Amsterdam, holland
    Posts
    1,172

    Saving image created with System.Drawing.Graphics [resolved]

    I am currently combining 2 images with each other with an System.Drawing.Graphics object.... but once i have done that i want to save the image but i cant seem to get an image from the .image or .backgroundimage property :s


    this is my code

    VB Code:
    1. Dim g As System.Drawing.Graphics = PictureBox3.CreateGraphics
    2.         g.DrawImage(PictureBox2.Image, 0, 0)
    3.         g.DrawImage(PictureBox1.Image, 0, 0)
    4.         g.Save()
    5.         g.Dispose()
    6.         PictureBox4.Image = PictureBox3.Image ' nothing happens here

    putting it on another image is just a test to see if it worked.. ofcourse i know that i should save through the bitmap object

    any help would be nice
    Last edited by Ultimasnake; Nov 3rd, 2003 at 08:34 AM.
    For my PC and MS Smartphone 2003 software visit
    http://www.ultimasoftware.nl

  2. #2
    Addicted Member MasterBlaster's Avatar
    Join Date
    Jul 2002
    Location
    Seattle
    Posts
    196
    --> g.Dispose()<--
    "And most of the evils of society can, in fact, be cured through information. We have a society that has been disinformed and based on the disinformation has made irrational choices. And that's what I mean by 'ignorance.' People, who ordinarily might be smart, are deprived of the data by which to make a rational decision, don't have the data to do it."
    Frank Zappa

  3. #3

    Thread Starter
    Frenzied Member Ultimasnake's Avatar
    Join Date
    Feb 2002
    Location
    Amsterdam, holland
    Posts
    1,172
    what about it :S...
    For my PC and MS Smartphone 2003 software visit
    http://www.ultimasoftware.nl

  4. #4
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    when you create the PictureBox3.Image using graphics from the first 2 pictureboxes, the image is a " Virtual " image and not actually PictureBox3.Image ( if you tried saving PictureBox3.Image , you would probably find it saved a blank image, not the picture you see in the box )
    you would be best first creating the Image as an Image / Bitmap , then doing something like PictureBox3.Image = image
    ~
    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]

  5. #5

    Thread Starter
    Frenzied Member Ultimasnake's Avatar
    Join Date
    Feb 2002
    Location
    Amsterdam, holland
    Posts
    1,172
    uhm ok but the image/bitmap property doesnt have a creategrapics option... so how and where to use it precisely :S
    For my PC and MS Smartphone 2003 software visit
    http://www.ultimasoftware.nl

  6. #6
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    like this ...
    VB Code:
    1. [color=blue]Dim[/color] img [color=blue]As[/color] Image = Image.FromFile("C:\tester.bmp")
    2.         [color=blue]Dim[/color] grp [color=blue]As[/color] Graphics = Graphics.FromImage(img)
    3.         [color=blue]With[/color] grp
    4.             .DrawString("some string of text", [color=blue]New[/color] Font("Tahoma", 10, FontStyle.Bold), [color=blue]New[/color] SolidBrush(Color.Blue), 20, 20)
    5.         [color=blue]End With[/color]
    6.         PictureBox1.Image = img
    7.         PictureBox1.Image.Save("C:\a_Bitmap.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]

  7. #7

    Thread Starter
    Frenzied Member Ultimasnake's Avatar
    Join Date
    Feb 2002
    Location
    Amsterdam, holland
    Posts
    1,172
    Dim img As Image = Image.FromFile("C:\tester.bmp")
    /\

    how can i do this with a blank image only?
    For my PC and MS Smartphone 2003 software visit
    http://www.ultimasoftware.nl

  8. #8
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    if you want to start with a blank image...
    VB Code:
    1. [COLOR=blue]Dim[/COLOR] bmp [COLOR=blue]As New[/COLOR] Bitmap(200,200) [COLOR=green]'/// where 200 is the size , your size goes there.[/color]
    2. [COLOR=blue]Dim[/color] grp [COLOR=blue]As[/color] Graphics = Graphics.FromImage(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]

  9. #9

    Thread Starter
    Frenzied Member Ultimasnake's Avatar
    Join Date
    Feb 2002
    Location
    Amsterdam, holland
    Posts
    1,172
    works like a glove... only 1 problem

    the height and width should be taken from set variables... and this doesnt seem to work :

    VB Code:
    1. Dim bmp As New System.Drawing.Bitmap(x_width, x_height)


    so how the . can i do that? tried to set .height and .width afterwards but that doesnt seem to work
    For my PC and MS Smartphone 2003 software visit
    http://www.ultimasoftware.nl

  10. #10

    Thread Starter
    Frenzied Member Ultimasnake's Avatar
    Join Date
    Feb 2002
    Location
    Amsterdam, holland
    Posts
    1,172
    nevermind found it out ...

    VB Code:
    1. Dim bmp As System.Drawing.Bitmap = New System.Drawing.Bitmap(Width, Height)


    thanks for the help dynamic_sysop
    For my PC and MS Smartphone 2003 software visit
    http://www.ultimasoftware.nl

  11. #11
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    no problem , geode middag
    ~
    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]

  12. #12

    Thread Starter
    Frenzied Member Ultimasnake's Avatar
    Join Date
    Feb 2002
    Location
    Amsterdam, holland
    Posts
    1,172
    nederlands? :P


    (translation)
    dutch? :P
    For my PC and MS Smartphone 2003 software visit
    http://www.ultimasoftware.nl

  13. #13
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    ja maar ik heeft in engeland gewoonde voor 27 jaar, so mij nederlandse is niet goede
    i originally come from a place called Almelo in holland.
    ~
    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