I'm making a Blackjack game for a project in college (semester-long) and I've hit a road block that I can't seem to get over.
I'm trying to load the card images so they can be displayed onscreen, but I've been having very little luck in doing so. I've got absolute references down; I can load from those, but any attempt to load from a relative path fails. The project must be standalone; I can't instruct my professor to copy these images onto the root.
#if FROMDISK
Uri myUri = new Uri(@"C:\cards\" + getFilename(r, s, "png"), UriKind.Absolute);
PngBitmapDecoder decoder2 = new PngBitmapDecoder(myUri, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
BitmapSource bmp = decoder2.Frames[0];
#else
System.Reflection.Assembly myAssembly = System.Reflection.Assembly.GetExecutingAssembly();
Stream myStream = myAssembly.GetManifestResourceStream("Blackjack." + getFilename(r, s, "png"));
BitmapImage bmp = new BitmapImage();
bmp.StreamSource = myStream;
#endif
// Draw the Image
im.Source = bmp;
im.Stretch = Stretch.Uniform;
im.Width = CARD_WIDTH;