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

  • SEARCH
  • Home
  • 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 7090021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:59:37+00:00 2026-05-28T07:59:37+00:00

I current have some code that takes a screenshot and saves this to the

  • 0

I current have some code that takes a screenshot and saves this to the SD card (if present.) What I now need to do is remove the background colour from that screenshot so it becomes transparent however I cant figure out how that works.

Below is the code I used to take the screenshot

         int b[]=new int[w*h];
         int bt[]=new int[w*h];
         IntBuffer ib=IntBuffer.wrap(b);
         ib.position(0);
         gl.glReadPixels(x, y, w, h, GL10.GL_RGBA, GL10.GL_UNSIGNED_BYTE, ib);
         for(int i=0; i<h; i++)
         {//remember, that OpenGL bitmap is incompatible with Android bitmap
          //and so, some correction need.        
              for(int j=0; j<w; j++)
              {
                   int pix=b[i*w+j];
                   int pb=(pix>>16)&0xff;
                   int pr=(pix<<16)&0x00ff0000;
                   int pix1=(pix&0xff00ff00) | pr | pb;
                   bt[(h-i-1)*w+j]=pix1;
              }
         }                  
         Bitmap sb=Bitmap.createBitmap(bt, w, h, Bitmap.Config.RGB_565);
         return sb;

How do I remove a certain colour from that image or save it with a transparent background?

  • 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-05-28T07:59:37+00:00Added an answer on May 28, 2026 at 7:59 am

    Why don’t you examine the value of ‘pix1’? So

    if(pix1 == replaceFrom)
        pix1 = replaceTo
    bt[(h-i-1)*w+j]=pix1;
    

    By the way, if you want transparent colour use ARGB_8888 instead of RGB_565.
    Furthermore, take a look at this: How to change colors of a Drawable in Android?

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

Sidebar

Related Questions

I have some code that gets the current logged in user. userID = request.session.get(_auth_user_id)
I have a problem with some code I need to refactor. Right now it
We have a scenario where some .NET code is attempting to access the current
I have some unit tests that expects the 'current time' to be different than
I have a simple class that contains some general information about the current web
For some user controls, I have this binding: AppLanguage={Binding Path=ApplicationLanguage, Source={x:Static Application.Current}} This works
Unfortunately I inherited some code (c/c++) that does some string manipulation and now I
i have some files located in c:\MyApp\file.txt and current executing assenbly in in debud
My current setup : I have an entity object with some properties, among them
Is there some way to replicate rails' link-to-unless-current? Ie. if i have a list

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.