I want to upload a photo from my phone to azure blob.
Im using this link
http://www.windowsazure.com/en-us/develop/mobile/tutorials/upload-images-to-storage-wp8/
there is no error or a exception, it just i cant see it and i know the binding is correct,
even when i open the link of the image, there is no photo found.
there is a question similar to this one here
Upload image to Azure blob storage from Windows Phone. Not creating
This is what I'm doing
PhotoChooserTask chooser;
protected override void OnNavigatedTo(NavigationEventArgs e)
{
Refresh();
base.OnNavigatedTo(e);
}
private void PhotoChooserBtn_Click(object sender, RoutedEventArgs e)
{
chooser = new PhotoChooserTask();
chooser.Completed += chooser_Completed;
chooser.Show();
}
Stream stream = null;
void chooser_Completed(object sender, PhotoResult e)
{
stream = e.ChosenPhoto;
BitmapImage sourceImg = new BitmapImage();
sourceImg.SetSource(stream);
ProfileImage.Source = sourceImg;
}
async private void SaveBtn_Click(object sender, RoutedEventArgs e)
{
Images images = new Images() { Username = "7elbeh" };
InsertImage(images);
}
private void RefreshBtn_Click(object sender, RoutedEventArgs e)
{
Refresh();
}
please help.
I have the same error, to solve i convert my Stream to array and use UploadFromByteArrayAsync
byte[] array = imageStream.ToArray();
await blobFromSASCredential.UploadFromByteArrayAsync(array, 0, array.Length);
Related
I'm in making barcode scanner but "VideoCaptureDevice can't pick up any objects" ?
I'm using AForge video and ZXing in visual studio 2019 C#
I want it to be able to scan barcodes from my laptop webcam.
I tried running it with the problem but in my combobox where are supposed to be cameras available for use but they are none. I even tried activating the webcam before opening up the program.
code:
FilterInfoCollection FilterInfoCollection;
VideoCaptureDevice VideoCaptureDevice;
private void Form1_Load(object sender, EventArgs e)
{
FilterInfoCollection = new FilterInfoCollection(FilterCategory.VideoInputDevice);
foreach (FilterInfo device in FilterInfoCollection)
comboBox1.Items.Add(device.Name);
comboBox1.SelectedIndex = 0;
}
private void button1_Click(object sender, EventArgs e)
{
VideoCaptureDevice = new VideoCaptureDevice(FilterInfoCollection[comboBox1.SelectedIndex].MonikerString);
VideoCaptureDevice.NewFrame += VideoCaptureDevice_NewFrame;
VideoCaptureDevice.Start();
}
private void VideoCaptureDevice_NewFrame(object sender, NewFrameEventArgs eventArgs)
{
Bitmap bitmap = (Bitmap)eventArgs.Frame.Clone();
BarcodeReader reader = new BarcodeReader();
var result = reader.Decode(bitmap);
if (result != null)
{
textBox1.Invoke(new MethodInvoker(delegate ()
{
textBox1.Text = result.ToString();
}));
}
pictureBox1.Image = bitmap;
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
if (VideoCaptureDevice != null)
{
if (VideoCaptureDevice.IsRunning)
VideoCaptureDevice.Stop();
}
}
}
}
I have managed to pick an image from the phones library and display it. this is the code. Question is how do i Insert this image into my Sqlite database of contacts and retrieve it and display it again after getting the image? Here is my code. A detailed step by step instruction would be appreciated from here.
namespace Mobile_Life.Pages
{
public sealed partial class NextOFKin_Update_Delete : Page
{
int Selected_ContactId = 0;
DatabaseHelperClass Db_Helper = new DatabaseHelperClass();
Contacts currentcontact = new Contacts();
CoreApplicationView view;
public NextOFKin_Update_Delete()
{
this.InitializeComponent();
HardwareButtons.BackPressed += HardwareButtons_BackPressed;
view = CoreApplication.GetCurrentView();
}
private void HardwareButtons_BackPressed(object sender, BackPressedEventArgs e)
{
if (Frame.CanGoBack)
{
e.Handled = true;
Frame.GoBack();
}
}
protected override async void OnNavigatedTo(NavigationEventArgs e)
{
await StatusBar.GetForCurrentView().ShowAsync();
Selected_ContactId = int.Parse(e.Parameter.ToString());
currentcontact = Db_Helper.ReadContact(Selected_ContactId);//Read selected DB contact
namestxt.Text = currentcontact.Name;//get contact Name
relationtxt.Text = currentcontact.Relation;//get contact relation
phonetxt.Text = currentcontact.PhoneNumber;//get contact PhoneNumber
}
private void Update_click(object sender, RoutedEventArgs e)
{
currentcontact.Name = namestxt.Text;
currentcontact.Relation = relationtxt.Text;
currentcontact.PhoneNumber = phonetxt.Text;
Db_Helper.UpdateContact(currentcontact);//Update selected DB contact Id
Frame.Navigate(typeof(NextOfKin));
}
private void Delete_click(object sender, RoutedEventArgs e)
{
Db_Helper.DeleteContact(Selected_ContactId);//Delete selected DB contact Id.
Frame.Navigate(typeof(NextOfKin));
}
private void profile_img(object sender, TappedRoutedEventArgs e)
{
FileOpenPicker filePicker = new FileOpenPicker();
filePicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
filePicker.ViewMode = PickerViewMode.Thumbnail;
// Filter to include a sample subset of file types
filePicker.FileTypeFilter.Clear();
filePicker.FileTypeFilter.Add(".bmp");
filePicker.FileTypeFilter.Add(".png");
filePicker.FileTypeFilter.Add(".jpeg");
filePicker.FileTypeFilter.Add(".jpg");
filePicker.PickSingleFileAndContinue();
view.Activated += viewActivated;
}
private async void viewActivated(CoreApplicationView sender, IActivatedEventArgs args1)
{
FileOpenPickerContinuationEventArgs args = args1 as FileOpenPickerContinuationEventArgs;
if (args != null)
{
if (args.Files.Count == 0) return;
view.Activated -= viewActivated;
StorageFile storageFile = args.Files[0];
var stream = await storageFile.OpenAsync(FileAccessMode.Read);
var bitmapImage = new BitmapImage();
await bitmapImage.SetSourceAsync(stream);
var decoder = await Windows.Graphics.Imaging.BitmapDecoder.CreateAsync(stream);
profile.ImageSource = bitmapImage;
}
}
}
The best way would be NOT to store the image in SQLite. Just copy it to your ApplicationData.Current.LocalFolder and save the path.
If you really want to store the BitmapImage in SQLite, just convert it to byte array: Convert a bitmapimage to byte[] array for storage in sqlite database
how can i make a snapshot in my cod:
using DirectX.Capture;
using DShowNET;
private void Form1_Shown(object sender, EventArgs e)
{
DirectX.Capture.Capture capture = null;
Filters filters = null;
capture = new DirectX.Capture.Capture(filters.VideoInputDevices[deviceNo], filters.AudioInputDevices[0]);
capture.PreviewWindow = pictureBox1;
}
private void _Pause_Click(object sender, EventArgs e)
{
//??
}
i want to convert pictureBox1's video stream to a image by clicking on "Pause" button.
and then save pictureBox1's pic(*.jpg) to data base.
I am trying to play different video files continuously on VLC player on my Winform application.
The problem I face is between different playlist videos there is a 1-2 seconds of black screen.
How can I play all videos in my playlist smoothly without any waiting?
private void buttonLoad_Click(object sender, EventArgs e)
{
var uri = new Uri(#"C:\Users\Val\Downloads\000013.ts");
var converted = uri.AbsoluteUri;
var uri2 = new Uri(#"C:\Users\Val\Downloads\000210.ts");
var converted2 = uri2.AbsoluteUri;
axVLCPlugin21.playlist.add(converted);
axVLCPlugin21.playlist.add(converted2);
}
private void buttonStart_Click(object sender, EventArgs e)
{
axVLCPlugin21.MediaPlayerEndReached += new EventHandler(OnTimedEvent);
axVLCPlugin21.playlist.playItem(0);
}
private void OnTimedEvent(object sender, EventArgs e)
{
axVLCPlugin21.playlist.playItem(1);
}
this is a simplified version of what I am trying to do.
When the player reaches end of the first video file it starts the second on by eventhandler function.
The best way I know to play videos seamlessly is to avoid the timed event in your example:
private void buttonLoad_Click(object sender, EventArgs e)
{
var uri = new Uri(#"C:\Users\Val\Downloads\000013.ts");
var converted = uri.AbsoluteUri;
var uri2 = new Uri(#"C:\Users\Val\Downloads\000210.ts");
var converted2 = uri2.AbsoluteUri;
axVLCPlugin21.playlist.add(converted);
axVLCPlugin21.playlist.add(converted2);
}
private void buttonStart_Click(object sender, EventArgs e)
{
axVLCPlugin21.playlist.play();
}
I'm trying to preview and print multiple page TIFF files from a C# 2005 Windows application. Printing works fine but when I send my PrintDocument to a PrintPreviewDialog I get two images of the first page rather than an ameage of the first and second page. I also have the same problem when I use PrintPreviewControl.
Below is code for a form with 2 buttons, a PrintDocument and a PrintPreviewDialog that demonstrates the problem.
public partial class Form1 : Form
{
private Image m_Image;
private Int32 m_CurrentPage;
private Int32 m_PageCount;
private void Form1_Load(object sender, EventArgs e)
{
m_Image = Image.FromFile(".\\Test-2-Page-Image.tif");
m_PageCount = m_Image.GetFrameCount(FrameDimension.Page);
}
private void printDocument_BeginPrint(object sender, PrintEventArgs e)
{
m_CurrentPage = 0;
m_PageCount = m_Image.GetFrameCount(FrameDimension.Page);
}
private void printDocument_PrintPage(object sender, PrintPageEventArgs e)
{
m_Image.SelectActiveFrame(FrameDimension.Page, m_CurrentPage);
e.Graphics.DrawImage(m_Image, 0, 0);
++m_CurrentPage;
e.HasMorePages = (m_CurrentPage < m_PageCount);
}
private void btnPreview_Click(object sender, EventArgs e)
{
printPreviewDialog.Document = printDocument;
printPreviewDialog.ShowDialog();
}
private void btnPrint_Click(object sender, EventArgs e)
{
printDocument.Print();
}
}
Does anyone know if there is there a problem with the PrintPreviewDialog in the .Net framework or am I doing something wrong.
It's a bug with the Graphics.DrawImage() function.
The problem is documented here: Graphics.DrawImage Bug
The working code looks like this:
img.SelectActiveFrame(FrameDimension.Page, curPage);
using(MemoryStream stm = new MemoryStream())
{
img.Save(stm, imgCodecInfo, encParams); // save to memory stream
Bitmap bmp = (Bitmap)Image.FromStream(stm);
e.Graphics.DrawImage((Image)bmp,0,0);
bmp.Dispose();
}