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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T11:31:31+00:00 2026-05-22T11:31:31+00:00

I try to write an application that create a watermarked image from the loaded

  • 0

I try to write an application that create a watermarked image from the loaded jpeg in WPF.
I want to load in WPF an jpeg image and draw it with a predifined png with a transparence region over.
I’ve tried to create two images as the RenderTargetBitmap and then create a new RenderTargetBitmap like

Image LoadSource(string file) {
  var image = new Image();
  var src = new BitmapImage(); 
  src.BeginInit(); 
  src.UriSource = new Uri(file, UriKind.Absolute);
  src.CacheOption = BitmapCacheOption.OnLoad;
  src.EndInit();
  image.Source = src;
  image.Stretch = Stretch.Uniform;
  image.Width = 1024;
  image.Height = 768;
  return image;
}

private void Window_Loaded(object sender, RoutedEventArgs e) {
  var imgA = LoadSource(@"D:\test\1.jpg");
  var imgB = LoadSource(@"D:\test\2.png");
  var bmp = new RenderTargetBitmap(1024, 768, 120, 96, PixelFormats.Pbgra32);
  bmp.Render(imgA);
  bmp.Render(imgB);
  ResultImage.Source = bmp;
}

but it doen’t work.

Can anyone point me at the solution?

  • 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-22T11:31:31+00:00Added an answer on May 22, 2026 at 11:31 am

    I have an easier solution:

    XAML:

    <DockPanel>
        <Button DockPanel.Dock="Bottom" HorizontalAlignment="Right" 
                Margin="12" Click="ButtonSave_OnClick" Content="_Save" />
        <Grid Name="MergedImage" Width="1024" Height="768" 
                HorizontalAlignment="Center" VerticalAlignment="Center" 
                AllowDrop="True" DragOver="MergedImage_DragEnter" 
                Drop="MergedImage_Drop">
            <Image Name="SourcePicture"/>
            <Image Source="Watermark.png"/>
        </Grid>
    </DockPanel>
    

    Code behind:

    void ButtonSave_OnClick(object sender, RoutedEventArgs e)
    {
        var dialog = new Microsoft.Win32.SaveFileDialog 
        { 
            DefaultExt = ".jpg", 
            Filter = "Image (.jpg)|*.jpg" 
        };
    
        if (dialog.ShowDialog() == true)
        {
            // Save my merged image as jpeg.
            // SaveAsJpeg(MergedImage, dialog.FileName);
        }
    }
    
    private void MergedImage_DragEnter(object sender, DragEventArgs e)
    {
        if (e.Data.GetDataPresent(DataFormats.FileDrop))
        {
            var fileNames = (string[])e.Data.GetData(DataFormats.FileDrop, true);
            if (fileNames.Length == 1)
            {
                var file = new FileInfo(fileNames[0]);
                if (file.Extension.ToLower() == ".png" ||
                    file.Extension.ToLower() == ".bmp" ||
                    file.Extension.ToLower() == ".jpg" ||
                    file.Extension.ToLower() == ".jpeg" ||
                    file.Extension.ToLower() == ".gif")
                {
                    e.Effects = DragDropEffects.Copy;
                    e.Handled = true;
                    return;
                }
            }
        }
        e.Effects = DragDropEffects.None;
        e.Handled = true;
    }
    
    private void MergedImage_Drop(object sender, DragEventArgs e)
    {
        if (e.Data.GetDataPresent(DataFormats.FileDrop))
        {
            var fileNames = (string[])e.Data.GetData(DataFormats.FileDrop, true);
            SourcePicture.Source = new BitmapImage(new Uri(fileNames[0], 
                UriKind.Absolute));
            Application.Current.MainWindow.Activate();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using django to create a application download site. I try to write a
I want to write an application which will create cookies for firefox. I want
If I would want to create a c# application that support multiple languages, how
I'm writing an application that needs to create a special user account hidden from
I want to create gallery application which would get thumbnails and metadata from web
I'm trying to write an application that will allow a non-administrator user to create
I'm trying to write an application that gets stock quotes from Google Finance and
I am trying to create an application that is able to write text into
I want to create simple application that detects language(using Google API) of phrase and
I try to write a simple client/server application (all application is a bluetooth service

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.