Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Crashing Code

Crashing Code

Scheduled Pinned Locked Moved C#
graphicscomquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    TyronX
    wrote on last edited by
    #1

    I used http://www.codeproject.com/cs/media/perpxalpha\_sharp.asp to create a non-rectangular window. Then I tried to add a Label Form, but that didn't work (didn't show up). Therefore I thought that this maybe wouldn't be possible when you have a this type of window and tried directly to draw strings in my loaded bitmap: Graphics g = Graphics.FromImage(newBitmap); newBitmap.Dispose(); Font font = this.Font; Brush brush = new SolidBrush(Color.White); g.DrawString("Hallo wie geht es dir?",font,brush, 50,50); g.DrawImage(newBitmap,0,0); bitmap = newBitmap; newBitmap contains the loaded png (with alpha mask) image. The assignment of bitmap seems to crash (System.ArgumentException) because I disposed newBitmap. But why? I however assigned newBitmap again with g.DrawImage...

    J 1 Reply Last reply
    0
    • T TyronX

      I used http://www.codeproject.com/cs/media/perpxalpha\_sharp.asp to create a non-rectangular window. Then I tried to add a Label Form, but that didn't work (didn't show up). Therefore I thought that this maybe wouldn't be possible when you have a this type of window and tried directly to draw strings in my loaded bitmap: Graphics g = Graphics.FromImage(newBitmap); newBitmap.Dispose(); Font font = this.Font; Brush brush = new SolidBrush(Color.White); g.DrawString("Hallo wie geht es dir?",font,brush, 50,50); g.DrawImage(newBitmap,0,0); bitmap = newBitmap; newBitmap contains the loaded png (with alpha mask) image. The assignment of bitmap seems to crash (System.ArgumentException) because I disposed newBitmap. But why? I however assigned newBitmap again with g.DrawImage...

      J Offline
      J Offline
      Judah Gabriel Himango
      wrote on last edited by
      #2

      Draw image does not assign a bitmap, I'm suprised it isn't crashing on you at g.DrawImage line. Don't dispose the newBitmap until you're really done with it; or dispose it, then assign it again with

      newBitmap = new Bitmap()

      .

      Tech, life, family, faith: Give me a visit. Judah Himango

      T 1 Reply Last reply
      0
      • J Judah Gabriel Himango

        Draw image does not assign a bitmap, I'm suprised it isn't crashing on you at g.DrawImage line. Don't dispose the newBitmap until you're really done with it; or dispose it, then assign it again with

        newBitmap = new Bitmap()

        .

        Tech, life, family, faith: Give me a visit. Judah Himango

        T Offline
        T Offline
        TyronX
        wrote on last edited by
        #3

        ok thanks.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups