Hi KooKiz,
Thanks for your valuable information. As per your suggestion I tried this code:
| public partial class MainPage : PhoneApplicationPage |
| { |
| BitmapImage bitmap = new BitmapImage(); |
| public MainPage() |
| { |
| InitializeComponent(); |
| MediaLibrary library = new MediaLibrary(); |
| Picture picture = library.Pictures[0]; |
| bitmap.ImageOpened += new EventHandler<RoutedEventArgs>(imageTest_ImageOpened); |
| bitmap.SetSource(picture.GetThumbnail()); |
| int b = bitmap.PixelHeight; |
| b = bitmap.PixelWidth; |
| } |
| |
| void imageTest_ImageOpened(object sender, RoutedEventArgs e) |
| { |
| int b = bitmap.PixelHeight; |
| b = bitmap.PixelWidth; |
| WriteableBitmap _bitmap = new WriteableBitmap(bitmap); |
| } |
| } |
And I tried to debug in WP7 and WP7.1 and found few interesting things:
1.
WP7.1 :
a) bitmap.PixelHeight and Width is still set to
"0" and ImageOpened event not yet fired within constructor.
b) Can not create a WriteableBitmap using this bitmap in constructor.
WP7.0 :
a) bitmap.PixelHeight and Width is showing correct value my case "99" and ImageOpened event not yet fired within constructor.
b) Can create a WriteableBitmap using this bitmap in constructor.
2.
WP7.1 :
a)
ImageOpened event fired width/Height is visible as
"99" (in my case).
b) Can create a WriteableBitmap using this bitmap within event.
WP7.0 :
a)
ImageOpened event fired width/Height is visible as
"99" (in my case).
b) Can create a WriteableBitmap using this bitmap within event.
So,
YES, as you said we are able to see those properties after image is loaded.
But the problem is if you see use
case 1 where you can clearly see the difference and something which is missing in 7.1. The same thing works fine in 7.0 considering image is not being loaded yet.
However, it may be a temperary workaround to create a writeableBitmap when image loads. But still this may not be sufficient enough if I want to save multiple images at some location. Since images are being loaded asynchronously so I won't be knowing what name to assign them properly :-(
Thanks and Regards
Nishant Rana