32 Cards set development -> Trying obtain .xap small size

All replies

  •  the problem with doing everything in xaml is that it sits in your DLL compressed effectively only by the zip algorithm.  it does not get compiled; it is in your DLL represented as plain text.  your user controls defining the cards make up 416kb out of the entire 440kb of the xap.

    i'd probably experiment with creating the cards procedurally.  have 1 user control for each suit, and create some logic that places them on the card correctly according to the card number.  the actual number on the card should obviously just be a textblock.

    so basically you'd have a very tiny user control for each one of heart, spade, diamond, club.  the only thing defined in each is just a single image of the suit.  then you'd have some function that creates each card on the fly via code:

    public UserControl CreateCard(cardNumber, suit) {
        // logic to place the suit image in the correct place and the correct number of times...

    of course, you'll still have to worry about the images for your queen, king, etc, but perhaps creating the other cards procedurally might have reduced the xap size enough so that it won't matter.

    Saturday, May 01, 2010 2:15 PM
  • Thanks for reply.

    I try this way ...

    Saturday, May 01, 2010 2:36 PM
  • Definitely create them with a procedure call, and not with a separate XAML for each card.  You only need one XAML Card which would be smart enough to decide what gets drawn on it depending on what type of card it is.  This should make the xap very small.

    Saturday, May 01, 2010 3:47 PM
  • I have investigated the option of converting PNG's into vector graphics using (open source) Inkscape. If I replaced one PNG for a vectorized version, the total size of data grew. However, I think this is my experience and not rule. PNG's compress better than vectors... who would have thought that?

    Saturday, May 01, 2010 4:14 PM
  • I've worked on converting that EXACT card set to XAML. There are a number of issues. First, the face cards are the main issue. If you look at the original SVG for the Jack of Spades there are 2 really big paths that define the black on the top and bottom. You should be able to define the path geometry once and then define 2 Paths that use that PathGeometry and applies the appropriate transforms. You would use the same idea for the suits in the non-face cards. You could also save some space by changing the numbers from paths to Textblocks. Given the complexity of the Paths in the face cards, it would be challenging to get the entire set under 100k. I would guess that with some work 250-300k is possible. With the release of Silverlight 4 I've been meaning to get back to finishing the conversion of these. Here's my work so far,
    Saturday, May 01, 2010 5:34 PM
  • Yeah if you look atn the for suites then reall you only need the j,q,k of each as full card faces and the a,2 to 10 can all be generated in code as long as you save the symbols for hart,diamond,spade,club and size/copy and position them.

    you could make a matrix / map of where the symbols go for each card and note that for example the 3 is the ace plus the 2.

    that pattern happens several times in a deck

    4/5  and 6/7  and 8/9

    where the 5,7 and 9 are the addition of one more.

    see what i mean ??

    Saturday, May 01, 2010 7:36 PM
  • A lot of good ideasBig Smile

    Merci beaucoup (en français dans le texte)


    Sunday, May 02, 2010 4:45 AM
  • btw, have you tried assembly caching? This should also reduce xap size substantially.

    To enable assembly caching, in Silverlight project properties check “Reduce XAP size” checkbox

    more info:

    Sharker Khaleed Mahmud

    Sunday, May 02, 2010 5:51 AM
  • No Change in the xap file when using this option assembly caching Sad

    Sunday, May 02, 2010 6:06 AM
  •  using assembly caching only reduces xap size when you would otherwise have more than 1 dll in your xap...

    he only has Cards.dll

    Sunday, May 02, 2010 10:00 AM
  • Another option is to load the cards on-the-fly. Just copy them to the web server separately from the XAP and when the application loads, use WebClient to download the cards. If you save them as .jpg files, you don't even need to use webclient - just <Image Source=""/> from the XAML. I use this extensively to load backgrounds, videos, etc in The full application is about 87 MB but the initial XAP size is about 800 KB. Also in the front page of The initial application size was ~200 KB, reduced to ~ 35 KB after caching.

    Hope that helps..

    Edit: it's unlikely that you'll display all cards at once, that's why this method would work to improve the perceived app speed from the user.

    If you want to display all cards at first, you could make a .jpg that contains all cards with very low quality and display that, and replace it with the high-quality cards as they become available. I've made a control to make this transition smooth/unnoticeable (typically)


    Tuesday, May 18, 2010 2:54 PM
  • Hooo thanks ! It is a good way too Big Smile


    Tuesday, May 18, 2010 4:10 PM
  • you can save you graphic files with low level quality.

    Photoshop -> Save as -> Web...

    Tuesday, May 18, 2010 4:15 PM
  • you can save you graphic files with low level quality.

    They're vector art, good for nice scaling, for example...

    Tuesday, May 18, 2010 7:44 PM
  •  the option of converting PNG's into vector graphics using (open source) Inkscape is one I like to use, and with great results

    Wednesday, May 19, 2010 11:58 PM
  • I like too.
    Just one problem with Inkscape is 0,0 coordonates not in left bottom.

    I write a mistake

    Inkscape use 0,0 coordonates in left-bottom.

    But Silverlight use 0,0 coordonates in left-top

    Have you solution for tranform Inkscape xaml file coordonates in Silverlight xaml file coordonate ?


    Thursday, May 20, 2010 2:23 AM
  • 0,0 is the left-bottom in Inkscape. What I do is I move the graphic to align with the top-left of the page-rectangle. If you then convert it and delete the original image, you can save it as XAML, which will be correctly aligned. Up till now I have not used any result of this, because I found that the XAML produced by Inkscape is larger than the original PNG.

    Thursday, May 20, 2010 5:29 PM
  • Yes after generating xaml by Inkscape, you must rebuild the file whit Kaxaml to reduce the size.

    Friday, May 21, 2010 3:45 AM
  • My new version reduce .xap size to 193 Ko Laughing

    Have a look here :

    Sunday, July 25, 2010 5:18 AM
  • Hi,

    How did you do it? Did you replace Xaml with code?

    Sunday, July 25, 2010 11:07 AM
  • Yes i replace max of xaml by code.

    I search also to replace path Data by code, but i don't find a parse function.

    In the path Data, suppress blank space
    For example : M 86,10 must be replace by M86,10

    Don't use UserControl with xaml if possible.
    Make Class an inherit UserControl or other control.

    You reduce code by 15%


    Sunday, July 25, 2010 11:37 AM
  • I was also investigating this option, a little, but you have proved that it is worth it, that's nice to know.

    For those who do not know: pull a dll with at least one UserControl from your xap and open it in notepad. You'll see that the dll contains the complete Xaml; the Xaml is not converted to code, it is not reduced.

    Sunday, July 25, 2010 1:19 PM
  • You could also try using software such as illustrator to reduce the number of points in your paths in the original artwork. This should help


    Wednesday, July 28, 2010 3:36 PM
  • I've looked at the SVG cardset and I could compress it to 77Kb. Load SVG cardset in Inkscape. Export as PNG in Inkscape. In Photoshop, resize image to 840x469, and save for webdevices with PNG-8. You don't have vectors then, but you do have a small size. 

    Monday, August 23, 2010 5:52 PM
  • Have you link for looking ? 

    Tuesday, August 24, 2010 2:20 AM