My WPF icons are displayed very small - wpf

My WPF icons are displayed very small, as you can see in this image, can you please
suggest what could be the problem? I tried to find some properties related to size but
no success.

One problem could be the bitmap's resolution. Open the bitmap for example in Paint.NET and in the Resize Bitmap dialog check whether it is 72DPI or 96DPI. A large ribbon bitmap should be 32x32 Pixels at 96 DPI.
By the way, in your screenshot the bitmaps actually look ok. What makes you think they are too small?

WPF uses an unusual resolution of 96 dpi... I'm guessing that your images have not been saved at this resolution.

Related

how to scale an image with gimp and save the actual scale and all the white space

there are a ton of scaling instructions for GIMP but all of them tell you to scale and save easy peasy. I feel like I'm taking crazy pills.
This is what my save or export generates:
How can I simply export a selection? Shouldn't the GIMP instructions include this detail? Sorry for ranting.
In Gimp (and some other popular image editors) the image you work on is actually made of separate images (a.ka.a layers) held together on a "canvas". The "canvas" gives the size of the final image.
There are three different ways to scale things and you have to use the right one:
The Scale tool : scales the active layer by dragging corners. Doesn't change the size of the canvas. This is probably what you used.
Layer>Scale layer: scales the active layer by providing explicit dimensions. Doesn't change the size of the canvas.
Image>Scale image: scales the whole image contents and the canvas. This is probably what you should have used.
What happened to give you the image above is that you resized the layer using the Scale tool, so you got a tiny image in the corner of the canvas, which didn't change size. The uncovered part of the canvas was displayed as a checkerboard pattern. If you exported to a format that supports transparency such as PNG or GIF the image would have been transparent, but since you exported to JPG which doesn't support transparent images Gimp replaced the transparent part by the default background color.
Everything is well explained on their website. https://www.gimp.org/tutorials/GIMP_Quickies/

How to properly use screen size in WPF application

I've done desktop application's GUI for minimum 800x600 pixels. But now I need to make it look good when maximised in any screen size. There is so little to show, I don't know how to adjust the elements in big screen.
Now in 800x600:
Maximised in 1366x768:
I tried to make them bigger with screen size, but that give them kinda ugly, unsophisticated look. What should I do?
You need to use WPF Grid Layout to position your control. It will stretch the size of your control based on the defined layout.
You can read a tutorial here https://www.wpftutorial.net/GridLayout.html
You can use Uniform grid in that case
http://www.c-sharpcorner.com/uploadfile/raj1979/uniformgrid-in-wpf/

How ImageResizer Dynamically change image resolution based on screen size

I am using ImageResizer to resize the images and display on the bootstrap layout.
Here I am fixing the image sizes while retrieving them to display the sizes in URL.
Issue is, image quality is lost as dimensions are different for different screen sizes and I am unable to adjust the image which is retrieved to fit exactly to the screen size.
Eg: for 14 inch monitor if size of image is 300*300 which gives perfect quality image, if the same image is viewed in 21 inch monitor the 300*300 image retrieved from imageresizer is loosing quality and getting blurred.
Can some one say what is best solution to retrieve images?
Thanks in advance.
Praveen.
Slimmage.js offers automatic resolution and dpi-switching using the ImageResizer URL API. It is probably the easiest way to achieve what you are looking for, as you just install it and set a CSS max-width on images. Done.
Why this is a problem (like Amy says in the first comment):
Because of high-density displays, browser pixels and screen pixels are not 1-1. Thus you need to use a images-swapping technique like srcset, picture, or Slimmage.js. srcset and picture require polyfills to work on older browsers.

convert pdf with 300dpi bitmaps to svg

I'm creating a tool to convert pdf's into svg. These pdf's contain graphical data, including large bitmaps at 300 dpi and a bunch of vectors as well. Poking around here on stackoverflow, I've found pdf2svg, which great -- works like a charm, and the vector data is perfect. But it looks like the bitmaps are getting downscaled to 72dpi. The dimensions are still 8x10 in inches, but you can tell that the dpi isn't right when you zoom in. Soft of makes sense that the default values would presume 72 dpi, but I need the full resolution bitmap images.
pdf2svg uses poppler and cairo to make the conversion. I've poked around in the code, and I see where it's creating a poppler page and a cairo surface, and I've seen in the documentation that a poppler page has a concept of "scale" that seems relevant, but I can't figure out where to plug it in. I tried (experimentally) hardcoding the height and width passed into cairo_svg_surface_create to the correct values, but it made the dimensions applied to the whole svg larger, without affecting the embedded bitmap.
poppler_page_get_size (page, &width, &height);
// Open the SVG file
surface = cairo_svg_surface_create(svgFilename, width, height);
drawcontext = cairo_create(surface);
// Render the PDF file into the SVG file
poppler_page_render(page, drawcontext);
cairo_show_page(drawcontext);
I don't think what I'm trying to do is very esoteric, so I'm hoping someone who has experience with the libraries will see my error right away. Any help, of course, would be immensely appreciated.
I just made the change to the source as described in http://lists.freedesktop.org/archives/poppler/2011-December/008451.html and it worked perfectly - the images seem to be at their native resolution.
Replace
poppler_page_render(page, drawcontext);
with
poppler_page_render_for_printing(page, drawcontext);
Does cairo_surface_set_fallback_resolution() perhaps help? (No, I'm not even sure about this myself)

How can I stretch bitmap in WPF without smoothing pixels

I'm working on SEM image processing application, written in WPF. I have an image display control, derived from Canvas, which displays image & overlays using DrawingVisuals (one for each "layer"). It also implements Zoom & Pan using scale & translate transform, applied on DrawingVisuals.
When I zoom in the image to see individual pixels, they are displayed smooth, evidently using bilinear filtering to stretch the bitmap (no surprise, as WPF is rendered through Direct3D). However, for my use case, I would rather see individual pixels as sharp boxes, as usual in any image editor like Photoshop. That's why user of my app zooms the image -> to be able to operate on pixel level.
Is there such option in WPF (other than manually stretching the bitmap before displaying it)? I was not able to find anything.
thanks in advance,
Zbynek Vrastil
Czech Republic
Finally found an answer, with some help from Experts Exchange. Class RenderOptions defines attached property BitmapScalingMode, which can be set to NearestNeighbor. So,
RenderOptions.SetBitmapScalingMode(imageDisplay, BitmapScalingMode.NearestNeighbor);
does the trick.
Zbynek Vrastil
Hate to put a dampener on things, but if NearestNeighbor works like GDI+, then this will give you a limited success. As you increase magnification in areas of high contrast you might not get the desired results. In GDI+ you find blacks becoming blue, and whites becoming red - again I stress in areas of high contrast! If this isn't the case in WPF, think yourself lucky!
Perhaps a WCF developer could confirm that?
I've found that there are more options to consider, but I can only speak for the GDI+ Graphics class, which might be useful to someone.
Graphics graph = e.Graphics;
graph.InterpolationMode = InterpolationMode.NearestNeighbor;
graph.CompositingQuality = CompositingQuality.AssumeLinear;
graph.SmoothingMode = SmoothingMode.None;
This works for me. I think the SmoothingMode is the trick. Hope this helps someone else out there.

Resources