How can I control the quality of a screenshot in c# - c#

I made a small windows form app that takes screenshots, but the final image looks a bit blurry compared to screenshots using other screenshot softwares.
I mean like the pixel density on screenshots from my app is lower than the density of screenshots from other apps.
I used this tutorial: http://www.developerfusion.com/code/4630/capture-a-screen-shot/
How can I control the pixel density or quality of the screenshots my app takes, without resizing the images?

The problem was just the image format. Probably jpeg format has lower quality than png when taking screenshot. Saving the image as png gave me a real sharp and high quality screenshot.

Related

Is it possible to crop screenshot at gpu level

My final goal is to get screenshots of a cropped area on the screen as fast as possible.
I'm using the the desktop duplication api with sharpdx to retrieve the full screenshot from windows according to the official sample :
https://github.com/sharpdx/SharpDX-Samples/blob/master/Desktop/Direct3D11.1/ScreenCapture/Program.cs.
I'm currently cropping at CPU level with a pinned memory bitmap and Buffer.BlockCopy on the raw bytes which, IMO, cannot be considerably anymore faster.
Is it possible to apply a simple crop operation at GPU level?

Why image has different pixel resolution in Hololens

I'm working on application, where small UI.Images are displayed with small textures 32x32 pixels. It is very important to display each pixel properly.
When I'm trying to launch the application in Unity everything is perfect - Image consists of 32x32 pixels.
While deployed to Hololens, the Image has worse quality and resolution changes to 16x16 pixels.
The question is how to obtain texture displayed in 32x32 pixels quality on Hololens device?
Ok, finally I figured it out. In Unity Edit > Project Settings > Quality the option Very Low is used for Hololens application. In this mode the Texture Quality is set to Half Res, thus the Image was rendered with half of the pixels' number (16 pixels). When changed to Full Res, the Image get original 32 pixels size.
It does not explain why in Unity Editor the Image was displayed properly, but the most important thing is that now it's working properly on the device.

losing quality when resizing with ImageResizer

I'm using the ImageResizer .net library. It works as expected, but one image messes around.
I've uploaded the image below. I've already tried some things like format=jpg&quality=100, only width=220, also different sizes, but it always adds this blurry border around the image.
The original image is a png.
This one is the original image:
This one is resized by the ImageResizer:
And this one is resized with photoshop:
EDIT:
If you're running into the same issue. Try to set up the SpeedOrQuality Plugin. I've set it to speed=3 and the image is sharp again.
Vector graphics require different resampling algorithms than photographs.
ImageResizer V4 includes higher quality image resampling options under the FastScaling plugin.
For graphics (non-photographic images), I suggest playing with &f.sharpen=0..100, &down.preserve=-5..5, and &down.filter=Robidoux. Make sure &fastscale=true and FastScaling is installed.
You can certainly find a good configuration for your rasterized vector art and set up a preset for it. FastScaling is capable of much better resampling than Photoshop - on par with Lightroom, in fact.
Enabling fastscaling alone helps substantially (?width=200&fastscale=true):
Adding sharpening gives a very clear result: (?width=220&fastscale=true&f.sharpen=100):
Visibly crisper than Photoshop:
Each time you save a jpeg, you loose quality (the image is reencoded).
I would recommend using the same quality as the original image was save against, it should give the best results.
Using a higher quality is not recommended as it will artificially try to improve quality, mistaking approximations done by previous encoding for details, resulting in things like the blurry border.
Aside that, usually, one should not use a quality over 95 for jpeg encoding.

Import/Setting background image to windows form cause run slow

I import background image to every forms in my project now my programs runs slow?
How can I fix this?
the format for the image is png.
Any things to consider in to doing this? to solve the issue? thanks!
In your Form,set property DoubleBuffered to true
Buffered graphics require that the updated graphics data is first
written to a buffer. The data in the graphics buffer is then quickly
written to displayed surface memory. The relatively quick switch of
the displayed graphics memory typically reduces the flicker that can
otherwise occur.
Instead of using PNG format use JPEG format with Quality 12(final image quality is like PNG format),your image size decrease and your form load faster.

Content-Aware Image Cropping with C#

I am working on a CMS like project which users can upload images with contents. I have to create thumbnails for the uploaded images on the fly. Lets say the thumbnail size as 125x75
I can resize images without problem but when it comes to crop operation several problems occur. My resize and crop procedure works like this:
Load the original image.
Resize the image to desired size preventing the original aspect ratio depending on the given maximum width or height
If the result image has a different aspect ration than the output aspect ratio than a centered crop operation is applied.
But what I want to achive is a content-aware cropping as described in Jue Wang's article Opticrop: Content-aware Cropping with PHP and ImageMagick
Is there any way to do it with C# or is there a library that can do this operation.
Note: I do not want content-aware resizing. Content-aware resizing (seam craving) can be done with ImageResizing.net SeamCarving plugin
If you are using the ImageResizing.net framework, the WhitespaceTrimmer plugin may be a good starting point I think.
If you want to write the code yourself, this Gist shows a good solution using entropy but is written in Ruby.

Categories

Resources