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 8057023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:53:48+00:00 2026-06-05T08:53:48+00:00

I call a C++ function over JNI and pass a RGBA_8888 bitmap, lock it,

  • 0

I call a C++ function over JNI and pass a RGBA_8888 bitmap, lock it, change the values, unlock it, return and then display it in Java with this C++ code:

AndroidBitmap_getInfo(env, map, &info) < 0);
AndroidBitmap_lockPixels(env, map, (void**)&pixel);

for(i=info.width*info.height-1;i>=0;i--)
{   pixel[i] = 0xf1f1f1f1;
}

AndroidBitmap_unlockPixels(env, map);

The problem I have is that the bitmaps looks not as I expect it and the pixel values (verified with getPixel) are not the same when I check them in Java from what I set them in C++. When I set the bitmap values to 0xffffffff I get the correct value in Java, but for many others I don’t. 0xf1f1f1f1 for example turns into 0xF1FFFFFF.

What do I have to do to make it work ?

PS: I am using Android 2.3.4

  • 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-05T08:53:51+00:00Added an answer on June 5, 2026 at 8:53 am

    It appears the problem is because of the premultiplied alpha.

    Further testing revealed that the r,g,b values get scaled by the alpha so if I pass a bitmap to jni I need to multiply the r,g,b values by 255 and divide them by the alpha to have the real value that I can do alpha-operations with. When I pass them back I have to do the reverse.

    For only copying and operations without alpha that is not necessary, as the alpha will be 255 for maximum opacity and * 255 / 255 negates itself.

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

Sidebar

Related Questions

I want Java Timer to call function n times after every t seconds. I
How can you call a Function over some part of a container, using for_each()
I'd like call a function every time a user drags their mouse over an
I want to call COUNT_BIG function over my table. This table returns a lot
Basic PHP function: //SOAP CALL function sayHello(){ $client = new SoapClient('http://Server:8080/MyClassService/MyClass?WSDL'); $response = $client->glassfishHello();
Possible Duplicate: Call Function in Underlying ViewController as Modal View Controller is Dismissed I've
Possible Duplicate: How to call function in every “X” minute? How to periodically call
How do you call function lol() from outside the $(document).ready() for example: $(document).ready(function(){ function
Is it possible to call function within the same function without specifying the function
After ul tag i want to call function in javascript to add list item

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.