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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:07:48+00:00 2026-06-12T12:07:48+00:00

I have the following task. Take a base image and overlay on it another

  • 0

I have the following task. Take a base image and overlay on it another one. The base image is 8b png as well as overlay.
Here are the base (left) and overlay (right) images.

Overlay image
Overlay image

Here is a result and how it must look.

enter image description here
enter image description here

The picture in the left is a screenshot when one picture is on top of another (html and positioning) and the second is the result of programmatic merging.

As you can see in the screenshot the borders of the text is darker. Also here are the sizes of the images

  • Base image 14.9 KB
  • Overlay image 6.87 KB
  • Result image 34.8 KB

The size of the resulting image is also huge

Here is my code that I use to merge those pictures

/*...*/
public Stream Concatinate(Stream baseStream, params Stream[] overlayStreams) {
    var @base = Image.FromStream(baseStream);
    var canvas = new Bitmap(@base.Width, @base.Height);
    using (var g = canvas.ToGraphics()) {
        g.DrawImage(@base, 0, 0);
        foreach (var item in overlayStreams) {
            using (var overlayImage = Image.FromStream(item)) {
                try {
                    Overlay(@base as Bitmap, overlayImage as Bitmap, g);
                } catch {

                }
            }
        }
    }
    var ms = new MemoryStream();
    canvas.Save(ms, ImageFormat.Png);
    canvas.Dispose();
    @base.Dispose();
    return ms;
}

/*...*/
/*Tograpics extension*/
public static Graphics ToGraphics(this Image image,
    CompositingQuality compositingQuality = CompositingQuality.HighQuality,
    SmoothingMode smoothingMode = SmoothingMode.HighQuality,
    InterpolationMode interpolationMode = InterpolationMode.HighQualityBicubic) {
    var g = Graphics.FromImage(image);

    g.CompositingQuality = compositingQuality;
    g.SmoothingMode = smoothingMode;
    g.InterpolationMode = interpolationMode;
    return g;
}
private void Overlay(Bitmap source, Bitmap overlay, Graphics g) {
    if (source.Width != overlay.Width || source.Height != overlay.Height)
        throw new Exception("Source and overlay dimensions do not match");
    var area = new Rectangle(0, 0, source.Width, source.Height);
    g.DrawImage(overlay, area, area, GraphicsUnit.Pixel);
}

My questions are

  • What should I do in order to merge images to achieve the result as in the screenshot?
  • How can I lower the size of the result image?
  • Is the System.Drawing a suitable tool for this or is there any better tool for working with png for .NET?
  • 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-12T12:07:49+00:00Added an answer on June 12, 2026 at 12:07 pm

    The answers to your questions are:
    1) Just call method ToGraphics with a argument CompositingQuality.Default instead of using default argument values like in the example:

    using (var g = canvas.ToGraphics(compositingQuality: CompositingQuality.Default)) 
    

    The problem is with CompositingQuality.HighQuality is that it makes a composition of both images into one, but you want to make an overlay, not to make a composition of two images.

    2) The size will be similar to the one you specified and that can not be changed, it is due to a image format.

    3) If you are programming in c# for desktop, than System.Drawing is the best choice as far as I know.

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

Sidebar

Related Questions

I have following task: Implement a mechanism that can take any collection of objects
I have the following task: there are a simple table from mysql database: <html>
I have the following task, which because of the combination of DestinationFiles and DestionationFolder
I have the following task in my MSBuild script: <Target Name=ZipStates> <Message Text=CREATING ZIP
I have the following exec task, performing checkin of assemblyinfo.cs files. I'm trying to
I have the following beans Task, ServerDetails and ApplicationDetails. I wish to retrieve all
I have the following situation: var Task = Backbone.Model.extend({ initialize: function() { }, save:
I am charged with the following task in a Rails project. Clients will have
i have the following code to disable task manager of windows xp but it
I have a simple function as the following: static Task<A> Peirce<A, B>(Func<Func<A, Task<B>>, Task<A>>

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.