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. Rotation

Rotation

Scheduled Pinned Locked Moved C#
graphicstutorialquestion
4 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.
  • O Offline
    O Offline
    oOomen
    wrote on last edited by
    #1

    hi, i use cards.dll to draw cards in my app. and it works good in onpaint method for example: Graphics x = e.Graphics; hdc = x.GetHdc(); x.ReleaseHdc(hdc); cardHandle.drawCardBack( hdc, 90, 10, eBACK.WEAVE1 ); but if i try do the same thing offscreen, it does not work!:confused: can someone explain why? Bitmap offScreenBmp = new Bitmap(this.Width, this.Height); Graphics offScreenDC = Graphics.FromImage(offScreenBmp); hdc = offScreenDC.GetHdc(); offScreenDC.ReleaseHdc(hdc); cardHandle.drawCardBack( hdc, 90, 10, eBACK.WEAVE1 ); e.Graphics.DrawImage(offScreenBmp, 10, 10); I need it to rotate this card. I have tried this method, but it does not worke.Graphics.RotateTransform(90f); if u know another way how to rotate the card i draw with cards.dll, please tell me ;-) thank u ;-)

    H 1 Reply Last reply
    0
    • O oOomen

      hi, i use cards.dll to draw cards in my app. and it works good in onpaint method for example: Graphics x = e.Graphics; hdc = x.GetHdc(); x.ReleaseHdc(hdc); cardHandle.drawCardBack( hdc, 90, 10, eBACK.WEAVE1 ); but if i try do the same thing offscreen, it does not work!:confused: can someone explain why? Bitmap offScreenBmp = new Bitmap(this.Width, this.Height); Graphics offScreenDC = Graphics.FromImage(offScreenBmp); hdc = offScreenDC.GetHdc(); offScreenDC.ReleaseHdc(hdc); cardHandle.drawCardBack( hdc, 90, 10, eBACK.WEAVE1 ); e.Graphics.DrawImage(offScreenBmp, 10, 10); I need it to rotate this card. I have tried this method, but it does not worke.Graphics.RotateTransform(90f); if u know another way how to rotate the card i draw with cards.dll, please tell me ;-) thank u ;-)

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      It probably doesn't work because you're releasing the HDC before you use it. Release it afterward. Once you've drawn to an off-screen bitmap, you should have no problems rotating it.

      Microsoft MVP, Visual C# My Articles

      O 1 Reply Last reply
      0
      • H Heath Stewart

        It probably doesn't work because you're releasing the HDC before you use it. Release it afterward. Once you've drawn to an off-screen bitmap, you should have no problems rotating it.

        Microsoft MVP, Visual C# My Articles

        O Offline
        O Offline
        oOomen
        wrote on last edited by
        #3

        oh, u r right, it works! :-) but, what's about this first example? it seems as if it works pretty good!

        H 1 Reply Last reply
        0
        • O oOomen

          oh, u r right, it works! :-) but, what's about this first example? it seems as if it works pretty good!

          H Offline
          H Offline
          Heath Stewart
          wrote on last edited by
          #4

          Surprising that it does, but you really shouldn't release the HDC until you're done (that's how it supposed to work). See the native CreateCompatibleBitmap API. You probably need to create a bitmap that is compatible (i.e., supports the same capabilities) with the on-screen bitmap, which is usually the case in GDI. You might be able to accomplish this by using Graphics.FromHdc to get a Graphics object, then use Clone to clone it. I've never tried it this way, but GDI+ is usually as simple as this.

          Microsoft MVP, Visual C# My Articles

          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