I am using OpenWeatherMap to get the weather data for my app.With the response data openweather is sending a weather icon code and they have a specific icon for that code which is very small ,but i want a bigger icon to use in my home page.Is there any alternative to get a bigger Icon from OpenWeatherMap.
Thanks in Advance.
Check this page to get all the icons (in #1x, #2x and #3x). Download them and add them to your assets and the system will automatically get the right one for you.
The you could increase them in your UIImageView if you want since they are png, I donĀ“t think you will decrease the quality.
// Parameters x, y, width, height
var imageView = UIImageView(frame: CGRectMake(0, 0, 100, 100));
This icon set is a lot clearer. Just change the folder from w to wn and add #2x before the .png:
https://openweathermap.org/img/wn/01d#2x.png
I was able to enlarge the png icon like this:
const weatherIcon = document.querySelector(".weather-icon");
const iconURL = "http://openweathermap.org/img/wn/";
weatherIcon.src = iconURL + response.weather[0].icon + "#2x.png";
You should be able to replace the #2x.png with also #3x.png. To me the easiest way is to break it down to separate variables and then combine them. This code is inside my displayData function. I would put this inside your function that displays your data.
P.S. coding newbie here still learning!!!
I use these icons in my UWP app:
http://www.zephyros.wetter.com/apps_und_mehr/website/api/downloads/
Related
I have set 3 images on a toolbar. It looks like so...
Here I added a toolbar, added barbutton items and set images to those buttons. The image type is 1x,2x,3x format and is rendered asa default image.
But the images shown above are shown large while it should have been small given like so...
What have I done wrong..?
EDIT 1: Screenshot of UI layout
Your image resolution must be like below
Tool bar structure
Use barbutton not button
I tested it, its work properly
Output
Wherever you define you images you need to use this line:
let image = yourImage
image.size = CGSize(width: 40, height: 40)
If your image is in the storyboard click on the image and then go to the measurement attribute and change the values there.
Explanation: Our app doesn't know what size we want our image to be so it (by default) sets the image size from the image so we need to define our own size.
This because of your images too big. Downscale your image about twice.
Good 1x size is 25x25; 2x - 50x50; 3x - 150x150. You could not put 1x images in your asset.
I have a very strange bug which appears randomly amongst users. In most cases, the same image loaded into a UIImageView shows perfectly, but occasionally has an artefact line running through it as in the pic attached. We cannot reproduce during testing on either the simulator or device. The image loaded is a simple png:
groupAvatarIV = [[UIImageView alloc] initWithFrame:CGRectMake(horizontalMargin, 5, 70, 70)];
groupAvatarIV.clipsToBounds = YES;
groupAvatarIV.layer.cornerRadius = 70 /2;
groupAvatarIV.image = [UIImage imageNamed:#"avatar"];
[contentV addSubview:groupAvatarIV];
I am really out of ideas how to debug this - any tips would be appreciated please.
It looks like the image contains data for a width greater than itself, so it keeps writing data in an address that becomes the next line down etc... (evidenced by the fact that it starts at the widest part of the circle)
maybe there is something wrong with the params on the image, or it might just be an apple bug...
if it is an apple bug, I would expect it to be with the behavior of clipToBounds
try to collect OS info from the users that experience it... also you could try to re-save the images using a different program, like use ffmpeg to save them as a tiff, then convert back to png (which should be a lossless route), so you know it had to re-interpret it...
Turned out the project which we took over contained multiple image files with the same name, which is what caused the artefacts.
You have mentioned that you have added the imageView in another view as a subview. It seems that the image view is not fit to the superview. You need to check the frame size of both views. Then you need to set the frame of the image view equal to or less than the superview.
Why are there jagged edges on some of the texts and images in the app i am developping?
I have tried to go through the frames, and i have not used a division to set a frame (so the 1.134234 is not an issue), and I have tried different antialiasing methods.
Does anybody have an idea?
See attached for an example.
EDIT:
The images become jagged, when downscaled. So either resize them to fit the size directly in the actual file, OR via code as suggested in other StackOverflow questions.
Now trying to figure out how to fix the text also! :)
EDIT EDIT EDIT EDIT
Answer will posted tomorrow (after 24 hours).
1) Image problem: Make sure the actual image size you are using is close to the size you are actually using it... (Feks 100 points with an image at #1x that is 100, #2x that is 200, and #3x that is 300, where 100,200, and 300 are the actual image file pixels). Or resize using code in the correct way to match.
When iOS is downscaling (as well as upscaling) an image, the pixels get disorted.
The problem in my case was using a too big an image.
2) As to the button, I don't know exactly why, but it got solved using attributedText for the title instead of the usual text. Method used is:
[button setAttributedTitle: forState:];
Solved it :D
1) Image problem: Make sure the actual image size you are using is close to the size you are actually using it... (Feks 100 points with an image at #1x that is 100, #2x that is 200, and #3x that is 300, where 100,200, and 300 are the actual image file pixels). Or resize using code in the correct way to match.
When iOS is downscaling (as well as upscaling) an image, the pixels get disorted.
The problem in my case was using a too big an image.
2) As to the button, I don't know exactly why, but it got solved using attributedText for the title instead of the usual text. Method used is:
[button setAttributedTitle: forState:];
I need to get preview from camera and show it on Imageview..
The code is done as follows
public void onPreviewFrame(byte[] data, Camera camera){
yuvimage = new YuvImage(data, parameters.getPreviewFormat(), width, height, null);
yuvimage.compressToJpeg(new Rect(0,0,parameters.getPreviewSize().width,parameters.getPreviewSize().height), 90, outstr);
bmp = BitmapFactory.decodeByteArray(outstr.toByteArray(), 0, outstr.size());
camera.addCallbackBuffer(data);
}
This code works fine, the if bmp passed to imageview the it displays clear color image on most of the devices, but on a tablet, it shows green/pink image..
If surfaceview is used to show preview directly then it shows clear color preview on all devices..
Any suggestion is appreciated..
If the image looks sort of correct, but just has a weird color to it, then I would guess
that the problem lies with the picture format. I would start is by trying to change parameters.getPreviewFormat() to ImageFormat.NV21 and see if that fixes the problem.
I have used basically the same code before, and never had a problem. (Although you should push the rendering to a separate thread, and probably use RenderScript to convert the pictures).
I used the 9330 simulator for developing my app, and now once I put it on a blackberry bold, I've noticed that my text and images appear much smaller on the device than the simulator. Is there anyway to fix this without having to change every objects height and width? Maybe I need to use Display.getHeight() and .getWidth() more instead of hardcoding numbers?
One way I dealt with this is making the size of my elements variable. I did this by, upon loading the app, detecting the screen size and applying a multiplier that modifies my elements by a given %, the % depends on the screen size. I calculated these percentages by taking a base screen size and seeing how much the screen sized varied from one model to another, there are only 4 screen sizes I believe.
Yes, you shouldn't hardcode any number as bold and curve have differnt screen resolutions
Curve: 8800s, 8300s, 8500s, 9300s 320x240
Bold: 8900s, 9000s, 9600s, 9700s 480x360, 480x320 (Bold 9000)
You will have to change every place you used that numbers and change to gethHeight and getWidth() where needed
For the images you should scale the object, something like this:
Bitmap bitmap = new Bitmap(width, height);
yourBitmap.scaleInto(bitmap, Bitmap.FILTER_BILINEAR);
For texts you should use something like this:
LabelField field = new LabelField("TEST");
field.setFont(field.getFont().derive(Font.PLAIN, yourFontSize));