Card images

Discussion in 'Code Samples & Tips' started by Stellaferox, Jan 25, 2008.

  1. Stellaferox

    Stellaferox Active Member Licensed User


    Does anyone know how to open or use cards.dll from windows (used in solitaire)? I want to use the cards for an apllication I am writing, without scanning them
    thnx in advance
    Last edited: Jan 29, 2008
  2. Stellaferox

    Stellaferox Active Member Licensed User

    reposting...problem not answered......
  3. agraham

    agraham Expert Licensed User

    Desktop only as cards.dll not present on the device. Needs .Net 2.0 and cards.dll in Windows\System32. XP has it, Vista doesn't - "borrow it" from an XP system. Enjoy! :)

    Attached Files:

  4. Stellaferox

    Stellaferox Active Member Licensed User

    Thx Agraham,
    A tool to extract the cards for the pocket pc would be nice now.....
  5. agraham

    agraham Expert Licensed User

    Shhh! Don't tell anyone about this.

    Attached Files:

  6. Erel

    Erel Administrator Staff Member Licensed User

    This one deserves to be in the Code Samples forum.
  7. dlfallen

    dlfallen Active Member Licensed User

    Here is another

    Here is another file of playing cards. I started a card project months ago, but it has been on hold for a long time. I did, however, have the card images compiled including a joker and several card backs. Attached is the file and a card demo program for viewing them.

    I intend to write a tutorial on the use of this card image file. If there is genuine interest, I can move that task up to the head of the queue.

    -Dave Fallen

    P.S. The card images provided by agraham have simpler graphics and may display better for smaller cards sizes. I haven't tested either card file on the device yet.

    Attached Files:

  8. Stellaferox

    Stellaferox Active Member Licensed User


    You are really magnificent! This is what I needed!!! Thanks very much. i think the community can use this very well. I sure can. Now I can go on with my Texas Hold Em Poker Hand evaluation with simulation of probabilities!!
    Thanks again
  9. RandomCoder

    RandomCoder Well-Known Member Licensed User

    If you need a tester then I volunteer myslef.
    I've been playing it on Facebook for the last couple of months which is mostly why I'm on here less often :sign0013:
    It's just too addictive :sign0085:

  10. Stellaferox

    Stellaferox Active Member Licensed User

    LOL, me too!!

    I will keep that offer in mind. The main idea is to deal the hand and then calculate probabilities that you win with tha thand against a community. No intention (yet) to make a poker playing game, but I got this deep in game theory that the challenge is quit irresistable...

    Meantime, who can tell me what the format of the cards.dat file is? I am interested in the index and how it is built.


  11. dlfallen

    dlfallen Active Member Licensed User

    Marc, the cards.dat is a binary file created with B4PPC's binaryfile.dll. First, I assembled the bitmaps for each card and card back. Then I wrote a short program using the EmbedFile method to put all the bitmaps into a single file -- cards.dat.

    As you can see from the CardDemo program, the images are retrieved using the RetrieveImage method. To retrieve a particular card image (bitmap), you need to know the starting position for that image within cards.dat. The CardDemo program gives you the algorithm for retrieving images 1-63, where images 1-52 are the cards in a standard deck, 53 is the joker, and 54-63 are different card backs.

    All of the bitmaps are 96 x 71 pixels but the first 53 images have only 4 bits per pixel whereas the rest of the cards have 8 bits per pixel which means the storage space for those images is larger. This makes calculating the starting position a little more difficult but again, the algorithm for doing so is in the CardDemo program.

    When you create an image control to receive the image with the RetrieveImage method, you should define its size in the same ratio as the original bitmap. The card demo program uses 96 x 71, 69 x 51, and 46 x 34, all of which have the same height to width ratio. Pick any height you wish and make the width proportional, or vice-versa.

    As you can see in the carddemo program, the first card in cards.dat is the Ace of Clubs, followed by the 2 through the King. Then comes Diamonds in the same rank order, then Hearts and then Spades. It is easy enough to "shuffle" the 52 cards and deal a random hand. But you need a way of identifying the rank and suit of a give card (say, for example, card number 31). Here is the algorithm for doing that (be sure to define Rank and Suit as global):

    Sub randcard(c)
    Rank = 1 + (c-1) Mod 13
    Suit = 1 + Int((c - 1) / 13)
    End Sub

    Rank returns a 1 for ace, 2-10, 11 = jack, 12 = queen, and 13 = king.
    Suit returns 1 = clubs, 2 = diamonds, 3 = hearts, 4 = spades.
    So if you enter the subroutine with C=31, you would get Rank = 5 and Suit = 3, i.e. the 5 of hearts.

    I hope this enough information to get you going. Good luck with your project!

    -Dave Fallen
  12. Stellaferox

    Stellaferox Active Member Licensed User

    Thanks Dave!,

    I already made the backbone of my Texas Hold Em Pokerhand evaluator. This works great.

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice