I use monogame. Currently, I have a problem that prevents me to advance. this problem is concerning the image resolution and size to use.
What I want to know is Can I use the same images or I must use different images (Background images whish fill all the screen) for each device according to the resolution and/or the size of the screen.
Thank you in advance.
You can use just one image and scale it to fit the desired resolution. The simplest way to do a background image is to use the SpriteBatch.Draw overload that takes a destination rectangle like so:
var width = _graphicsDeviceManager.PreferredBackBufferWidth;
var height = _graphicsDeviceManager.PreferredBackBufferHeight;
var destinationRectangle = new Rectangle(0, 0, width, height);
_spriteBatch.Begin();
_spriteBatch.Draw(_backgroundTexture, destinationRectangle, null, Color.White);
// draw other sprites here
_spriteBatch.End();
Keep in mind that your images are going to look better if you are scaling them down rather than up, so make them fairly large so they look good on tablets as well as phones. I tend to use 1600x960 because it's twice the size of a common phone resolution 800x480.
The other thing to consider is that the image may with stretch into a different aspect ratio on some screens. In my opinion, this is okay most of the time, but you may want to implement a more sophisticated scaling system. Some people like to use Pillarboxing, Letterboxing or simply cut off the sides in a non-widescreen (not sure what this is called).
Alternately, you could use different images for different resolutions for a higher quality result. Although, I haven't seen this approach used much in games but I think it's pretty common in apps.
you must use diffrent image for each resolution, and put images of the same resolution in one folder to order your code.
Related
I am about to deploy my first React Native application to the iOS app store. I am having a problem however when it comes to layout. I am utilizing the flexbox system and currently designing for iPhone 6. I have done all the mockups and Sketch and have everything how I would like it to look.
I have run into a problem however whenever I try to run the application in iPhone 4. The design that I have implemented for the iPhone 6 does not fit with the constraints that iPhone 4 possesses.
I can try to redesign things for iPhone 4, but then things become too small / ugly on the iPhone 6. I really need things to look great on all of the screen resolutions (i.e., iPhone 4 - iPhone 7 plus).
I have seen on the web many different solutions: apply a constant to each stylesheet value, dependent up the aspect ratio of the device; check the device and render different components based off the device your are on; and make better use of flexbox in order to make the layout responsive.
The first solution doesn't seem like it will give an accurate representation on each screen size, the second solution seems to create too much excess code just for styling, and the third solution seems to not account for static sizes and font sizes.
I normally would begin to follow the third solution, but there are some things that can simply not be a percentage of the container (e.g., button height, font size, some margin and padding, etc.)
Therefore, I am asking the question: What is the best way to approach this problem in React Native? I really need a thorough de-facto answer that can explain the best way to go through the development process as well (e.g., should I design for the smallest screen size and then fit it to bigger sizes? should I design for all resolutions? etc.).
A big thanks in advance for those of you who have felt my pain and have discovered a great solution, please let me know what that solution is.
Ok, so I think i understand how to go about doing this now. It looks like the key for designing for multiple screen sizes in iOS is not to necessarily make things bigger on bigger phones and smaller on smaller phones, but to design for what works on the smallest screen size, and let the items look small on the bigger devices.
It seems that the idea behind this type of responsive design is that individuals with bigger phones desire to see MORE CONTENT, not blown up content. Therefore, if it works on small phones, it can also work on big phones.
Take buttons for instance: If a button at 40pt looks good on an iPhone 4s, it will also work well on an iPhone 7 plus. The benefit is that the user of the iPhone 7 plus is able to see more content, rather than just a bigger button.
This design also makes it to where multiple screen sizes are not necessary for styling.
There is still a role in determining the dimensions of the device you are on, but this is more to determine whether you are able to display more content (e.g., in the case of iPhone 5 vs iPhone 6, whether or not to display an additional tab button), as well as the layout (e.g., where should I place the menu).
You can see this type of design on most of the very popular web application native apps.
Images and videos are one of the only exceptions. It seems that it is helpful at times to automatically grow the images whenever the device and the design call for it. Fortunately, this is very simple by using a flexbox and responsive technologies as are included with react-native.
I hope this helps others and saves them some time. Note: this does not provide for the problem of landscape vs portrait. Under that situation, it is probably best to use some sort of varying styles.
I have felt your pain and choose a similar solution to your first one also similar to the blog post mentioned by Shukarullah Shah. In my style.js file first I obtain the device width and height using;
const x = Dimensions.get('window').width;
const y = Dimensions.get('window').height;
Then I divided each dimension, x and y, to 10, 20 and 40. For width, it become like;
const widthS = x / 40; // ~10 px
const widthM = x / 20; // ~20 px
const widthL = x / 10; // ~40 px
Then I use these values to define any size for margin, padding, image size etc. Also I use a common style.js file for each component I have. So that I define these constants once and I can see/compare every style piece I have easily. Of course you can improve these kind of definitions like in the blog post mentioned. But I am a developer not a designer so that I am not so edgy about perfect ratios.
I have read useful blog on medium about Responsive Design in React Native. I did not get time to try it but I think it will solve your issue, let me know how it works for you.
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.
I'm looking for a way to store a very large image (e.g. 100.000x100.000 pixels) on a webserver. I must be able to retrieve parts of that image and write parts into it. The cherry on top would be a way to get parts of that image, resized to a specific resolution (for example, i want alle pixels from 0,0 to 10.000,10.000 resized to 1000x1000 pixels).
Anybody know a kind of DB, or a data-structure or any other way or service or programm that can handle something like that?
thx, tux
How about Tiles?
Just like what popular mapping application (Google Maps / Bing Maps ) does. Divide and pre-process your image in to tiles for various sizes (zoom levels). Display them on a webpage with zero margin, zero border.
While retrieving, calculate positioning of tiles (which tiles should be retrieved as whole and which ones as partial) and then return as single image.
http://143.117.54.5/idl/images/img_pyrm.gif
(image ack: http://143.117.54.5/idl/Image_Tiling.html)
Search for "map servers": there are a bunch of them already available. I'm sure they at least contain components that might be of interest for you.
My developer's box has a screen resolution of 1680 x 1050. I'm developing a full-screen Silverlight 3 application that I'm considering deploying to the Internet. So, I want to make sure the application looks good on a variety of screen resolutions. I just started testing on other boxes, the first one having a screen resolution of 1024 x 768. During the test I found some of the pages on the application were partially truncated. It seems the controls on the page didn't adjust for the lower screen resolution. So, I'm looking for some tips on how to make a Silverlight application, to the extent possible, adjust for screen resolution. For example, are there things one should or should not do on XAML to make adapting to screen resolution easier? Should I just optimize for a minimum screen resolution? Your thoughts and suggestions are welcomed.
You can easily enforce a minimum acceptable resolution by setting the MinHeight and MinWidth properties of your root visual. (Of course, this should be less than the minimum screen resolution to account for browser chrome.)
Try to specify absolute Width and Height only when necessary: for example, for images or icons of fixed dimensions, or for obvious cases like TextBoxes (whose width should reflect the average length of the data entered).
Grid panels are excellent for mixing scalable and fixed layout areas. The star sizing specification takes a bit of getting used to--it's not as simple as a percentage-based proportioning--but it's much more flexible, especially in combination with row/column min/max dimensions.
You don't really need to test on multiple resolutions unless you're interested in testing a range of dots per inch--just resize the browser to approximate different screens. Since there's always a bit of give and take depending on the user's browser configuration, you'll have to account for some variance anyway.
You can make your application scale with the Silverlight Toolkit ViewBox or make it strech with layout controls like the Grid, StackPanel, and WrapPanel. Make your main UserControl have a Width and Height of Auto (or remove the width and height entirely) and the size of the app will resize to the size of the parent div (the default HTML template uses 100%x100%). Then just resize the browser accordingly. IE8 has developer tools that can help you see your app resized to specific screen resolutions.
Testing on a variety of screen resolutions is always a good idea.
I covered the resizing of elements and making it resolution independent on another thread.
You can have a look here, there are multiple ways to sizing and resizing things automatically.
When I call resize on images using app engine, they maintain their aspect ratio - I don't end up with the size I ask for.
I'm trying to make rectangular pixel NTSC images from square pixel sources, so I don't want this behaviour
I want to take an image that is 720x540 and resize it to 720x480 but what I actually end up when ask for the resize is an image that is 640x480.
Is there any way round this?
Alas, while PIL per se could do it, that's not what App Engine's very simple images functionality is using (you may be confused by the fact that the SDK is indeed using PIL to implement that functionality's API on your development machine) -- in particular, resize always does respect the aspect ratio. Your chance to get higher functionality depends on asking for it on app engine's issue tracker, and hoping that many developers have that need!
Are you giving the resize method both a width and a height?
http://code.google.com/appengine/docs/python/images/functions.html
Adam McGrath wrote a great rescale function that crops an image to a specific width and height in his answer here.
Why not use the crop function?
The correct arguments to transform a 720x540 to a 720x480 image would be (presuming you want a center crop):
crop(bytestream, 0, 0.055, 1, 0.945, output)
The crop function takes its arguments as a proportion of the image width or height, specified as a float value from 0.0 to 1.0.