PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
[RESOLVED] [VB2005]Slow drawing of Playing-cards using Cards.Dll-VBForums
Results 1 to 7 of 7

Thread: [RESOLVED] [VB2005]Slow drawing of Playing-cards using Cards.Dll

  1. #1

    Thread Starter
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    Resolved [RESOLVED] [VB2005]Slow drawing of Playing-cards using Cards.Dll

    Hi,
    I'm drawing playing-cards onto a picturebox.
    Each time I draw them (a max of 104 cards for a complete picture) I notice a small delay in drawing, even on a dual-core pc!
    I tried backbuffering, but it took away only the delay when a complete redraw isn't necessary. Whenever I draw all cards it has this delay.
    Is there a faster way to draw playing cards besides the use of the Cards.DLL
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  2. #2
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,020

    Re: [VB2005]Slow drawing of Playing-cards using Cards.Dll

    Im not familiar with this cards.dll...what is it? How are you doing the drawing?
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  3. #3

    Thread Starter
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    Re: [VB2005]Slow drawing of Playing-cards using Cards.Dll

    The cards.Dll is used to show playing cards (for card-games like solitair or poker).
    It holds the pictures for all cards as well as some backgrounds.
    The drawing is done be a call like:
    Code:
    cdtDrawExt(hdc, x, y, Width, Height, Card, Style, Color)
    with hdc beeing the HDc, x and y the position, Width and Height are used to stretch, Card is telling which Card to draw,style tells wether fore- or background and color gives to color.
    It looks to me like an wrapper around a strBilBlt using the pictures of the cards.
    I use it to draw either on a bitmap object and put that one onto a pictuerbox or to draw directly onto the picturebox, both cases show the slow "painting".
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  4. #4
    Hyperactive Member metalmidget's Avatar
    Join Date
    Mar 2007
    Location
    Melbourne, Australia
    Posts
    342

    Re: [VB2005]Slow drawing of Playing-cards using Cards.Dll

    Isn't stretch blitting notoriously slow? If you don't need to stretch the cards, would creating your own wrapper that uses bitblit be an option?
    Actually, now I think of it, I may have heard from somewhere that stretchblit is only slow if you do stretching, so if you're not stretching the image it's exactly the same speed as bitblit. But I could be making that up.
    I've created games just using VB6 and bitblt, using over 100 sprites, running in a mazimised window, at speeds up to 100FPS with no delay/flicker etc, so I don't know what it could be. Is your computer decent? Is your own code efficient?

    metal

  5. #5

    Thread Starter
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    Re: [VB2005]Slow drawing of Playing-cards using Cards.Dll

    Quote Originally Posted by metalmidget
    Is your computer decent? Is your own code efficient?
    On the first one it's a definite YES (DualCore.....) for the notebook, however the old desktop isn't. There is a big difference when running it on the notebook or the desktop.
    On the second, I figured NO
    My present solution is, not to draw all my cars whenever anything changes (that was easy doing). I changed it to draw only the needed parts, that takes away most of of the cases for those delays. However when for example the form is rezised, or a new game is to be drawn, there is no way around it.


    I was working with starting lines and circles in my other applications, in those I did redraw everything for each cycle with no noticeable delay ( and that was on the "old" desktop under VB6 and VB2005), so I was a bit surprised by that delay.

    On the StrBitBlt or BitBlt, the cards.Dll does also have a method to draw without the streching posibility. There was no difference when using that method compared to the use of the method that allowed strechting (but not actually using it).


    To conclude: I found my solution (optimze code], I'll close this one, Thanks!
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  6. #6
    Hyperactive Member metalmidget's Avatar
    Join Date
    Mar 2007
    Location
    Melbourne, Australia
    Posts
    342

    Re: [RESOLVED] [VB2005]Slow drawing of Playing-cards using Cards.Dll

    If you've done other stuff with no delay, and if the 'no-stretching' option makes no difference, then maybe it's the extra layer of abstraction from the DLL that makes it slow? Depending on what functions the DLL wraps, it might do something like:
    Pseudocode Code:
    1. Get ready to draw
    2.     Draw
    3. Stop being ready to draw
    If you call the DLL wrapper function a few times, you get:
    Pseudocode Code:
    1. Get ready to draw
    2.     Draw
    3. Stop being ready to draw
    4. Get ready to draw
    5.     Draw
    6. Stop being ready to draw
    7. Get ready to draw
    8.     Draw
    9. Stop being ready to draw
    10. etc etc
    Whereas, if you wrote the code without wrappers, you'd write:
    Pseudocode Code:
    1. Get ready to draw
    2.     Draw
    3.     Draw
    4.     Draw
    5. Stop being ready to draw
    If you're drawing 100+ cards, it could be the repetitive calls of get ready and stop being ready that are slowing you down. That's the best I can think of.

    hope that helps,
    metal

  7. #7

    Thread Starter
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    Re: [RESOLVED] [VB2005]Slow drawing of Playing-cards using Cards.Dll

    Good point, I could speed it up even more by not releasing HDC after every card drawn!
    Thanks a lot!
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width