How to strech Visual assets in UWP? - visual-studio

I have generated the assets for my uwp app using the Assets Generator (which is inside the Package.appxmanifest) and also using this extention.
It generates files OK. However when i see the icons, they are centered. Like (the icon on the right of Settings) where you can barely see anything. The quality of the icon is better than it is showed here, and the quality of the icon is good. So the problem is that the icon is centered in the rectangle. I want it to stretch over all its rectangle.
Like:. (it does not need to stretch to 2 rectangles as in this photo.)
How can i do this?
Edit: Perhaps the question was not clear. I want to remove the padding from the icon. Let me give you another example that may be more clear. In the taskbar.
I have my logo here, with padding outside. I want it to stretch so there is no padding.I want my logo to be the size of the actual container.

Stretching the icon to 2 rectangles has nothing to do with the developer. You as a developer do not have any control over that. The user can right click the tiles and select the size of the tile, if they select it to be medium size, it will take space of 2 rectangles if small then only 1 and if large size is selected it take size of 4 rectangles.
In the image below you can see I have opened the context menu on the SMicrosoft Store tile and its selected size is currently Wide which is why it is currently taking 2 squares ( or rectangles ) and I can change its size to small, Medium or Large as well, this is all done at the user end after they have installed your app.
If you want to remove extra padding around your assets: when you generate assets with the built in asset generator of the manifest there is a checkbox "add recommended padding" uncheck it and you will have the desired result.

Related

NSToolbarItem with Segmented Control - Images Not Rendering Correctly

