I have a problem that occurs on some displays (HTC Hero, Motorola Defy, HVGA emulator) where some bitmaps are distorted in a peculiar way: The image apparently is shifted by one or two pixels, e.g. to the left, and the resulting gap on the right side is filled by duplicating pixels from the right border of the bitmap. I use pre-computed LDPI/MDPI/HDPI versions of these bitmaps, e.g. a notification icon that fits the specs for notification icons.
I attached two images that show the effect. Please note: even though it might appear that the bitmap is tiled, this is not the case, other images consistently show that the pixels are not wrapped around but duplicated/stretched.
Has anybody ever had a similar problem?
Thanks in advance for any clues that could help me solve this issue,
Arne
Related
I have few scenes in my project. I was able to center all of the other scenes. But i cannot center the main scene in my project. Its fine when it opened on a mobile device(probably because resolution matches i guess). but when i opened it in tablet(its an old tab "xiaomi tab 3") its always align to the right on the screen. I was able to center other scenes but i cant center the main scene to screen for some reason. project setting set as 2D and Expand. I also tried to use Control nod, canves layers, margine containers.. but nothing works. If someone can give any suggestions, Thank you in advance.
img1
https://i.stack.imgur.com/FJOHl.jpg
project
1920 x 1080
I have seen this problem, or similar, in windowed mode. I don't know if this is the exact case, but if it doesn't mess with your project, try full-screen mode.
If it's that, you can also take care of the window bar size (which is a problem because it can change from different devices), since godot will count its pixels too.
Notice that you're only having this problem in one axis.
Also, I think you could take a look into the Viewport Stretch Mode. It could mess your graphics depending of the intended result—but other projects won't even notice, so judge for yourself.
The viewport setting sets the root scene’s Viewport to the base resolution. The rendered output of the root Viewport is then scaled to the display resolution. [...]
The viewport setting is a better choice than the 2d setting when pixel-perfect precision is required, since primary rendering still occurs at the base resolution.
Support multiple devices
Scaling correctly for all devices could be an odyssey, so bon voyage.
We have started integrating ActionBarSherlock into our app. Everything looks great, it's a really great lib, that gets in easily. But, there's one issue we don't know how to solve:
Some of the icons on some pages for larger screens get stretched. Has anybody had such problem?
Upd. 1.: Device that has icons stretched is running on Android 4.2.2 (it's Nexus 7 actually). All ok on a smaller screen like HTC Desire (2.3.3).
Upd. 2.: As the example of what is happening: there's an icon of a size of 48x52 pixels. It is in the "drawable" folder. It is used as the background for a Button widget. Before the update the app used this icon as is, i.e., it looked like 48x52. Now, looking at the element borders it looks as if the app is stretching the widget's width to be 52x52 or even wider, keeping the height same. layout_width, layout_height are set to "wrap_content"
Ok, using this answer I managed to fix -
changed all the Buttons to ImageButtons
all the android:background-s to android:src-es
android:background-s set to 'transparent'
But! I don't know why it happened and why it worked! Any clues? Thank you!
I am using this code Pinch zoom in android 2.1 (by kinghomer) within an Activity within a Tabhost. I am using that to display a background image, and then also display icons on that image. These icons have to be displayed at the spot that i have defined (i give the matrix x and y coordinates). This is all working.
The problem that i have is that in some devices, the icons aren't on the exact same spot, but about 1cm off in each the x and y coordinates. I have tried to recreate this in an emulator, using the same resolution as one of those devices, however, in the emulator, with the same resolution as one of the devices where it is "wrong", they are shown on the correct spots. I have no idea what is causing this?
I have tried the app on an HTC sensation running 4.0.3 (displaying the icons correctly) and a samsung galaxy s3 running 4.1.2 (displaying them incorrectly, each coordinate is off about 1cm.). I have emulators with the same resolution as each of these devices, but in both those emulators the icons are displayed correctly.
What is causing this? I'd be grateful for any ideas!! Thanks in advance!
I figured it out. My error was that i thought since i needed to have the exact pixel as x and y coordinate on my background picture, that i should put that picture as well as the icons only into the drawable-hdpi folder (completely disregarding the other drawable folders), so that Android is forced to take the same images. I couldn't rescale them and put the accordingly scaled pictures into the other folders, because then the pixel coordinates would be off. However, i just put the exact same images into each of the drawable folders, and Android takes care of the rest. Quite embarrassing really. Thanks #MarsAtomic for trying to help!
I've created a single sprite sheet for my game app, with each frame 100x100 px.
Everything's been working well until after I added a few more rows to the sprite sheet, then suddenly nothing gets drawn onto the screen any more. I reverted the sprite sheet back to an earlier version, which had less rows, and everything works again.
The sprite that works is 400w*900h px, and the one that stopped working is 400w*1400h px... I suppose there's a middle ground somewhere I just haven't bothered to look for it.
My question is what is there a dimension limitation on the resource image files? And is there another way to get around what I just descripted other than splitting it into different files?
Thanks in advance
edit: getMaximumBitmapHeight() helped a little: On my testing device (nexus galaxy) it's only 2000 something... And on the emulator is in the 30k range :S Is there a way to set the allowed size? And if anyone knows... how different is it from phone to phone
The Canvas class has a method getMaximumBitmapHeight() (& width , naturally ) to give you this information for a given device, you can just print it in a log message.
On possible work-around is adding columns. Your image is only 400px wide but 1400 in height. It could be that 1400 is too wide but I very much doubt 400px is too wide.
I used a linear gradient image for a background and in Photoshop (and everything else) it looks nice and smooth but when I displayed it in the emulator is was banded! What's worse, it's banded on my actual phone - a Droid Incredible. I'm running 2.2 both in emulation and on the phone.
Here's a sample - original on the left, Android'ed version on the right: http://pnart.com/temp/AndroidMach.jpg
This has the appearance of Android imposing some bit-depth limitation. What's going on and how do I fix it?
Thanks in advance!
I had the same problem and did some searching on Google. One of the sites I found suggested I put the gradient image in res/raw/ and load the image when needed. I tried this and it worked.
From what little I understand, any image you place under "drawable" will be processed by AAPT and it isn't guaranteed the final images will be the same as the ones you are putting into it. In this case, it decided to shrink the PNG gradient image to a smaller palette to shrink the size of the final APK. If someone else has a better (or more correct) explanation, I'd love to hear.
-Dan
just try this: get down the width and height to the screen resolution of the device (eg: for moto droid: w:320px and h:480px and in photoshop keep the resolution to 200 dpi or above)
Regards,
Mistry Hardik
If there isn't any special reason for using an image to get a gradient I highly recommend looking up the Shape Drawable as it supports gradients which should (I haven't tried it but I assume) allow lossless scaling.
First of all, the color depth of phone's screen is much worse than that of your PC. On your PC you have 8-8-8 bits depth for R-G-B but for phones it's typical to have 5-6-5 depth. It means that any fine gradients/shades that look good on PC will be distorted when displayed on the device because its color depth is just not enough, physically.
Therefore, designer's rule №1: avoid fine shades and fine gradients in your designs.
But if you have to then, of course, you may try the following, but you've been warned!
1) For runtime-generated gradients: use dithering, like this:
setContentView(R.layout.screen_dashboard);
findViewById(R.id.layout).getBackground().setDither(true);
2) For graphics assets: always apply a 5-6-5 filter before saving png. Here is a good article with examples. Applying 5-6-5 filter ensures that color depth of your png is within device capabilities, and decreases png size too.
Seems like it might be because it's scaling the image to fit the screen. When non-vector gradients are scaled they often get that "banded" look. Try making a gradient that's the same size as the screen you're targeting, or try changing the ImageView (or whatever) that is displaying the image to make sure it's not stretching or scaling the image.
EDIT
In my opinion the best solution would be to create your gradient for your background at runtime have a look at GradientDrawable