hello guys !!
i would like some help about how to convert an image to memory stream or whatever and send it to a web service. The image is already captured from wp7 camera.
Thanking you in advance.
Adamos
image convertion and sending
Page 1 of 18 Replies - 3077 Views - Last Post: 03 April 2011 - 03:16 PM
Replies To: image convertion and sending
#2
Re: image convertion and sending
Posted 02 April 2011 - 08:19 AM
Which part do you need help with? Converting the image or sending it to a web service?
#3
Re: image convertion and sending
Posted 02 April 2011 - 08:29 AM
I ve great issues how to convert it. bmp.Save() and many other solutions are not supported on WP7. About sending it i think so am okay i ve made the method but okay am not sure if its working because i dont have the byte array to send it!! and check it!!
#4
Re: image convertion and sending
Posted 02 April 2011 - 10:07 AM
You will need to handle the Completed event for the Camera task.
So once you are handling that event, you can get the picture that was taken..
That should work for you.
So once you are handling that event, you can get the picture that was taken..
private void CameraCompleted(object sender, PhotoResult e)
{
if (e.TaskResult == TaskResult.OK)
{
// the 300,300 are just test dimensions. You may need
// to change these
WriteableBitmap picture = new WriteableBitmap(300,300);
picture.LoadJpeg(e.ChosenPhoto);
byte[] pictureByteArray = picture.ToByteArray();
// send the byte array to your web service
}
}
That should work for you.
#5
Re: image convertion and sending
Posted 02 April 2011 - 12:17 PM
Thanks for the code but i ve got an error.
Error 2 'System.Windows.Media.Imaging.WriteableBitmap' does not contain a definition for 'ToByteArray' and no extension method 'ToByteArray' accepting a first argument of type 'System.Windows.Media.Imaging.WriteableBitmap' could be found (are you missing a using directive or an assembly reference?)
Error 2 'System.Windows.Media.Imaging.WriteableBitmap' does not contain a definition for 'ToByteArray' and no extension method 'ToByteArray' accepting a first argument of type 'System.Windows.Media.Imaging.WriteableBitmap' could be found (are you missing a using directive or an assembly reference?)
#6
Re: image convertion and sending
Posted 03 April 2011 - 01:17 AM
I find an implementation which almost works.
Then i call it using
but now i have a problem with static
ERROR:
Error 1 Extension method must be defined in a non-generic static class
public static byte[] ConvertToBytes(this BitmapImage bitmapImage)
{
using (MemoryStream ms = new MemoryStream())
{
WriteableBitmap btmMap = new WriteableBitmap
(bitmapImage.PixelWidth, bitmapImage.PixelHeight);
// write an image into the stream
Extensions.SaveJpeg(btmMap, ms, bitmapImage.PixelWidth, bitmapImage.PixelHeight, 0, 100);
return ms.ToArray();
}
}
Then i call it using
byte[] pictureByteArray = ConvertToBytes(bmp);
but now i have a problem with static
ERROR:
Error 1 Extension method must be defined in a non-generic static class
This post has been edited by fiftycy: 03 April 2011 - 01:18 AM
#7
Re: image convertion and sending
Posted 03 April 2011 - 06:18 AM
#8
Re: image convertion and sending
Posted 03 April 2011 - 11:30 AM
Thank you a lot but i find the solution!!!
First i ve create a static class and i put the method.
and the i call it at the phone application class
First i ve create a static class and i put the method.
public static class Convertion
{
public static byte[] ConvertToBytes(this BitmapImage bitmapImage)
{
using (MemoryStream ms = new MemoryStream())
{
WriteableBitmap btmMap = new WriteableBitmap
(bitmapImage.PixelWidth, bitmapImage.PixelHeight);
// write an image into the stream
Extensions.SaveJpeg(btmMap, ms, bitmapImage.PixelWidth, bitmapImage.PixelHeight, 0, 100);
return ms.ToArray();
}
}
}
and the i call it at the phone application class
uppicbyte = Face.Convertion.ConvertToBytes(bmp);
Page 1 of 1
|
|

New Topic/Question
Reply


MultiQuote




|