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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T22:26:50+00:00 2026-06-02T22:26:50+00:00

my first question here. And I’m sure it’s an easy one, but I can’t

  • 0

my first question here. And I’m sure it’s an easy one, but I can’t find a solution anywhere, I’ve read lots and just can’t comprehend how to what i need to do:

  • I have a *.gif file, that I want to store in System.Drawing.Bitmap, so that I have access to GetPixel() method
  • I want to have my drawing on some control (currently trying out PictureBox)

So far what I’ve got:

  • I create a template, Bitmap from file – and that works (map_t in code)
  • I create a bitmap that will actually be drawn (map)
  • I can set my PictureBox image to a bitmap
    • I can’t change this bitmap. Or I can, but the result doesn’t show
    • I thought I’d have to create Graphic from that bitmap, then change it. I have no idea what i’m missing.

Here’s the code: MapCanvas is PictureBox on a form, everything is in MouseMove, because I was trying to make some circles around the pointer – didn’t work so I ended up with this code, which doesn’t work either. I have read every question I could find, nothing helps… Here’s the code:

namespace Projekt_innowacje
{
    public partial class MapForm : Form
    {
        Bitmap map_t;
        Bitmap map;

        public MapForm()
        {
            InitializeComponent();
            map_t = new Bitmap("map.gif", true);
            map = new Bitmap(map_t.Width, map_t.Height);
            MapCanvas.Image = map;
        }

        private void MapCanvas_MouseMove(object sender, MouseEventArgs e)
        {
            Graphics canvas = Graphics.FromImage(map);
            for (int i = 0; i <= map.Width; i++)
                for (int j = 0; j <= map.Height; j++)
                    if (map.GetPixel(i, j) == Color.Red)
                        canvas.DrawLine(new Pen(Color.Blue), i, j, i + 1, j + 1);

                        // map.SetPixel(i, j, map.GetPixel(i, j)); // also doesn't work         

            //MapCanvas.Refresh(); 
            MapCanvas.Invalidate();

            canvas.Dispose();
        }
    }
}
  • 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-02T22:26:52+00:00Added an answer on June 2, 2026 at 10:26 pm

    The code you are showing will never modify the canvas/map image unless you are making some other changes to the map image that you’re not sharing. In your loop you test map.GetPixel, however map is created as a blank image in the constructor, so none of its pixels will ever be Color.Red. Did you intend to test against your template instead?

    Also, you may want to have a look at this question which talks about comparing colors. It suggests that for basic color comparisons to use the .ToArgb() method on the color structure since the == and Equals do more than just compare the color value.

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

Sidebar

Related Questions

This is my first question here but I'm sure there are many more to
I have a quick question here. I know that the cakePHP find('first') function returns
OK, go easy on me as it's my first question here. ;) I am
This is my first question here, though I'm frequent visitor. I tried to find
First question here as a user, so please take it easy on this noob!
first question here! I'm writing a grep type program for Windows, just for fun
My first question here. The question is similar to this one: PHP: Retrying a
I'm sorry to make my first question here a bit of a simple one
my first question here: I've searched the internet and also read several question and
My first question here, so go easy on me. This is my situation: I

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.