BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.onload);" line, I get and exception: {"The codec cannot use the type of URI provided."}
Any ideas why I'm getting this exception? I don't get it on every file. Just a few of my .jpg files.
I might be able to attach one of the offending jpg's. But I'll post this first.
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.IO;
namespace xxx
{
public class ImageButton : Window
{
[STAThread]
public static void Main()
{
Application app = new Application();
app.Run(new ImageButton());
}
public ImageButton()
{
Title = "ImageButton";
string path = "C:\\nextBtn.jpg";
if (File.Exists(path))
{
Uri uri = new Uri(path);
//BitmapDecoder decoder = new JpegBitmapDecoder(uri,
BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.onload);
BitmapImage bitmap = new BitmapImage(uri);
Image img = new Image();
img.Opacity = 50;
img.Source = bitmap;
img.Stretch = Stretch.None;
Button btn = new Button();
btn.Content = img;
btn.HorizontalAlignment = HorizontalAlignment.Center;
btn.VerticalAlignment = VerticalAlignment.Center;
Content = btn;
}
}
}
}

New Topic/Question
Reply




MultiQuote




|