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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:59:01+00:00 2026-05-13T17:59:01+00:00

this creates streaks instead of dots. why ? I am trying to paint individual

  • 0

this creates streaks instead of dots. why ? I am trying to paint individual pixels. another method was also tried (using fillrectangle) , which also didn’t give the desired result, got bars instead of dots.

protected override void OnPaint(PaintEventArgs pea )
    {

         Graphics g = pea.Graphics ;

         for ( int y = 1 ; y <= Width ; y++ )
         {
            for (  int x  =  1  ; x <=  Height    ; x++ )
            {
                System.Random rand = new  System.Random() ;
                Color c =   (Color.FromArgb(rand.Next(256),
                                    rand.Next(256),
                                    rand.Next(256)));
            // SolidBrush myBrush = new SolidBrush(c);
            // g.FillRectangle(myBrush, x, y, 1, 1);


                 Bitmap pt = new Bitmap(1, 1);
                 pt.SetPixel(0, 0, c);
                 g.DrawImageUnscaled(pt, x, y);

            }
        }

}

what is happening here ?

  • 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-13T17:59:01+00:00Added an answer on May 13, 2026 at 5:59 pm

    You should not create a new Random object each time. Since that will give you the exact same “random” numbers repeated over and over.

    Instead use the same Random object and just call Next on in.

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

Sidebar

Related Questions

Trying to use GridBagLayout. I have the method called buildLabel. This creates three label.
I'm creating multiple asynchronous web requests using IObservables and reactive extensions. So this creates
This method works as expected - it creates a JTree with a root node
This function creates & stores a cookie, and here it stores the name of
Consider statement: String s=new String(abc); Will this statement creates two String objects namely abc
I'm working on a navigation control. I have nested lists which creates this: What
Well ive got this code that creates a table from JSON data. If a
Hi I have been working on this code that creates a table with radio
I have made a program that scans rss feeds. This same program creates feeds
I have this JavaScript code that creates a table, and puts in the rows

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.