I'm trying to emulate Xcode's toolbar controls to show/hide the Navigator and Inspector:
...but without the bottom pane (only left and right: two segments)
I screen-captured the icons from Xcode's UI and traced them in an image editing application. The resources for the left pane are:
#1x:
(20x20 #72 dpi)
#2x:
(40x40 #72 dpi, although using 20x20 #144 dpi seems to make no difference)
The right-pane counterparts are identical, but flipped horizontally.
All rhe resources are stored in the asset catalogue, as follows:
I dropped a segmented control on the toolbar, to create a toolbar item with a segmented control inside it, and set the image attribute for each segment (0 and 1).
Image Scaling for both segments is set to "Proportionally Down". The segment control has segment width "Fixed" checked, with a width of 48 for both segments. The toolbar item has Minimum Size of (83 x 25) and Maximum Size of (100 x 28).
The icons display correctly on the storyboard (Interface Builder).
However, when I run the app, I can not get the icon images to display appropriately.
If I launch my app on a retina monitor, no icon is displayed on either segment.
If I move the window to the external, non-retina monitor, both icons are displayed.
If I remove the one of the two image sets from thew catalogue and run the app, the other icon is correctly displayed! (on either monitor)
If I further set the same, remaining image for both segments, they display correctly!
If I leave both image sets in the project, but reset the Image field in one of the segments to empty, the other icon isn't displayed eihter!
What on Earth is going on??
I have put a sample project on GitHub that reproduces the issue.
Edit: Just to make sure, I extracted the resources from the compiled app binary using the cartool command line utility (as explained in this answer), and all 4 images are there at the right sizes...
Solution: As suggested by Ivan's answer below, I switched to using vector graphics (PDF) for the icons. I downloaded the trial version of Acorn and recreated my icons at 1x size, then exported as PDF.
To avoid blurring at the scaled up size of #2x at runtime, I had to make sure all coordinates in the editor were integers, and also check the box for "Snap to pixels" in the Vector Shapes inspector for each shape layer:
(Happy Ending)
$ git commit -m "Fix toolbar icons for good (PDF)"
According to my experience, using of bitmaps in toolbar is troublesome. You can try to target exactly recommended resolutions to possibly avoid some problems: https://developer.apple.com/macos/human-interface-guidelines/icons-and-images/custom-icons/
However, the cleanest way would be to use vector (pdf) icons, as they simply work as intended.

Archive upload failed with error: ITMS-90470 Missing TVTopShelfImage.TVTopShelfPrimaryImageWide key

Do you know why this is happening and most important how to fix it?
Adding the key with what value?
Starting in tvOS 10 you must include a wide top shelf image, Top Shelf Image Wide, with a size of 2320px by 720px #1x. tvOS Human Interface Guidelines: Icons and Images.
If Top Shelf Image Wide is not already in your Assets.xcassets you can create one manually, or with the + Add a Group or Image Set button. For example:
The crop area is still 1920px x 720px #1x when the top shelf image is displayed on the Apple TV. So, if you're using any text or images that you don't want cut off make sure to make them centered in those dimensions. For example:
The areas in red are only used for sliding in your top shelf image when your app icon becomes highlighted on the Apple TV home screen.
EDIT:
Check your target's Build Settings.

how to make a bitmap to fit to the static picture control of a property sheet?

I am having a property sheet and added three pages.In the first page I added a picture control and in the properties of that picture control for "Image" property I am setting a bitmap.And was able to load very successfully.But,the problem here I faced when I run my exe then I am getting bitmap on the page header(which is some kind of banner for the page.)But what I noticed is there is some gap between the banner bitmap and the frame edge (which is occurring at the right top corner). And when I ran my xxx.exe on a Japanese machine then I had observed like the sheet is somewhat stretched and banner bitmap is not stretched completely till the edge of the sheet (top right corner)for Instance if we take a dialog on load a bitmap on it then we can observe that it is entirely got stretched till the edge.
So how can we avoid this issue like whatever the operating system it is and whatever the resolution it might be that banner should get stretched till the edge of the sheet.The gap has to be removed.
I am not loading the bitmap dynamically (setting in the properties.)
Can anyone please help me ti achieve this
The reason you get different results on different systems is that dialogs and controls are sized using "dialog units" which are based on the average size of the font, rather than an absolute number of pixels.
By default a static image control will resize itself to the size of the bitmap it's displaying. So if the dialog itself ends up bigger than normal (because the font is physically bigger), the picture control will appear to have shrunk, leaving a gap.
You could try setting the SS_REALSIZECONTROL style on the static control. The normal behavior of the static control (when displaying a picture) is to resize itself to the size of the bitmap, however the SS_REALSIZECONTROL style overrides that behavior and instead causes the bitmap to be resized to the size of the control. However the results of that may be less than optimal (e.g. the aspect ratio will probably be wrong), so instead you may want to look into scaling the bitmap yourself.

Unity 4.6 - How to scale GUI elements to the right size for every resolution

The new Unity 4.6 comes with a new GUI, when I change de resolution on Unity the UI Button scales perfectly but when I test on the Nexus 7 device the Button looks too small. Any idea how to solve this?
Unity's new GUI system uses "anchors" to control how gui elements (like buttons) scale in relation to their parent container.
Unity has a tutorial video on how to use the new "Rect Transform" component (where the anchors are configured) here: http://unity3d.com/learn/tutorials/modules/beginner/ui/rect-transform.
The last half of the tutorial is all about anchors. That page has links to the entire tutorial series. It's not too long. You should watch the whole thing.
Specific to your question:
The anchors are visible in your first screen shot. They are those 4 little arrows at the top left of your button.
Right now, your button is only anchored by it's top left corner.
The two right anchors need to be dragged to the right so that the right edge of your button is anchored to a space inside its parent container.
Depending on your situation, the two bottom arrows may need to be dragged down so that the bottom edge of your button is anchored as well.
The video I linked above covers all this in detail.
Lastly, for the font size to scale nicely on different resolutions, you will need to add and configure a reference resolution component to the base canvas of your UI, as Ash-Bash32 wrote earlier.
Update: The best way to add a Reference Resolution component is through the inspector window for the base canvas in your UI.
1) click the "Add Component Button" at the bottom of the inspector.
2) type the word "Reference" in the search filter field.
3) select the "Reference Resolution" component in the search results.
The Reference Resolution is now renamed as Canvas Scaler.. Along with the renaming they have added many more features for the dynamicity of the Canvas. You can go through the Unity Doc of Canvas Scaler and also take a look at this article for a practical example of how and why to use Canvas Scaler. Also make sure you use the Anchor Points to good effect to make this more robust...
To Scale UI added the ReferenceResolution Component to the Canvas you want to scale.
P.S. Theres no Documention for ReferenceResolution
If you want the button to be the same size for all screens and resolutions, you have to add the canvas scaler component to the canvas and the set the screen match mode to: match width or height, here is the link to the docs, this helps a lot if you want to aim to different sizes or resolutions:
http://docs.unity3d.com/Manual/HOWTO-UIMultiResolution.html
This becomes giant and convoluted once you start laying things out in code AND using a canvas scaler, so I wish to provide a thorough answer to save someone the hours I went through.
First, don't use anchoredPosition to position anything, unless you fully realize it is a 0.0 to 1.0 number. Use the RectTransform localPosition to do the actual laying out, and remember it's in relation to the parent anchor. (I had to lay out a grid from the center)
Second, put a canvas scaler on the parent layout object AND the inner ui pieces. One makes the layout in the right position, the other will resize your elements so they actually show up right. You can't rely on the the parent unless the children also have scalers (and Graphic Raycasters to touch them).
Third, if you have a scaler, DON'T use Screen.width and height, instead assume the screen is the same value you put for the scalers (hopefully you used the same, or know what you're doing). The screen width always returns the actual device pixels, retina devices too, but the canvas scalers DO NOT account for this. This probably gives unity the one remaining way to find actual screen dpi if your game wants it. Edit: This paragraph applies to any parent canvas connected to the code doing your laying out. Not stray canvases, you can probably mix it up. Just remember unity's guidelines on performance with canvases.
Fourth, the canvas is still a bit buggy. Even with the above working, some things don't render until you delete and recreate a canvas, if you re-open the scene or it crashes. Otherwise, the above is the general "rules" I've found.
To center a "grid of things" you can't just use half of the canvas scaler's width or height, you have to calculate the height of your grid and set the offset by half of it, otherwise it will always be slightly off. I just added this as an extra tip. This calculation works for all orientations.

Center image horizontally & vertically on page with % margins and be resizable with window

It seemed so simple just a day ago, but I can't figure it out:
How do I center an image on a page, giving it fixed % margins (10% on all sides) and still have it scale with the window on resize?
It's very important that the page and the image display well on all platforms, without scrollers (!).
The page itself is very simple and only contains the image (which on different versions of the page has different dimensions), and a bar on the top with a link to send it to another page.
The max size of the image would be 1500x1000px, no minimum size.
I wholeheartedly hope someone can help me out with this, thanks so much!
Best way to do that is using JavaScript. Get the window size, subscribe for window.onresize event and update the image size and position accordingly.
Using CSS only will NOT work, because any position properties depend on the container. In your case the container is the window, which will size itself based on the content. This creates a sort of circular dependency (window size depends on the image, the image size and position depend on the window size).
For information about getting the exact available window size in cross-browser way you could check this post: Get the size of the screen, current web page and browser window - haven't done that in a while to provide you with exact code.
Also note that you don't mention keeping the aspect ratio of the image. If it should not be maintained there is no way to do it HTML/CSS only, because all operations with them do maintain AR of images.

Resources