I want to preload a lot of images when my app starts up, sort of a once off thing.
I have an Image class that contains the Url of its image stored in the cloud as blob storage (this address is a https address BTW)
I want to download the image bytes from the cloud, store them on the object, then when it comes time to show the image, load the image from its bytes.
I have all the code for this, but I keep getting the exception:
No imaging component suitable to complete this operation was found.
Here is my code: EDIT UPDATED WITH A FIX
//Loaded on start-up
private static void LoadImageBytes(Image img)
{
var urlUri = new Uri(img.Url);
var request = (HttpWebRequest)WebRequest.CreateDefault(urlUri);
MemoryStream memStream = new MemoryStream();
using (var response = request.GetResponse())
{
var buffer = new byte[4096];
using (var stream = response.GetResponseStream())
{
int bytesRead = stream.Read(buffer, 0, buffer.Length);
while (bytesRead > 0)
{
memStream.Write(buffer, 0, bytesRead);
bytesRead = stream.Read(buffer, 0, buffer.Length);
}
img.ImageBytes = memStream.ToArray();
}
}
}
Then when I want to get the image on the screen I call this:
public BitmapImage ImageFromBuffer(Byte[] bytes)
{
MemoryStream stream = new MemoryStream(bytes);
stream.Seek(0, SeekOrigin.Begin);
BitmapImage image = new BitmapImage();
image.BeginInit();
image.StreamSource = stream;
image.EndInit();
return image;
}
But in the EndInit() call I get the exception.
I have done some testing and if I load the file from my local filesystem, I get a different set of bytes to that of the image in the cloud. I assume its something to do with blob storage or https?
And yes I can browse to that image and its not corrupted.
EDIT, fixed now all good
Are you sure this line is correct?
while (stream.Read(buffer, 0, buffer.Length) > 0)
img.ImageBytes = buffer;
img.ImageBytes will hold the last read buffer.
Related
I have a very strange issue. I am converting Image to base64string in an asp.net web API hosted in Azure app service and getting the wrong image string.
If I run the code in the local machine I am getting the correct value.
public static string GetImageFromSharePointOnline(string imageUrl)
{
try
{
using (var clientContext = CreateContext(URL))
{
clientContext.ExecutingWebRequest += ExecutingWebRequest;
FileInformation fileInformation = null;
Stream returnStream = new MemoryStream();
int readCount;
var buffer = new byte[8192];
Uri image = new Uri(imageUrl);
try
{
fileInformation = Microsoft.SharePoint.Client.File.OpenBinaryDirect(clientContext, image.AbsolutePath);
while ((readCount = fileInformation.Stream.Read(buffer, 0, buffer.Length)) != 0)
{
returnStream.Write(buffer, 0, readCount);
}
}
catch (Exception ex) { }
returnStream.Seek(0, SeekOrigin.Begin);
return "data:image/" + GetFileExtensionFromUrl(imageUrl) + ";base64," + Convert.ToBase64String(buffer);
// return Convert.ToBase64String(buffer);
}
}
catch (Exception ex) { }
}
Azure web api output:
data:image/jpg;base64,VHdEqK7rHUHQQ0VMQUMN/T0MMGKzMFUEsTYAdpNTJgXxeGxYh+qoll/MSfCD7AOvxrk3738OrTjPyJZGHi5kcUcsCBYkCJtAUgdeq27da89em0/L0vPW/gt8zw0mAwkS74zmwY9Qe411c+31+rm6cvlx47jzly7b7I1F5Htew9g7Seyt79PmZZ05/VwYcPjsGFlKY6NtIJMgDk2N9d37AK49u21/Lq15axZy+Jw893kmiAlc38xPC1/h1+NTXrtqu3LWlfkeKmwcnypPEp1jfsYV26dJtMuTfn81Pi8ZHzYw6hl8R2sLjRSelTrtjW4OeudjNiQwwlimPDudStzGh0PXs7tK4r02v5dk0k/ClzeBiR8a8iQojqy2ZVCnU27K9eXTa7ea8uvOTXwXY495AAuToAK68ubA/h8Xjwgb0WWX8zMAyj2AHT41x9O1vr06tOMnsWjF4DAUUoWDG4vewsBbpavH6r1xFHkvTsE0LS4sYjnUX2Lor+y3QHutXtz7WXFeXTjLMwtCMEV2uREx0EGSiObJVHJloLES1BajSoqwkQorssNTK4SEIpkws4MC+fv/AOGCw9/QH4E3ry67ftenKfuEooq4nWtxRjs7NKDXKYS5HF5MTC942K+xlF1+8VdLim0zAH0/D/04PbWSQ3PeFAA+y5r17Xy8uU8DUUVhuPQak14vVbgjDKrDVWAIPeDrSrA71Xio3GpKR4opBY+xtCPwr14Xy8u0zATh4wcuM+xv6TXR0v7a8Oc/dDLFDpf7q4nYq+o4h/k7gGxLJcnQC7jtrfK/uY6TwWuGVGzI97W2ncBYm5AuOntrp3viufWeTNFFXG6lmEx+cYf8QKHI9hJH7KC/FFUaIeaqLyOWiiy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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
Can anyone help me with this please.
You're initializing a MemoryStream:
Stream returnStream = new MemoryStream();
(should be var returnStream = new MemoryStream();)
as the container for the bytes read from a Stream.
The Image bytes are read from the source Stream using a buffer:
var buffer = new byte[8192];
which is ok for a NetworkStream.
Assuming Uri image = new Uri(imageUrl); represents the same object in both environments, you the read a [buffer] number of bytes (which is the maximum value, the actual bytes read may be less than that) and write the bytes read - the value is stored in the readCount variable - to the MemoryStream:
try
{
fileInformation = Microsoft.SharePoint.Client.File.OpenBinaryDirect(clientContext, image.AbsolutePath);
while ((readCount = fileInformation.Stream.Read(buffer, 0, buffer.Length)) != 0)
{
returnStream.Write(buffer, 0, readCount);
}
}
When the source Stream is read to end, the MemoryStream contains the Image bytes.
At this point, you want to convert the Image bytes to a Base64String.
Of course, you need to convert the content of your MemoryStream, returnStream, not the buffer content, which is only used as a temporary container for the bytes coming from the source Stream. So just change:
Convert.ToBase64String(buffer);
to:
Convert.ToBase64String(returnStream.ToArray());
Setting returnStream.Position = 0 before calling returnStream.ToArray() is not necessary in this context, but it doesn't hurt either.
Side note: those empty catch blocks don't serve you well. Either add logging features or remove.
I created local server, that should get image files as binary data and save them back as images in hard drive.
Socket mySocket = myListener.AcceptSocket();
#region Connection Check
if (mySocket.Connected)
{
============
/* Some Code For Displaying Information*/
============
byte[] data = new byte[mySocket.ReceiveBufferSize];
int i = mySocket.Receive(data, data.Length, 0);
byteArrayToImage(data);
mySocket.Close();
}
byteArrayToImage method Converts byte Array to Image file and saves on hard drive, here's the code
public void byteArrayToImage(Byte[] data)
{
MemoryStream ms = new MemoryStream(data);
Image img = Image.FromStream(ms);
img.Save(#"C:\MyPersonalwebServer\ImageData\img.png", ImageFormat.Png);
}
but I get ArgumentException here: Image img = Image.FromStream(ms)
Here is part of data array: http://s43.radikal.ru/i101/1403/78/1913ab884790.png
Any ideas how to fix it?
Thanks in advance.
The following code works for me:
var buffer = new byte[256];
FileStream fs = new FileStream(#"D:\test.png", FileMode.Open);
var ms = new MemoryStream();
int readCtr;
while ((readCtr = fs.Read(buffer, 0, buffer.Length)) > 0)
{
ms.Write(buffer, 0, readCtr);
}
Image img = Image.FromStream(ms);
img.Save(#"D:\test2.png", ImageFormat.Png);
Are you sure that the data you are sending from the client connection is complete/clean?
Make sure the data you are sending from the client isn't appending null bytes when performing Socket.Send(), or try clean it up server-side by stripping any null bytes from the end of the byte array:
buffer = buffer.Where(x => x != (byte)0).ToArray();
You could also check the size of the image manually against the content received server-side using standard debug practices/console output.
Either way, I dont think your code would be failing if the byte array had valid content.
I am asynchronously downloading images from one web site.And I want to save list of images into IsolatedStorage. And stream is not serializable, so I have to convert it to byte array. But it is not reading Stream in while loop in ReadFully() method.
Here is how I am trying to download images:
HttpWebRequest request = HttpWebRequest.Create(uri) as HttpWebRequest;
request.Headers["Referer"] = "http://www.website.com";
request.BeginGetResponse((result) =>
{
Stream imageStream = request.EndGetResponse(result).GetResponseStream();
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
// Set stream as the source of image
BitmapImage bitmapImage = new BitmapImage();
bitmapImage.CreateOptions = BitmapCreateOptions.BackgroundCreation;
bitmapImage.SetSource(imageStream);
image.Source = bitmapImage;
// Convert stream to byte array and save in the custom list with the uri of the image
ls.Add(new DownloadedImages() { Image = ReadFully(imageStream), URI = uri });
ds.SaveMyData(ls, "BSCImages");
});
}, null);
And here is the method for converting stream to byte array:
public static byte[] ReadFully(Stream input)
{
byte[] buffer = new byte[input.Length];
using (MemoryStream ms = new MemoryStream())
{
int read;
while ((read = input.Read(buffer, 0, buffer.Length)) > 0)
{
ms.Write(buffer, 0, read);
}
return ms.ToArray();
}
}
Update:
It is not getting inside the while loop. So the byte array is always empty.
Because you are consuming the stream imageStream in creating bitmapImage before passing to ReadFully.
First get the byte[], then use it to form the image and to pass to new DownloadedImages()
I am trying to convert bitmap Image to Byte array. I have select all the image by using MediaLibrary class and added it into a list of bitmap images. Here is my code
using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication())
{
if (!store.DirectoryExists("ImagesZipFolder"))
{
store.CreateDirectory("ImagesZipFolder");
for (int i = 0; i < imgname.Count(); i++)
{
using (IsolatedStorageFileStream stream = new IsolatedStorageFileStream(#"ImagesZipFolder\" + imgname[i], System.IO.FileMode.CreateNew, store))
{
byte[] bytes = null;
using (MemoryStream ms = new MemoryStream())
{
WriteableBitmap wBitmap = new WriteableBitmap(ImgCollection[i]);
wBitmap.SaveJpeg(ms, wBitmap.PixelWidth, wBitmap.PixelHeight, 0, 100);
stream.Seek(0, SeekOrigin.Begin);
bytes = ms.GetBuffer();
stream.Write(bytes, 0, bytes.Length);
}
// byte[] bytes = Encoding.UTF8.GetBytes(imgname[i]);//new byte[ImgCollection[i].PixelWidth * ImgCollection[i].PixelHeight * 4];
// stream.Write(bytes, 0, bytes.Length);
}
}
}
else {
directory = true;
}
}
Basically what I am trying to do is, selecting all images or photo from device and create a zip file of that images. I was successful in creating a zip file of images. When I extract that file there is some images, but the problem is when I double click on image, I can't see that image. I think the problem is in reading the bytes of image. I am not getting what's wrong? Is my code is correct ?
Perhaps you can try the below. I know this code maintains the image, so if you have no luck using this, you may have a different issue.
// Convert the new image to a byte[]
ImageConverter converter = new ImageConverter();
byte[] newBA = (byte[])converter.ConvertTo(newImage, typeof(byte[]));
The ImageConverter is of the System.Drawing namespace.
Update:
http://msdn.microsoft.com/en-GB/library/system.windows.media.imagesourceconverter.convertto.aspx
You should be able to use this in place of the System.Drawing type I suggested.
There is no need to save the WriteableBitmap to a MemoryStream and then copy it to an IsolatedStorageFileStream. Just save the bitmap directly to the IsolatedStorageFileStream.
using (IsolatedStorageFileStream stream = new IsolatedStorageFileStream(#"ImagesZipFolder\" + imgname[i], System.IO.FileMode.CreateNew, store))
{
WriteableBitmap wBitmap = new WriteableBitmap(ImgCollection[i]);
wBitmap.SaveJpeg(stream, wBitmap.PixelWidth, wBitmap.PixelHeight, 0, 100);
}
This will allow you to save on memory as well. If you really want to save memory, you could reuse the WriteableBitmap.
I have a Samsung IP camera and I want to stream it in to my c# program, but when I run the program I got 'invalid parameter' error.
private void button1_Click(object sender, EventArgs e) { while (true) {
string sourceURL = url; byte[] buffer = new byte[100000];
int read, total = 0;
// create HTTP request
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(sourceURL);
req.Credentials = new NetworkCredential("admin", "4321");
// get response
WebResponse resp = req.GetResponse();
// get response stream
Stream stream = resp.GetResponseStream();
// read data from stream
while ((read = stream.Read(buffer, total, 1000)) != 0)
{
total += read;
}
Bitmap bmp = (Bitmap)Bitmap.FromStream(new MemoryStream(buffer, 0, total));
pictureBox1.Image = bmp;
}
}
What might be the problem?
You are not building the correct buffer, you are overriding the old buffer with new buffer each time while there is new data, idea to fix it:
List<byte> fullData = new List<Byte>();
while ((read = stream.Read(buffer, 0, buffer.Length)) > 0)//also > 0 not == 0 because of it can be -1
{
fullData.AddRange(new List<Byte>(buffer).GetRange(0, read));//only add the actual data read
}
byte[] dataRead = fullData.ToArray();
Bitmap bmp = (Bitmap)Bitmap.FromStream(new MemoryStream(dataRead , 0, dataRead.Lenght));
My guess (since you don't indicate the error) is that the image has gone over 100,000 bytes, which your code doesn't handle at all. I would, instead:
byte[] buffer = new byte[10 * 1024];
...
using(var ms = new MemoryStream())
{
// read everything in the stream into ms
while ((read = stream.Read(buffer, 0, buffer.Length)) > 0)
{
ms.Write(buffer, 0, read);
}
// rewind and load the bitmap
ms.Position = 0;
Bitmap bmp = (Bitmap)Bitmap.FromStream(ms);
pictureBox1.Image = bmp;
}
kinda late answer relative to the time of the question; however, since I'm hunting down similar issues and this has apparently not been answered, I'm adding my two cents...
There are two issues here as I see it:
First:
You don't wanna put the event handler of a button-click into an endless loop. This should probably be a thread of some type so that the event handler can return.
Second:
As mentioned in another comment, your code is expecting the response to be a raw image of some type, and most likely it is not. Your camera may eventually send MJPG, but that doesn't mean it comes raw. Sometimes you have to send other commands to the camera and then when you actually start getting the MJPG stream you have to parse it and extract headers prior to sending the portion of the image to some picturebox. You're probably getting some kind of html response from the camera (as I am) and when you try to pass that data to a method that is expecting the data to be some image format (likely JPEG), then you get the invalid parameter error.
Can't say I know how to solve the problem cause it depends on the camera. If there is some kind of standard interface for these cameras I'd sure like to know what it is! Anyway, HTH...