Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7844247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:48:59+00:00 2026-06-02T16:48:59+00:00

I know very little about OpenGL so please be gentle. The app needs to

  • 0

I know very little about OpenGL so please be gentle.

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.

I am seeing three visual presentations:

  1. The bitmap (a smooth 24-bit gradient) shows correctly, with no banding.

  2. The gradient shows, but with obvious banding

  3. The texture shows as flat white, no bitmap (or issues in logcat)

Here are two versions of the method to load the bitmap, and notes on the results seen with each:

    // 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;
    }

getTextureSize() returns 1024.

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T16:49:00+00:00Added an answer on June 2, 2026 at 4:49 pm

    getBitmap1

    outHeight and outWidth are used in conjunction with inJustDecodeBounds. You cannot use them to load a scaled bitmap. So the reason you are seeing a white texture is that the bitmap is not a power of two.

    getBitmap2

    you should keep a reference to the bitmap returned by decodeResource so that you can recycle it later.
    also use options.inScaled = false;to load an unscaled version of the bitmap. Also take note that createScaledBitmap may change the depth of the bitmap to RGB_565 if the original bitmap contains no alpha channel (Source);

    Questions:
    is the original Bitmap Resource square? If not your scaling code will change the aspect ratio which could result in artifacts.

    EDIT:
    so how do you scale a bitmap and preserve the bit depths?
    Easiest solution is to pass a bitmap with alpha channel into createScaledBitmap.
    You can also scale yourself like so:

                        Bitmap newBitmap = Bitmap.createBitmap(1024, 1024, Bitmap.Config.ARGB_8888);
                        Canvas canvas = new Canvas(newBitmap);
                        final int width = src.getWidth();
                        final int height = src.getHeight();
                        final float sx = 1024  / (float)width;
                        final float sy = 1024 / (float)height;
                        Matrix m = new Matrix();
                        m.setScale(sx, sy);
                        canvas.drawBitmap(src,m,null );
                        src.recycle();
    

    ANOTHER EDIT:
    take a look at this Question for pointers on how to deal with that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First, please be gentle, I know very little about DB design. I am working
I know very little about SQL. My app is running Rails 3.0.9. I have
I know very little about XML. I build reports exported from Quickbooks based in
I know very little about Ruby, so please forgive me if the answer to
I know very little about Java but I'm attempting to run this applet from
First question on here so please be nice :) I know very little about
I know very little about Javascript and jQuery, and I'm attempting to use jQuery
I know very little about encryption/hashing. I have to hash an encryption key. The
I know very little about Flash, and so is not programming in it. I
Pardon me if this has already been asked (I know very little about Data

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.