Library doesn't work properly

Jul 2, 2013 at 8:51 AM
Hi everyone,

I'm Italian, so sorry for my bad English.

I'm trying to use WriteableBitmapEx: I added it to my WPF project using NuGet (and downloading it and adding the reference to the project too), but it doesn't work.
First of all, I followed the tutorial on the homepage of the project (the sample of code), but I can't found the overload which requires only two arguments (writeableBmp = new WriteableBitmap(0, 0).FromResource("Data/flower2.png");) because Visual Studio shows me only two overloads: one that requires a BitmapElement, and the other that requires the width, the height, the DPIX, the DpiY, the PixelFormat and the BitmapPalette.

So I tried to use the second one adding ".FromResource("Data/flower2.png");", but it still not work: it shows me execution errors (one with Just My Code, when I disabled JMC, it shows me a weird error).

The screenshots of the two errors are there:

http://snap.ashampoo.com/ZcKXhOGq
http://snap.ashampoo.com/o920B8xv

Could you help me? I'm a bit confused...

Oh, I've also read an article on an Italian magazine that shows how to make something like Instagram using WriteableBitmapEx (in Windows Phone 8). I'm still not able to work following it because of the overloads.

Thanks a lot.

Jymmy097
Coordinator
Jul 2, 2013 at 9:59 AM
Please use the BitmapFactory.New(1, 1) method. It handles all the rest. I will update the project main site. Sorry.

Check out the Source Code with the WPF samples. Those are great to use and adapt.
  • Rene
Jul 2, 2013 at 10:38 AM
Edited Jul 2, 2013 at 10:49 AM
Hi,

It still not work: it says that "Calls stack contains only external code. You have to disable 'only user code' and load symbols to view the origin of this path (or somehting similar: I have VS in Italian).
If I disable Just My code, it says that PresentatinFramework.pdb wasn't loaded.
C:\Windows\Microsoft.Net\assembly\GAC_MSIL\PresentationFramework\v4.0_4.0.0.0__31bf3856ad364e35\PresentationFramework.pdb: Unable to open or read the file PDB.
C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\PresentationFramework.pdb: Unable to open or read the file PDB.
C:\Windows\symbols\dll\PresentationFramework.pdb: Unable to open or read the file PDB.
C:\Windows\dll\PresentationFramework.pdb: Unable to open or read the file PDB.
C:\Windows\PresentationFramework.pdb: Unable to open or read the file PDB.

And then I stop the execution.
This is the code I use:

WriteableBitmap bmp = BitmapFactory.New(1, 1);
    public MainWindow()
    {
        InitializeComponent();
        bmp.FromResource("Image\\Tulips.jpg");
    }
and this is the XAML code:

<Window x:Class="Test45.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="900" Width="1366">
<Grid>
    <Button Content="Button" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Width="75" Click="Button_Click_1"/>
    <Image HorizontalAlignment="Left" Height="768" Margin="90,10,0,0" VerticalAlignment="Top" Width="1024"/>

</Grid>
</Window>

What's going on?

Thanks a lot.

Jymmy097

EDIT: I tried to add Tulips.jpg to one of the sample project and to load it using FromResource method.
This Window appeared:
http://snap.ashampoo.com/sGDY16Ai
It tells me to Find the origin of WriteableBitmapConvertExtensions.cs.
And If I do that, it tells me that Imust use BeginInit and EndInit or something similar because he couldn't find BitmapSource.

EDIT2:
I used this code:

bmp = BitmapFactory.New(1, 1).FromResource("Image\Tulips.jpg");

instead of this:

bmp.FromResource("Image\Tulips.jpg");

it tells me "Missing origin informations into debug informations for this module".
Jul 13, 2013 at 3:15 PM
I have the same problem ...
Is this a real bug? Or is the example outdated?
Jul 13, 2013 at 3:36 PM
Jymmy097 wrote:
Hi,

It still not work: it says that "Calls stack contains only external code. You have to disable 'only user code' and load symbols to view the origin of this path (or somehting similar: I have VS in Italian).
If I disable Just My code, it says that PresentatinFramework.pdb wasn't loaded.
C:\Windows\Microsoft.Net\assembly\GAC_MSIL\PresentationFramework\v4.0_4.0.0.0__31bf3856ad364e35\PresentationFramework.pdb: Unable to open or read the file PDB.
C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\PresentationFramework.pdb: Unable to open or read the file PDB.
C:\Windows\symbols\dll\PresentationFramework.pdb: Unable to open or read the file PDB.
C:\Windows\dll\PresentationFramework.pdb: Unable to open or read the file PDB.
C:\Windows\PresentationFramework.pdb: Unable to open or read the file PDB.

And then I stop the execution.
This is the code I use:

WriteableBitmap bmp = BitmapFactory.New(1, 1);
    public MainWindow()
    {
        InitializeComponent();
        bmp.FromResource("Image\\Tulips.jpg");
    }
and this is the XAML code:

<Window x:Class="Test45.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="900" Width="1366">
<Grid>
    <Button Content="Button" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Width="75" Click="Button_Click_1"/>
    <Image HorizontalAlignment="Left" Height="768" Margin="90,10,0,0" VerticalAlignment="Top" Width="1024"/>

</Grid>
</Window>

What's going on?

Thanks a lot.

Jymmy097

EDIT: I tried to add Tulips.jpg to one of the sample project and to load it using FromResource method.
This Window appeared:
http://snap.ashampoo.com/sGDY16Ai
It tells me to Find the origin of WriteableBitmapConvertExtensions.cs.
And If I do that, it tells me that Imust use BeginInit and EndInit or something similar because he couldn't find BitmapSource.

EDIT2:
I used this code:

bmp = BitmapFactory.New(1, 1).FromResource("Image\Tulips.jpg");

instead of this:

bmp.FromResource("Image\Tulips.jpg");

it tells me "Missing origin informations into debug informations for this module".
Found the solution in the samples. Here is how they do it:
WriteableBitmap LoadBitmap(string path)
      {
         var img = new BitmapImage();
         img.BeginInit();
         img.CreateOptions = BitmapCreateOptions.None;
         var s = Application.GetResourceStream(new Uri(path, UriKind.Relative)).Stream;
         img.StreamSource = s;
         img.EndInit();
         return BitmapFactory.ConvertToPbgra32Format(img);
      }
Jul 18, 2013 at 10:36 AM
Edited Jul 18, 2013 at 6:27 PM
Thanks a lot for the solution. I haven't found it...
I'll test it as soon as I can.

Bye.

Jymmy097

EDIT: Didn't work for me. desperate times call for desperate measures (translated with Google translator, so I'm not sure that the translation is correct): can you upload the solution you used in a Dropbox space for example and post here the public link? I need that. Thanks a lot!!!!!!!
Jul 21, 2013 at 10:26 AM
IT WORKS!!!!!!

I used the code from smiron86 to access the image (I modified the function: now it requests an URI) and I enabled CLR exception from Debug -> Exception -> Enable ALL CLR Exception.

And now... IT WORKS!!

Thanks a lot for your support!

Jymmy097