Card images

Stellaferox

Active Member
Licensed User
Hi,

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
Marc
 
Last edited:

dlfallen

Active Member
Licensed User
Longtime 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.
 

Attachments

  • CardDemo.zip
    154.9 KB · Views: 488

Stellaferox

Active Member
Licensed User
Guys,

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
Marc
 

RandomCoder

Well-Known Member
Licensed User
Longtime 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:

Regards,
RandomCoder
 

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.

thnx

Marc
 

dlfallen

Active Member
Licensed User
Longtime 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
 

Stellaferox

Active Member
Licensed User
Thanks Dave!,

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

marc
 
Top