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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:28:44+00:00 2026-06-15T17:28:44+00:00

First of all Ill explain what I try to do, just in the case

  • 0

First of all Ill explain what I try to do, just in the case that someone comes up with a better approach
I need to blend too images using the “color” stile from photoshop (you know, the blending methods: Screen, hard light, color … )

So, I have my base image (a png) and WriteableBitmap generated on execution time (lets call it color mask). Then I need to blend this two images using the “color” method and show the result in a UI component.

So far what Im trying is just to draw things on the WriteableBitmap but I’m facing unexpected behavior with the alpha channel.

My code so far:

// variables declaration
WriteableBitmap img = new  WriteableBitmap(width, height, 96,96,PixelFormats.Bgra32,null); 
pixels = new uint[width * height];

//function for setting the color of one pixel
private void SetPixel(int x, int y, Color c)
    {
        int pixel = width * y + x;

        int red = c.R;
        int green = c.G;
        int blue = c.B;
        int alpha = c.A;

        pixels[pixel] = (uint)((blue << 24) + (green << 16) + (red << 8) + alpha);

    }

//function for paint all the pixels of the image
private void Render()
    {
        Color c = new Color();
        c.R = 255; c.G = 255; c.B = 255; c.A = 50;
        for (int y = 0; y < height; y++)
            for (int x = 0; x < width; x++)
                SetPixel(x, y, c);



        img.WritePixels(new Int32Rect(0, 0, width, height), pixels, width * 4, 0);
        image1.Source = img;  // image1 is a WPF Image in my XAML
    }

Whenever I run the code with the color c.A = 255 I get the expected results. The whole Image is set to the desired color. But if I set c.A to a different value I get weird things.
If I set the color to BRGA = 0,0,255,50 I get a dark blue almost black. If I set it to BRGA = 255,255,255,50 I get a yellow …

Any clue !?!?!

Thanks in advance !

  • 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-15T17:28:45+00:00Added an answer on June 15, 2026 at 5:28 pm

    Change the order of your colour components to

    pixels[pixel] = (uint)((alpha << 24) + (red << 16) + (green << 8) + blue);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First of all I am not too sure how to explain that without sounding
Alright, Ill try to explain this as best as I can first... My program
First of all, sorry for my bad english. I'll try to explain my question:
First of all I want to state that I've just started with Drupal so
I'll try and explain this the best I can. First of all, here is
First of all, let me say that I am not a professional coder -
I'll try to explain in detail what I need: I'm parsing an RSS feed
Ive some questions about Spring Security 3.0.5 and the SecurityContext. First of all, Ill
First, I'll explain what I need to do, then how I think I can
This is my first post, so hopefully I explain what I need to do

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.