I have a C# program that I need to embed an image into or perhaps better stated make the exe file portable such that the image will open on any computer and I need the image to open up in the default picture viewer (not a form PictureBox). I do have the image in the resource folder with 'Embed Resource'
System.Diagnostics.Process.Start = WindowsFormsApplication5.Properties.Resources.MyImage;
I realize the above code is invalid, but I am just a coding hobbyist, so I don't know everything. If I could get a little push in the right direction, I would appreciate it.
This might do the trick for you but If you want a Default Image Viewer to open a picture, you need to store that image to somewhere on your disk, thus the Image Viewer could find and open your picture.
var bitmap = new Bitmap(WindowsFormsApplication5.Properties.Resources.MyImage);
bitmap.Save("YourImageLocation");
Process.Start("YourIamgeLocation");
Related
I need the user to be able to upload an image, and then have the image be able to be accessed later for drawing it. I only know how to show an image in the Android Resources/drawable folder. I don't think it is possible for a user to upload an image there, so is there another place they can upload it, and then have the image to be used? I don't know how to have the user to be able to upload it either.
I only know how to show an image with the xaml code <Image Source="image.png"/>, where image.png is in the Android Resources/drawable folder
Since Resources contained in out raw directory of our project will be packaged inside our APK and will not be writeable at runtime.
So I highly recommend that you use Internal or External Data Storage to store your images and text file.
For more details, you can check: https://learn.microsoft.com/en-us/xamarin/android/platform/files/
And at the bottom of this page:External storage, there is a example which function is to save text file in External storage, it should be helpful for you.
The sample link is here: https://github.com/xamarin/monodroid-samples/tree/master/LocalFiles
If you want to choose Photos and Video, you can use MediaPlugin of jamesmontemagno. Of course , you can achieve this function yourself.
I have a WinForms app that takes a screenshot, and I want to be able to view this screenshot. Originally I was creating a new instance of a PreviewForm which contained nothing but a picturebox, but if the image being previewed was large, the screenshot is kind of useless.
I'm aware of defining a filepath and using Process.Start(), but this would require this screenshot being saved locally before opening.
Is there no equivalent method to open an image in image viewer from just a bitmap object?
I find it would be easier if you just saved it and opened it with a software. I tried to find many different ways to not save the file, but there aren't any unfortunately, so I have to save it and open with a tool like this: http://www.paintshoppro.com/en/pages/bmp-file/
I use a Flex app (SDK version 4.14.1) to take a photo from a camera on Android, and I pass the resulting ByteArray to an .net c# script that writes the image to a directory and sets the name etc.
I can see the file in the file system, I can open the file in the file system (with either a jpg or png extension, I believe that browsers can do this though), but when I add an Image control to Flex and point the source to the path of the image, I just get that annoying missing image icon.
I was guessing that it was to do with extensions, as the image is sent straight from the camera as a byte array I kind of had to guess the extension, but whatever it is can you help me solve it please?
For reference, the image is stored on an IIS web server, but it isn't cross domain policy that is stopping it because if I drag the image into my project and bind it directly it still does the same thing.
Ideally I need to use Image and not BitmapImage, but if it can't be helped then I can change.
Thanks
EDIT
Changing from Image to BitmapImage kind of worked, kind of because the image now shows in the desktop debugger, but on device it just shows blank. Any thoughts on this?
In the spirit of making sure all of my questions get an answer I am going to settle on the solution of using BitmapImage. Every other part of the design is correct, I cannot see anything I am doing wrong, and although using BitmapImage causes me an issue with missing image and placeholder image, it is a solution after all.
I have a problem with converting *.fig files (from Matlab) into bitmaps (or any type which I could use in pictureBox) using C#.
I need to read this file somehow and then show it in pictureBox.
I tried several ways, for example:
Image img = Image.FromFile(fileName);
Bitmap bmp1 = new Bitmap(img.Width, img.Height);
But I got an "Out of memory" exception thrown in the first step.
Do you have any ideas how to do it??
I have a proposal:
Instead of a picturebox, put a panel on your windows form. Then, use System.Diagnostics.Process to start the matlab viewer (required dependency for this, sorry).
Now, you can use the instructions here to get the windows handle for the main window of the viewer:
How to get main window handle from process id?
Next, change its parent to the panel in your windows form.
http://support.microsoft.com/kb/89563
I've used this trick before and it takes some tweaking, but you can capture another process's main window and make it a child control on your form. If you can find a less messy way of doing this, that would be great.
The out of memory exception also occurs when the image file is not in the correct format.
http://msdn.microsoft.com/en-us/library/stf701f5.aspx
It's likely you'll need to use some tool to change the .fig file into an image format. I'm not sure how Matlab saves .fig files, so you'll need to do some research as to how the file is actually stored, or find some third party software to update your file to a viable format.
How I can open the image saved in database directly using Internet Explorer (Not WebBrowser control in WinForm/WPF) without saving it to a file first?
I think this is not possible unless you create a web page or something similar to display the image from a temp file
Search for Process.Start look at the site...
MSDN
This gives you the exact example of opening a file in IE, you might need to save your image into a temp file on the disk