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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:36:11+00:00 2026-06-10T10:36:11+00:00

I have two Image controls on each other and I set the alpha channel

  • 0

I have two Image controls on each other and I set the alpha channel of some pixels to zero, from the upper one(this is the colorful). But after I “zoom” (width the ScaleTransform), a “border” will be visible around the pixels that have set. Here is a screenshot:

enter image description here

Here is the code:

        <Grid Name="grdPhotos">
            <Image Stretch="None" Source="picture_grayscale.jpg" Name="photo1" HorizontalAlignment="Left" VerticalAlignment="Top" />
            <Image Stretch="None" Source="picture.jpg" Name="photo2" MouseLeftButtonDown="photo2_MouseLeftButtonDown" HorizontalAlignment="Left" VerticalAlignment="Top" />
        </Grid>

    private void photo2_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
    {
        var photo = photo2.Source as WriteableBitmap; // A WriteableBitmap is created before from the Source BitmapImage
        for (int x = 100; x < 200; x++)
        {
            for (int y = 100; y < 200; y++)
            {
                int index = Convert.ToInt32(photo.PixelWidth * y + x);
                if (index > 0 && index < photo.Pixels.Length)
                    SetPixelAlphaChannel(ref photo.Pixels[index], 0);
            }
        }

        var transform = new ScaleTransform { ScaleX = 2, ScaleY = 2 };
        photo1.RenderTransform = photo2.RenderTransform = transform;
    }

    public void SetPixelAlphaChannel(ref int pixel, byte value)
    {
        var color = ColorFromPixel(pixel);
        if (color.A == value)
            return;

        color.A = value;
        pixel = ColorToPixel(color);
    }

    private Color ColorFromPixel(int pixel)
    {
        var argbBytes = BitConverter.GetBytes(pixel);
        return new Color { A = argbBytes[3], R = argbBytes[2], G = argbBytes[1], B = argbBytes[0] };
    }
    private int ColorToPixel(Color color)
    {
        var argbBytes = new byte[] { color.B, color.G, color.R, color.A };
        return BitConverter.ToInt32(argbBytes, 0);
    }

Why is this? Or how can I implement a zoom functionality without this “border”? Thanks a lot.

  • 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-10T10:36:13+00:00Added an answer on June 10, 2026 at 10:36 am

    When you zoom an image, the pixel values will be interpolated, this will result in pixels in the border are you are observing being the result of interpolating your transparent pixels with their non transparent neighbours. Unfortunately you cannot control the interpolation behaviour of render transforms. You are going to have to do this yourself, possibly via WriteableBitmap.

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

Sidebar

Related Questions

I have two models, Image and Tag . Each Image object can have more
I have two columns in my NSOutlineView. One is a Text and image cell
I have two data sets, each dataset contains the pixel values of an image.
I have two methods, one that I use to convert an image to a
I have a jQuery tools scroller set up with controls managing two separate divs
I am having two controls in that i have set the required field vaildators
I have such task - to create control that union two controls (DataGrid from
I have applied Two different Image Enhancement Algorithm on a particular Image and got
I have a MasterPage that has two image buttons , and two content pages,
I have two CIImages. I'm trying to apply a CGAffineTransformation to the top image,

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.