Rotation
-
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 ;-) -
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 ;-)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
-
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
-
oh, u r right, it works! :-) but, what's about this first example? it seems as if it works pretty good!
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 nativeCreateCompatibleBitmap
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 usingGraphics.FromHdc
to get aGraphics
object, then useClone
to clone it. I've never tried it this way, but GDI+ is usually as simple as this.Microsoft MVP, Visual C# My Articles