How Can I Improve Colour Reproduction When Styling HERE Maps? - android

When styling a HERE Map for an application using the NORMAL_DAY scheme as a base, I have noticed that the colours of some map elements are exactly as assigned, while others are off by 2-4% (the amount of black in the colour) and some others are wildly off (30-40%).
For example, LAND was sampled at ARGB 255,251,57,57 while it was actually set to ARGB 255,255,0,0 (pure red). It feels like there is some kind of runtime manipulation of assigned colour values.
Can anyone shed light on this? How can this be compensated for?

you can load the custom style. please refer https://heremaps.github.io/maps-api-for-javascript-examples/change-style-at-load/data/dark.yaml

Related

Removing Image Background Android

I am working on an Image editing app, I have done almost everything that is cropping, re-sizing, filters e.t.c but I cannot seem to really figure out how I can remove image background,the basic idea is the image will have a distinct background e.g subject can be grey and background white or vice versa, I tried looking up here and other sites but could not really find anything matching my description the closest thing was to use OpenCV which did not really do the job well, for the most part it was slow (using GrabCut), if anyone has tried this before or knows how to please help thanks in advance.
You can iterate over your bitmap through all pixels. And check if pixel color value is near in color value of your established background color. And change those pixel color values to transparent etc.
Edit: this answer may be useful

Android Bitmap - Replace an object's color keeping Anti-Aliasing

I have an image in my assets folder on which I am drawing stuff using an external program and then using them in my app. The problem is that the bitmaps are blank (transparent) with black and white objects in them. Note that the objects are created with Anti-Aliasing on to look better. I know this was asked before but I couldn't find what I want. I need to replace all the black and white pixels in the image (even the transparent anti-aliased ones!) to the colors given by the user. Below are some images to show what I want to do:
Please note that this is just an example and I have even some very complicated shapes and the final colors aren't known (as inputed by the user in RGB style).
Any help is appreciated. Thanks! :)
Usually you can tint the images you load apliying them a color at runtime.
The problem is that color applies to the whole image and it only matchs exactly the same color in white pixels, with or without alpha.
So you could separate all the areas of the image with the same color, save them as white and then tint them at runtime while overlapping one over another.
It depends on the framework you are using.

background image or background color?

If you have an activity and you need to set the background color of the activity, simply you would set the background color as
android:background="#0000FF"
or prefer to use an image as
android:background="#drawable/bgimg"
, taking performance and space requirement into consideration?
I think as using image consume space, when ever possible this approach should be avoided. Is it so, or this really does not make a significant difference? Just need to be sure from the experts.
thanks.
First of all this depends upon your need. If you only want a plain Red background then applying background color should be the preferred one.
As working with images may have few odds,
Scaling of the image for various screen sizes.
They definitely consume memory.
May not give the desired effect (blurry at times) if re-sized by the OS automatically.
On the other hand if you need something like a combination of colors then Gradient will help us. (not for the complex ones though :))
At last if you have an image type of background then drawable images will certainly be the choice.
color would be better, since you might have to use different image sizes to suit different screens, which in turn will increase the app size and you might not be very sure that the images are well displayed. And if you opt for higher resolution images, chances are that the app might crash with a fatal signal error just because it runs out of memory.
And #Atul O Holic's answer is complete too.
As little as the difference could be, the color approach is always going to be cheaper when we think in the space required, because you don't need to have a file with the image resource. Also, you can always use a native color from android using android:color/[color].
Using an image as background is only better when you can't have the same effect by just using a single color as background.
If it's one solid colour just set the background colour (you can also set the colour in your resources so you wouldn't need to keep setting it!).
Totally agree with joa2fast4u, when targeting multiple devices, especially ones with low memory, any optimizations you can make to save memory/reads/writes is preferred. Also, you can specify many preset styles in your styles/themes resource files to propagate and control the entire theme of your app from the default background to the text color on your widgets.
1) Solid Color - Apply a background color
2) Multiple Colors - Use a Gradient
3) Anything more complex - Use images
Please note that the usage of images involves optimization of multiple screen resolutions & sizes. File size & device form factor is also an important factor to be considered here.

Android Graphics issue for seekbar background

So I have this image set as the background of a seekbar. On different screens, the image gets skewed so much that it is quite horrible. I tried doing a 9 patch, but obviously there are several regions I would like to scale so 9 patch wasnt the best option. What I would like to acheive is, have the background stretched and leave the numbers proportional. The numbers tend to eith stretch too much or shrink too much.
Any help is appreciated.
Thanks
The simplest option here is probably to create a GradientDrawable to set as the background of your view. You can see from the docs that GradientDrawable can take an array of colors in its constructor, and it will draw all those colors evenly spaced across whatever size the enclosing view end up to be. This is the same element used to create <shape> drawables in XML, but if you instantiate it in Java code you can add more than just three colors to the gradient scale.

Should I draw or load an image?

I am wondering what would be the best practice for android. To draw or to load an image?
For example I want to have a circle that is green filled with the text 25 in it.
-Should I have it in .PNG image file and just load it to the imageview placeholder when I need it?
OR should I load it in Java (by determining the position in java and load it from my res folder)?
OR Should I draw it (draw a circle, fill color, add text field inside)?
On another note, to have a checkmark, what do advise me to do?I don't even know how to draw that
I really need your help in this
Thank you so much
I'd actually argue that there is a single right answer. You should use a shape with a set color and text view inside it. It is easy to do what you've described in xml, see: Oval Gradient in Android for an example (there are a number if you google for android shapes). This will be less CPU/memory intensive than loading a bitmap, and more importantly, it will work for and look good on every screen size. As an added bonus of the user has changed their default font sizes, a textView/shape can respect that and a static image can not. Just set the background of your TextView to be the shape drawable (either in xml or programatically).
To get a bitmap to look good on multiple devices (a must for android development) , you will need a number of different versions of the same bitmap at different resolutions (XHDPI, HDPI, MDPI... etc).
Check marks are harder because they don't conform to a standard shape. Those you probably will have to make pngs for.
It depends on what you want to do.
Rendering a bitmap will be faster, but you cannot manipulate it after it is drawn.
So, for your case, you have a green circle with 25 written it. Do you also need a green ball with 23 and another with 24 in it? What about other colors?
It really depends on the amount of variation you need. At a certain point the overhead of using dozens of images will not be worth the evert of drawing to a canvas. Or, depending on how complex the images are, it will be.
The question is not "Which is better?", but instead, "Which is better for what I need to do?"
I'm not an expert on Android development but after seeing your question I have done a bit of reading and came across this article on displaying images with android that is relevant and includes some code to possibly help you out. http://www.javacodegeeks.com/2011/07/android-game-development-displaying.html
As for your image of a check mark, why dont you just go into photoshop or paint and use the line tool to draw a checkmark and then fill it in with color and save it as a .png perhaps?

Categories

Resources