Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid bitmap tiled by X
    primarykey
    data
    text
    <p>I'm trying to build a live wallpaper on Android 2.1 and I cannot figure out how to make a rectangular with x-repeatable bitmap.</p> <pre><code>Bitmap backWaveImage = BitmapFactory.decodeResource(res, R.drawable.test); BitmapDrawable backWave = new BitmapDrawable(backWaveImage); backWave.setTileModeX(TileMode.REPEAT); backWave.setBounds(0, this.horizon, this.width, this.horizon + backWaveImage.getHeight()); backWave.draw(c); </code></pre> <p>where c - is canvas. This code produces nothing.</p> <p>If I add <code>backWave.setTileModeY(TileMode.REPEAT);</code> I get the following: <img src="https://i.stack.imgur.com/f55Ez.png" alt=""></p> <p>Image seems to be incorrectly scaled or smth. I've got picture in drawable dir, so it's being upscaled.</p> <p>If I draw a single image (without <code>BitmapDrawable</code>) everything looks fine. I've played with Gravity, with various TileModes. I've even tried to use <code>Shader</code>, but nothing helped.</p> <p>This issue makes me crazy. Please, help.</p> <p><strong>2 WarrenFaith</strong></p> <p>There's not much to show. I've got a basic drawFrame() function from CubeLiveWallpaper demo. I believe it works fine.</p> <p>I've done more tests. This time 5x5 red square with white center.</p> <pre><code>backWave.setTileModeX(TileMode.REPEAT); backWave.setGravity(Gravity.LEFT | Gravity.TOP); backWave.setTileModeY(TileMode.REPEAT); </code></pre> <p>This code produces the following: <img src="https://i.stack.imgur.com/N9inF.png" alt=""></p> <p>Square is being upscaled to 8x8 pixels, that's ok, but it's definitely misaligned.</p> <pre><code>backWave.setTileModeX(TileMode.REPEAT); backWave.setGravity(Gravity.LEFT | Gravity.TOP); backWave.setTileModeY(TileMode.CLAMP); </code></pre> <p>gets me something unexpected:</p> <p><img src="https://i.stack.imgur.com/XGZQb.png" alt="enter image description here"></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload