For my final project in school ( even though I'm not a programmer ) I have to make a program that reads barcodes. I have to use Common Vision Blox.
I got a live feedback from the camera and I'm able to snap it.
But I want to save this picture now, I tried using this method (Saving image to file), but there seems to be a fault. Probably because I don't actually know which reference to use. I'll add my program in pictures.
I would like to save the snap in JPEG or something, so that I call it further in the program to start the barcode recognition.
Hope you guys can help, thanks in advance!
The solution is actually quite simple: The object axCVimage1 has a method Save() and a method SaveImageByDialog(). Use whatever method suits your needs. For saving the current image to a jpg file, simply provide a file name that has the extension 'jpg'. If you need control over the compression ratio and quality, use the the method SaveLossyImage() instead.
Related
I've got some C# code in Unity that grabs a large image from my Android Device's filesystem, and now with it I want to use it to create a small thumbnail image.
I've found lots of different suggestions for how to do this such as the following:
MemoryStream outputStream = new MemoryStream();
System.Drawing.Image image = System.Drawing.Image.FromFile(originalImagePath);
System.Drawing.Image thumbnail = image.GetThumbnailImage(thumbnailWidth, thumbnailHeight,()=>false, IntPtr.Zero);
thumbnail.Save(outputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
return outputStream;
However, as with the above method, all of the methods I've found require you to use the System.Drawing namespace. And I can't for the life of me get the functions in this namespace to work on Android, because even after adding "System.Drawing.dll" into the Assets folder, I get an error saying that it can't locate "gdiplus.dll" on construction of "System.Drawing.Image". I tried downloading and adding said "gdiplus.dll" to Assets, but I just get the same error as if it can't find it!
I don't understand why its so hard to get the System.Drawing functions working in Unity, but that's somewhat besides the point, as all I really want to do is create a thumbnail of an image that lives on the user's Android Device. Any suggestions would be welcome!
EDIT: I forgot to mention that I'd like to avoid solutions that use Texture2D's because they can't be run off the main thread, and hence come with performance consequences =(
Thanks in advance! =)
Don't use Texture2D.Resize, because the resulting texture will become grey:
After resizing, texture pixels will be undefined.
See this post for other solutions.
Old answer
I recommend use an opensource C# image processing library, such as ImageSharp or search it on GitHub.
The last solution is to write one yourself, if the performance or size of a 3rd-party library is still not good enough.
Here are two ideas I can come up with:
split the possibly lengthy reading and resizing procedure into several Coroutines.
use multi-thread
You may also try calling java functions from Unity3D. But I'm not familiar with that.
I'm working on a video player project (or something like that), that can play .avi files.
I wanted to improve it with something "special", so I put a "Take snapshot" button (btnSnapshot) under the playback area, which is a Picture Box (picboxPlayback).
I'm using DirectX.AudioVideoPlayback, and the video file's owner is this Picture Box:
Microsoft.DirectX.AudioVideoPlayback.Video myVideo = new Microsoft.DirectX.AudioVideoPlayback.Video(SelectedVideoPath);
myVideo.Owner = picboxPlayback;
Then I've tried to write the code that takes the snapshot from the current frame and saves it to a JPEG image to a user-defined path, but I've stuck when I realized that "Video" does not have any "TakeSnapshot" or such methods.
I looked on internet for a quick and simple solution, but did'nt find anything, or what I found was so complicated that I did'nt understand it. (probably because I'm too beginner to DirectX)
I don't know if there's even a quick and simple way to do this, but I would be very grateful if you could help me. :)
I'm developing a Windows 8 Store App, I have this problem,
I want the user to add the videos from a file picker and i managed it,
the problem is I want to display the videos images in a GridView,
like snap shot of the video in a certain position, i tried the media element and it's not working
also an image and it doesn't make sense.
There might not be a pure C# solution to this problem. Perhaps SharpDX would let you do that, but I haven't tried and I don't know if it was done before. If you look at these two threads:
http://social.msdn.microsoft.com/Forums/fil-PH/wingameswithdirectx/thread/05731d4f-5b7f-4ed1-8e28-94604655139e
http://social.msdn.microsoft.com/Forums/en/wingameswithdirectx/thread/ffacd05c-6e9e-43bf-b691-99127240730c
-- you should see that there is a TransferVideoFrame method you can use to copy a frame from a video stream to a DirectX texture. The Media engine native C++ video playback sample shows how you can use it natively. If you search for TransferVideoFrame+SharpDX - you can find this sample that uses the SharpDX version of this method in C#. After you transfer that frame to a texture - you can either copy the contents of the texture to a WriteableBitmap using the Map and Unmap methods like here. You can also save it to a file either using BitmapEncoder a here or directly from the DirectX texture to a file using WIC or say SharpDX Toolkit as in here. You will probably want to build a cache of thumbnails to avoid having to process the videos every time you display the list, so saving to a file is something you should do anyway.
Your own solution that you quoted elsewhere that should work for at least some videos:
var thumb = await
storageFile.GetThumbnailAsync(
Windows.Storage.FileProperties.ThumbnailMode.PicturesView,
1000,
Windows.Storage.FileProperties.ThumbnailOptions.UseCurrentScale);
I suggest using GetThumbnailAsync(), which works just as well. You don't even need to get the video properties or anything like that. If the StorageFile is loaded, this should work for a normal video of any format.
I was hoping to get some guidance on a project that I'm not even sure can work. I want to write an application in C# that allows me to type with my keyboard, but what shows up on the screen is a specific image from an image bank. So, I'll have a few images stored, and I'd like to map each keystroke from my keyboard to a stored image. Is something like this possible?
If not, is it possible to write some sort of library that I can import into MS Word, which would do something similar for me?
I created a new font with http://fontstruct.com . It's pretty straight forward to use. Once you've made your font, you can download it as a true type font, and install it to your computer.
Thanks for the help!
I have sucessfully inserted image to excel sheet.Now i should not allow the picture to be copied by anyone. how can i achieve this?
any idea.
thanks in advance.
You can't.
Of course, there are certain measures you could employ, but there are always ways around them. You could (somehow) disable copy & paste within Excel, but then the user could take a screenshot (Alt-PrtScn) and crop it in an image editor.
If you somehow disable the ability to take a screenshot, they may feed the monitor output of their machine to another machine with a screen grabber, and get the image that way.
Or, of course, accepting the loss of quality, they could point a camera at their screen and get it that way.
If your excel file is accessible by anyone, then you can't.
You can only shrink the images to low resolution or putting watermark on it.
Depending on your environment and audience (eg, an internal document in your company), Office IRM can prevent the document from being copied and even copied using print-screen.
Personally, I see these attempts as naive at best - the data can be easily copied anyway (for example by taking a photo of the screen), but it sends the right message to your colleagues.