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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:04:08+00:00 2026-05-30T07:04:08+00:00

I have a array of Bitmaps and a array of Graphics. Initially each Bitmap

  • 0

I have a array of Bitmaps and a array of Graphics. Initially each Bitmap object have our corresponding Graphics object in these arrays. But during the work bitmaps in array may be replaced by new instances or change their positions in array.
So I need a way to find proper Graphics object that corresponding to given Bitmap object (or to make sure that is no corresponding Graphics object in graphics-array).

please look this example code in C#:

void Main()
{
   // make some bitmaps
   Bitmap b1 = new Bitmap(100,100);
   Bitmap b2 = new Bitmap(100,100);

   // make graphics of our bitmaps
   Graphics g1 = Graphics.FromImage(b1);
   Graphics g2 = Graphics.FromImage(b2);

   bool result = Test(b1, g2);
}

bool Test(Bitmap b, Graphics g)
{
   // how can I check that given "g" is really created from given "b"?
   // ???
}
  • 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-30T07:04:10+00:00Added an answer on May 30, 2026 at 7:04 am

    If the graphics are being created in a central place you could maintain a lookup table using a dictionary, Dictionary<Bitmap, Graphics>.

    Alternatively, you could also use the Tag property of the Bitmap to store a reference to the Graphics object.

       Bitmap b1 = new Bitmap(100,100); 
       Bitmap b2 = new Bitmap(100,100); 
    
       // make graphics of our bitmaps 
       Graphics g1 = Graphics.FromImage(b1); 
       Graphics g2 = Graphics.FromImage(b2); 
    
       // Track the graphics object for each bitmaps
       // NOTE: be sure to dispose the Graphics when you're done with the Bitmap.
       b1.Tag = g1;
       b2.Tag = g2;
    

    In any case, make sure you are properly disposing of your Graphics objects once you no longer need them.

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

Sidebar

Related Questions

I have a 2D array of bitmaps. Bitmap[][] b; I know how many members
Android: I have two byte arrays one byte array of bitmap and another byte
I have following array, that I need to operate by hand on bitmaps. const
I have a 2D bitmap-like array of let's say 500*500 values. I'm trying to
I have a byte array that I want to save it as a bitmap
I have a float array in java and want to convert each element to
I have an array of images named image_<somenumber>_trans.png All these images have transparent areas.
I have a 2D array of ImageViews and am currently displaying each of them
I have an MxN array of ints representing colors (say RGBA format, but that
I have read posts on passing arrays from and to activities, but I am

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.