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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:07:42+00:00 2026-05-26T16:07:42+00:00

I am trying to flatten a png with transparency over a bitmap with a

  • 0

I am trying to flatten a png with transparency over a bitmap with a solid colour.

so far i have this

    using (System.Drawing.Image backImage = System.Drawing.Image.FromFile(layer1imagename))

    using (System.Drawing.Image frontImage = System.Drawing.Image.FromFile(HttpContext.Current.Server.MapPath("~/") + layer2))

    using (Image IMG1 = new Bitmap(251, 400))
    using (Graphics compositeGraphics = Graphics.FromImage(IMG1))
    {
        compositeGraphics.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy;
        compositeGraphics.DrawImageUnscaled(backImage, 0, 0);
        compositeGraphics.DrawImageUnscaled(frontImage, 0, 0);
        compositeGraphics.Dispose();
        frontImage.Dispose();
        backImage.Dispose();
        IMG1.Save(layer1imagename, System.Drawing.Imaging.ImageFormat.Png);
    }

However this turns removes the transparency on the top layer. How do i retain a transparent png on the top?

  • 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-26T16:07:43+00:00Added an answer on May 26, 2026 at 4:07 pm

    change using (Image IMG1 = new Bitmap(251, 400)) to using (Image IMG1 = new Bitmap(251, 400, PixelFormat.Format32bppArgb)).

    For MSDN references see:

    • http://msdn.microsoft.com/en-us/library/3z132tat.aspx
    • http://msdn.microsoft.com/en-us/library/system.drawing.imaging.pixelformat.aspx

    EDIT – as per comment:

    To draw the PNG you want you need to use a different CompositingMode – SourceOver instead of SourceCopy.

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

Sidebar

Related Questions

Trying to do this sort of thing... WHERE username LIKE '%$str%' ...but using bound
I am trying to flatten the xml output of xstream using a converter/marshaling with
This is a tricky one. I an trying to flatten a LINQ object collection.
I am trying to flatten nested objects like this: public class Book { public
am trying to flatten an XML element based on a child element name using
I am trying to flatten a hierarchy / structure to XML using XSLT 1
I'm trying to make will_paginate's :order to work with this array: @posts = current_user.subscribed_tags.map(&:posts).flatten.paginate(:page
I am trying to flatten 3D array into 1D array for chunk system in
Trying to get my css / C# functions to look like this: body {
Trying to keep all the presentation stuff in the xhtml on this project and

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.