Searching for a way to extract Shell Thumbnails for a windows application, I ran into this post and its very useful answer by AMissico:
C# get thumbnail from file via windows api
The sample project that solves the problem posted above can be downloaded here:
http://cid-7178d2c79ba0a7e3.office.live.com/self.aspx/.Public/ShellThumbnail.zip (I hope the original poster won't mind ...)
I've been able to modify the code posted by AMissico to keep the original aspect ratio of the images, but what I would like to do is offer a crop option, and mention the top-left point to start cropping from.
The sample project posted by AMissico uses the IExtractImage interface, with methods GetLocation and Extract. The GetLocation method accepts a size parameter, but I haven't found any way to add a starting point for the cropped image to it.
I would appreciate any help in doing this. Thanks!
I don't think there is a built-in way to obtain the thumbnail cropped. The size parameter is used for obtaining an image of a certain size (which can be the thumbnail image resized to that certain size or a completely different image for some ranges of the size parameter).
However, in the end, after obtaining the thumbnail image, why not crop that image right after obtaining and before first using it?
Related
I'm trying to compare an uploaded image with the image stored in my project's root file. I found many related work which is useful to compare images.
This link (https://www.c-sharpcorner.com/uploadfile/krishnasarala/compare-two-images-in-Asp-Net/) describe how to compare images.
I just want to compare with specific part. For example, I have an image in my root directory, the image is about government authorization stamp and signature and I want to check whether the uploaded image has same signature and stamp portion or not.
I value the help.
Mohammad.
You can use Bitmap to crop an image to your preferences. If you cannot access Bitmap with using System.Drawing dependency, follow this answer from another StackOverflow post.
Then you can crop using this algorithm:
int cropWidth, cropHeight;
Bitmap croppedImage = new Bitmap(Image.FromFile("uploaded.jpg"), cropWidth, cropHeight);
Note that crop will not scale the image in any way.
After this, you can use several comparison algorithms that are good, depending on what you find better for your application. I found this post interesting:
Algorithm to compare two images in C#
I suggest you follow this tutorial which uses opencv library to match the shapes. This will help you to find the solution for your requirement.
https://www.youtube.com/watch?v=tNMDWRXwHjo
I am using System.Windows.Forms.DataVisualization.Charting chart control to render graphs for some data in my c# winforms application. I now need to save those graphs/charts as .svg or any other lossless vector image, so that it can be seemlessly scaled when used in report.pdf.
Any suggestions are welcome.
I have looked into SaveImage(String, ChartImageFormat), where ChartImageFormat is an enum that does not include any vector image formats. Also searched stackoverflow and similar repos for an answer and as far as I see this is actually a duplicate question (Save ms chart control image as svg file using C# SVG rendering library from github), but the guy quit and used oxyplot instead.
chart.AntiAliasing = AntiAliasingStyles.All;
string imageNameAndPath = "TempImages/Image.png";
chart.SaveImage(imageNameAndPath, ChartImageFormat.Png);
In short I would like to do what the above code does but with ChartImageFormat.SVG or similar.
Edit: #TaW It seems now to me that I was not able to formulate the question correctly. To elaborate: Pictured here are two plots;
the violet one is from mentioned win forms, the white one is from oxyplot. Both get saved into files; the first one to emf the second one to svg file. Bit when those files are opened and zoomed in this is what I get:
So now I am not sure from where this quality difference originates, but it is obvious. So I guess my question is: how would it be possible to save a chart in windows forms in a vector format of a similar quality as it is the one from Oxyplot, preferably without actually drawing on screen (somehow drawing directly to a file, so to speak)?
We have a large number of Images taken from a car for a project. To satisfy privacy norms, we need to detect faces & License Plates and then blur those areas. I came to know of the Emgucv project, and the tutorial given at http://www.emgu.com/wiki/index.php/License_Plate_Recognition_in_CSharp has been very useful to detect Licensplates.
Is there a way of blurring this region using Emgu itself?
I don't believe that there is something built-in like what you are looking for.
What you will have to do, like with openCV, is to blur a whole copy of your source image and then copy back the license plate part to the original image.
You can do this using the SmoothBlur method first and then the Copy method that accepts a mask as its second argument.
I have an objective: I need to join, for example 2 pictures like http://imgur.com/9G0fV and http://imgur.com/69HUg. In the result there has to be and image like http://imgur.com/SCG1X not http://imgur.com/LO4fh.
I'll explain in words: I have some images with the same areas and I need to find the area, crop it in one image and after this join them.
Take a look at this article, it's explains a possible solutions using the C# Aforge.NET image processing library
What you want to do is read the pixel values into arrays,
then find overlapping area using an algorithm like correlation
or min cut.
After finding coordinates of overlap, write out both images into
new array, use coordinates relative to large image minus
position of overlap in that source image plus position in destination image.
C# is not a factor in solving this, unless you meant
to ask about existing .NET frameworks that can help.
I am developing .NET library called SharpStitch (commercial) which can do the job.
It uses feature-based image alignment for general purpose image stitching.
I have been trying to create a decoder that will stream through a pcx file and display it on screen as a bitmap. I have managed to get the information from the image header by using a binary reader, but I have now reached the part that seems to take the least amount of code, yet is also the hardest: creating an array of pixels.
I understand that i may need to add two embeddded for loops to process the data. I have looked at some C and C++ examples, but struggle to understand them. I also need to get the array to display it. if you need more code then I will share it.
I have searched far and wide and read the spec, but I don't know how to approach this. If anyone could help me, I would be very grateful.
Regards.
The .NET does not support PCX images natively, you have two choices. Read the specification and decode the image by yourself or use some library.
As suggested on bytes.com you can use Dot Net Fireball (a Free Image wrapper) and load the image like this:
Fireball.Drawing.FreeImage freeImage = new FreeImage(#"c:\test.pcx");
Image image = freeImage.GetBitmap();
http://magick.codeplex.com/
a nice wrapper working with http://imagemagick.codeplex.com/
easy to setup and get going, see samples at the bottom of the page here:
http://magick.codeplex.com/documentation