Click here to Skip to main content
15,889,852 members
Home / Discussions / WPF
   

WPF

 
QuestionSilverlight Automatic Image Transition Pin
saurabh94-Apr-10 23:03
saurabh94-Apr-10 23:03 
AnswerRe: Silverlight Automatic Image Transition Pin
Michael J. Eber19-Apr-10 11:54
Michael J. Eber19-Apr-10 11:54 
QuestionRotaing Label control Pin
#realJSOP4-Apr-10 5:58
mve#realJSOP4-Apr-10 5:58 
AnswerRe: Rotaing Label control Pin
Abhinav S4-Apr-10 6:50
Abhinav S4-Apr-10 6:50 
GeneralRe: Rotaing Label control Pin
#realJSOP4-Apr-10 7:02
mve#realJSOP4-Apr-10 7:02 
GeneralRe: Rotaing Label control Pin
Abhinav S4-Apr-10 7:11
Abhinav S4-Apr-10 7:11 
GeneralRe: Rotaing Label control Pin
#realJSOP4-Apr-10 7:51
mve#realJSOP4-Apr-10 7:51 
QuestionImage.ImageSource to string ? Pin
Mohammad Dayyan3-Apr-10 16:58
Mohammad Dayyan3-Apr-10 16:58 
Hi,

I have the below XAML code :

<Window x:Class="WpfApplication1.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    DataContext="{Binding RelativeSource={RelativeSource Self}}"
    WindowStartupLocation="CenterScreen"
    Title="Window1" Height="300" Width="300">
    
    <Grid>
        <Image x:Name="TestImage" Source="{Binding Path=ImageSource}" />
    </Grid>

</Window>


Now, I'm gonna set the `TestImage` with the below method :

Image Base64StringToImage(string base64ImageString)
{
    try
    {
        byte[] b;
        b = Convert.FromBase64String(base64ImageString);
        MemoryStream ms = new System.IO.MemoryStream(b);
        System.Drawing.Image img = System.Drawing.Image.FromStream(ms);

        //////////////////////////////////////////////
        //convert System.Drawing.Image to WPF image
        System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(img);
        IntPtr hBitmap = bmp.GetHbitmap();
        System.Windows.Media.ImageSource imageSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(hBitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());

        Image wpfImage = new Image();
        wpfImage.Source = imageSource;
        wpfImage.Width = wpfImage.Height = 16;
        //////////////////////////////////////////////

        return wpfImage;
    }
    catch
    {
        Image img1 = new Image();
        img1.Source = new BitmapImage(new Uri(@"/passwordManager;component/images/TreeView/empty-bookmark.png", UriKind.Relative));
        img1.Width = img1.Height = 16;
        return img1;
    }
}



I've used the following code, but it doesn't work :

public string ImageSource { get; set; }
ImageSource = Base64StringToImage("iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAABjUExURXK45////6fT8PX6/bTZ8onE643F7Pf7/pDH7PP5/dns+b7e9MPh9Xq86NHo947G7Hm76NTp+PL4/bHY8ojD67rc85bK7b3e9MTh9dLo97vd8/D3/Hy96Xe76Nfr+H+/6f///1bvXooAAAAhdFJOU///////////////////////////////////////////AJ/B0CEAAACHSURBVHjaXI/ZFoMgEEMzLCqg1q37Yv//KxvAlh7zMuQeyAS8d8I2z8PT/AMDShWQfCYJHL0FmlcXSQTGi7NNLSMwR2BQaXE1IfAguPFx5UQmeqwEHSfviz7w0BIMyU86khBDZ8DLfWHOGPJahe66MKe/fIupXKst1VXxW/VgT/3utz99BBgA4P0So6hyl+QAAAAASUVORK5CYIII").Source.ToString();


Actually , I have a problem with converting ImageSource to string !
Would you please guide me, how I can do it ?
Thanks.
AnswerRe: Image.ImageSource to string ? Pin
Abhinav S3-Apr-10 18:09
Abhinav S3-Apr-10 18:09 
QuestionWPF DataGrid row backgound Pin
koleraba3-Apr-10 7:47
koleraba3-Apr-10 7:47 
AnswerRe: WPF DataGrid row backgound Pin
Abhinav S3-Apr-10 7:59
Abhinav S3-Apr-10 7:59 
GeneralRe: WPF DataGrid row backgound Pin
koleraba3-Apr-10 8:06
koleraba3-Apr-10 8:06 
QuestionListView Item Style Pin
Snecx2-Apr-10 9:33
Snecx2-Apr-10 9:33 
AnswerRe: ListView Item Style Pin
Richard MacCutchan2-Apr-10 9:44
mveRichard MacCutchan2-Apr-10 9:44 
GeneralRe: ListView Item Style Pin
Snecx2-Apr-10 11:23
Snecx2-Apr-10 11:23 
GeneralRe: ListView Item Style Pin
Richard MacCutchan2-Apr-10 22:03
mveRichard MacCutchan2-Apr-10 22:03 
QuestionRemoving Underline of Hyperlink control in WPF Pin
Hema Bairavan31-Mar-10 18:43
Hema Bairavan31-Mar-10 18:43 
AnswerRe: Removing Underline of Hyperlink control in WPF Pin
Parwej Ahamad31-Mar-10 19:39
professionalParwej Ahamad31-Mar-10 19:39 
AnswerRe: Removing Underline of Hyperlink control in WPF Pin
shyam sohane29-Jun-10 19:26
shyam sohane29-Jun-10 19:26 
QuestionDimming the indicator of a custom progressbar Pin
2hdass31-Mar-10 18:36
2hdass31-Mar-10 18:36 
QuestionChecking if User-Control DLL is being used by EXE Pin
Prasoon Chaudhary31-Mar-10 0:19
Prasoon Chaudhary31-Mar-10 0:19 
AnswerRe: Checking if User-Control DLL is being used by EXE Pin
Pete O'Hanlon31-Mar-10 0:28
mvePete O'Hanlon31-Mar-10 0:28 
GeneralRe: Checking if User-Control DLL is being used by EXE Pin
Prasoon Chaudhary31-Mar-10 0:42
Prasoon Chaudhary31-Mar-10 0:42 
GeneralRe: Checking if User-Control DLL is being used by EXE Pin
Pete O'Hanlon31-Mar-10 0:45
mvePete O'Hanlon31-Mar-10 0:45 
Questionsilverlight application template missing Pin
lkrfan30-Mar-10 18:37
lkrfan30-Mar-10 18:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.