Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to use high-quality rendering for an Android resource bitmap loaded into an OpenGL texture?
    primarykey
    data
    text
    <p>I know very little about OpenGL so please be gentle.</p> <p>The app needs to load a bitmap (from resources), resize it, and use it in an OpenGL texture. I have an implementation that works, but there was a bad banding issue on the Wildfire S. So I changed the implementation and fixed the banding issue (by switching to ARGB_8888) but that then broke the functionality on the Galaxy Nexus and the Nexus One.</p> <p>I am seeing three visual presentations:</p> <ol> <li><p>The bitmap (a smooth 24-bit gradient) shows correctly, with no banding.</p></li> <li><p>The gradient shows, but with obvious banding</p></li> <li><p>The texture shows as flat white, no bitmap (or issues in logcat)</p></li> </ol> <p>Here are two versions of the method to load the bitmap, and notes on the results seen with each:</p> <pre><code> // White on Galaxy Nexus. White on Nexus One. Renders correct image (no banding) on Wildfire S private Bitmap getBitmap1() { BitmapFactory.Options options = new BitmapFactory.Options(); options.inPreferredConfig = Bitmap.Config.ARGB_8888; options.outWidth = getTextureSize(); options.outHeight = getTextureSize(); final Bitmap bmp; bmp = BitmapFactory.decodeResource(getResources(), bitmapResourceId, options); return bmp; } // Renders correctly (no banding) on Galaxy Nexus. Renders on Nexus One and Wildfire S but with obvious banding. private Bitmap getBitmap2() { int textureSize = getTextureSize(); BitmapFactory.Options options = new BitmapFactory.Options(); options.inPreferredConfig = Bitmap.Config.ARGB_8888; options.outWidth = getTextureSize(); options.outHeight = getTextureSize(); final Bitmap bmp; bmp = Bitmap.createScaledBitmap(BitmapFactory.decodeResource(getResources(), bitmapResourceId, options), textureSize, textureSize, true); return bmp; } </code></pre> <p>getTextureSize() returns 1024.</p> <p>How do I build a single method that shows the bitmap without banding on all devices, and without any devices show a big white box?</p>
    singulars
    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.
 

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