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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:17:43+00:00 2026-06-13T21:17:43+00:00

I am working on a picture editing tool in which I need to merge

  • 0

I am working on a picture editing tool in which I need to merge two images. Most of the image editing tools like gimp use PorterDuff modes for merging or blending images. I am also using the same approach in android.
As android provides limited number of PorterDuff modes, I am not able to achieve the desired result. So, I am thinking of implementing PorterDuff modes(Overlapping, Hard-Light, Soft-Light, Color-burn, Color-dodge) which are not included in android.
The problem is I don’t know where to start. So, any reference or guidance in this regard will be highly appreciated.

  • 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-13T21:17:44+00:00Added an answer on June 13, 2026 at 9:17 pm

    This is how you can implement the Overlay PorterDuff mode in android:

    public class MyPorterDuffMode
    {
    
        public Bitmap applyOverlayMode(Bitmap srcBmp, Bitmap destBmp)
        {
            int width = srcBmp.getWidth();
            int height = srcBmp.getHeight();
            int srcPixels[] = new int[width * height];;
            int destPixels[] = new int[width * height];
            int resultPixels[] = new int[width * height];
            int aS = 0, rS = 0, gS = 0, bS = 0;
            int rgbS = 0;
            int aD = 0, rD = 0, gD = 0, bD = 0;
            int rgbD = 0;
    
            try
            {
                srcBmp.getPixels(srcPixels, 0, width, 0, 0, width, height);
                destBmp.getPixels(destPixels, 0, width, 0, 0, width, height);
                srcBmp.recycle();
                destBmp.recycle();
            }
            catch(IllegalArgumentException e)
            {
            }
            catch(ArrayIndexOutOfBoundsException e)
            {
            }
    
            for(int y = 0; y < height; y++)
            {
                for(int x = 0; x < width; x++)
                {
                    rgbS = srcPixels[y*width + x];
                    aS = (rgbS >> 24) & 0xff;
                    rS = (rgbS >> 16) & 0xff;
                    gS = (rgbS >>  8) & 0xff;
                    bS = (rgbS      ) & 0xff;
    
                    rgbD = destPixels[y*width + x];
                    aD = ((rgbD >> 24) & 0xff);
                    rD = (rgbD >> 16) & 0xff;
                    gD = (rgbD >>  8) & 0xff;
                    bD = (rgbD      )  & 0xff;
    
                    //overlay-mode
                    rS = overlay_byte(rD, rS, aS, aD);
                    gS = overlay_byte(gD, gS, aS, aD);
                    bS = overlay_byte(bD, bS, aS, aD);
                    aS = aS + aD - Math.round((aS * aD)/255f);
    
                    resultPixels[y*width + x] = ((int)aS << 24) | ((int)rS << 16) | ((int)gS << 8) | (int)bS;
                }
            }
    
            return Bitmap.createBitmap(resultPixels, width, height, srcBmp.getConfig());
        }
    
    
    
        // kOverlay_Mode
        int overlay_byte(int sc, int dc, int sa, int da) {
            int tmp = sc * (255 - da) + dc * (255 - sa);
            int rc;
            if (2 * dc <= da) {
                rc = 2 * sc * dc;
            } else {
                rc = sa * da - 2 * (da - dc) * (sa - sc);
            }
            return clamp_div255round(rc + tmp);
        }
    
    
        int clamp_div255round(int prod) {
            if (prod <= 0) {
                return 0;
            } else if (prod >= 255*255) {
                return 255;
            } else {
                return Math.round((float)prod/255);
            }
        }
    
    }
    

    Note: While extracting the bitmaps set the configuration to be ARGB_8888 and this is important.
    Any time you want to do image blending or color manipulation, you need to make sure you are in ARGB_8888 mode, not in RGB_565 mode. Up until 2.3, android will usully default to RGB_565 mode unless you explicitly tell it to do otherwise in order to save memory.

    BitmapFactory.Options opt = new BitmapFactory.Options();
    opt.inPreferredConfig = Config.ARGB_8888;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Iam working on app for iOS5. I would like to have a big picture
I have a code of picture resizing and image thumbnail working fine but it
I've been working on a little application which grabs strings embedded within a picture,
Am working on some application. However, i have finished two modules which invoke the
Everything is working fine with FBProfilePictureView but I need to get that picture from
I'm working on a page on which I'm dynamically creating a Facebook Like button
I'm working on an Android application using the Aviary picture editing library, but have
I am working on a simple image gallery with a larger picture displayed above
i use this code but its not working $uid =$facebook->getUser(); $picture=http://graph.facebook.com/.$uid./picture?type=large;
I'm working on a picture select/crop program and using this code below: http://www.androidworks.com/crop_large_photos_with_android/comment-page-1#comment-969 As

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.