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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:08:42+00:00 2026-06-18T05:08:42+00:00

I am creating a hidden object game and am trying to mark the object

  • 0

I am creating a hidden object game and am trying to mark the object when found with an eclipse. I’ve manually saved the top left and bottom right coordinates of each picture which were obtained via the GestureListener_Tap event.

The problem is when I tried to draw an eclipse bounded by the coordinates using this code

WriteableBitmapExtensions.DrawEllipse(writeableBmp, AnsX1, AnsY1, AnsX2, AnsY2, Colors.Red);

The location of the eclipse is always off to the top left. Marking the pixel locations using the following codes show that they are indeed located differently then what I would expect from the GestureListener_Tap.

writeableBmp.SetPixel(AnsX1, AnsY1, Colors.Red);
writeableBmp.SetPixel(AnsX2, AnsY2, Colors.Red);

My code for marking the location:

    private void fadeOutAnimation_Ended(object sender, EventArgs e)
    {

        WriteableBitmap writeableBmp = new WriteableBitmap(bmpCurrent);
        imgCat.Source = writeableBmp;
        writeableBmp.GetBitmapContext();

        WriteableBitmapExtensions.DrawEllipse(writeableBmp, AnsX1, AnsY1, AnsX2, AnsY2, Colors.Red);
        writeableBmp.SetPixel(AnsX1, AnsY1, Colors.Red);
        writeableBmp.SetPixel(AnsX2, AnsY2, Colors.Red);

        // Present the WriteableBitmap
        writeableBmp.Invalidate();       

        //Just some animation code
        RadFadeAnimation fadeInAnimation = new RadFadeAnimation();
        fadeInAnimation.StartOpacity = 0.2;
        fadeInAnimation.EndOpacity = 1.0;
        RadAnimationManager.Play(this.imgCat, fadeInAnimation);

    }

What am I missing?

EDIT:

My answer below does not take into account the screen orientation changed. See my comment below the answer. How do you map pixel coordinates to image coordinate?

EDIT 2:

Found a correct solution. Updated my answer

  • 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-18T05:08:44+00:00Added an answer on June 18, 2026 at 5:08 am

    From @PaulAnnetts comment I managed to transform the pixel coordinates. My inital mistake was to assume the image coordinates are the same as the pixel coordinates! I use the following code to convert.

        private int xCoordinateToPixel(int coordinate)
        {
            double x;
            x = writeableBmp.PixelWidth / imgCat.ActualWidth * coordinate;
            return Convert.ToInt32(x);
        }
    
        private int yCoordinateToPixel(int coordinate)
        {
            double y;
            y = writeableBmp.PixelHeight / imgCat.ActualHeight * coordinate;
            return Convert.ToInt32(y);
        }
    

    EDIT:

    Since PixelHeight and PixelWidth is fixed, and ActualHeight & ActualWidth isn’t, I should convert pixel to coordinate in the GestureListerner_Tap event.

            if ((X >= xPixelToCoordinate(AnsX1) && Y >= yPixelToCoordinate(AnsY1)) && (X <= xPixelToCoordinate(AnsX2) && Y <= yPixelToCoordinate(AnsY2)))
            {...}
    

    And my pixel to coordinate converters

        private int xPixelToCoordinate(int xpixel)
        {
            double x = imgCat.ActualWidth / writeableBmp.PixelWidth * xpixel;
    
            return Convert.ToInt32(x);
        }
    
        private int yPixelToCoordinate(int ypixel)
        {
            double y = imgCat.ActualHeight / writeableBmp.PixelHeight * ypixel;
            return Convert.ToInt32(y);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Creating a simple RPG game, first time using XNA. Trying to get my character
I need one hidden iframe for all opened Firefox windows. For now I'm creating
Creating a server-side socket will fail if I'm trying to use the same port
I'm printing a document by creating a System.Diagnostics.Process object and then setting the StartInfo
I have a few questions relating to a Transaction object that I'm creating. Transaction
I am creating an object dynamically. I am wondering how do I access it?
I'm having trouble creating an Image/Bitmap object in C# from a base64 encoded byte
I have a player, game, shot, round and team model. When creating a shot,
Ok, I am dynamically creating hidden input fields as follows: $(<input type='hidden' id=pid'+postid+-title name='posts[+postid+][title]'
Creating a class at runtime is done as follows: klass = Class.new superclass, &block

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.