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

  • Home
  • SEARCH
  • 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 3750814
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T08:59:08+00:00 2026-05-19T08:59:08+00:00

I have tried, literally for hours, and I have not been able to budge

  • 0

I have tried, literally for hours, and I have not been able to budge this problem.

I have a UserControl, that is 800×369, and it contains, simply, a path that forms a worldmap.
I put this on a landscape page, then I render it into a WriteableBitmap.
I then run a conversion to turn the 1d Pixels array into a 2d array of integers.
Then, to check the conversion, I wire up the custom control’s click command to use the Point.X and Point.Y relative to the custom control in the newly created array.
My logic is thus:

wb = new WriteableBitmap(worldMap, new TranslateTransform());
wb.Invalidate();
intTest = wb.Pixels.To2DArray(wb.PixelWidth);

My conversion logic is as such:

public static int[,] To2DArray(this int[] arr,int rowLength)
{
    int[,] output = new int[rowLength, arr.Length / rowLength];
    if (arr.Length % rowLength != 0) throw new IndexOutOfRangeException();
    for (int i = 0; i < arr.Length; i++)
    {
        output[i % rowLength, i / rowLength] = arr[i];
    }
return output;
}

Now, when I do the checking, I get completely and utterly strange results: apparently all pixels are either at values of -1 or 0, and these values are completely independent of the original colours.

Just for posterity: here’s my checking code:

private void Check(object sender, MouseButtonEventArgs e)
{
    Point click = e.GetPosition(worldMap);
    ChangeNotification(intTest[(int)click.X,(int)click.Y].ToString());
}

The result show absolutely no correlation to the path that the WriteableBitmap has rendered into it. The path has a fill of solid white.

What the heck is going on? I’ve tried for hours with no luck. Please, this is the major problem stopping me from submitting my first WP7 app. Any guidance?

  • 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-19T08:59:08+00:00Added an answer on May 19, 2026 at 8:59 am

    You code works correctly, Silverlight uses pre-multiplied ARGB, so for transparent each of the RGB values will get multiplied by 0 and the final result will be 0. For white you get four 255 bytes which is -1 because of how integers are represented. You can get the bytes from an int using the BitConverter class but I’d recommend WriteableBitmapEx which has Get/SetPixel methods and handles the the pre-multiplication for you.

    If you were just looking for hex values:

    ChangeNotification(intTest[(int)click.X,(int)click.Y].ToString("X8"));

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

Sidebar

Related Questions

I have tried searching over the internet about this problem but not able to
I have literally tried every possible way on this but apparently I just can't
OK guys, I have a problem that is literally driving me crazy. Here's what
Have tried to find solutions for this and can't really come up with anything.
I have tried this: #define format(f, ...) \ int size = strlen(f) + (sizeof((int[]){__VA_ARGS__})/sizeof(int))
ive got a really weird problem. i have no clue why its not working.
For instance, I want to have a html form that looks like this: <table>
Well, I know it may sounds basic, but I have literally been looking everywhere
Apparently, Windows eats my errors. Literally. I have this C# .Net 4.0 @ VS
I have an unordered list (each list element contains some further markup but this

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.