Main Page | Report this Page
.NET DotNet Forum Index  »  Visual C# Forum  »  How to draw a one-pixel line??...
Page 2 of 2    Goto page Previous  1, 2

How to draw a one-pixel line??...

Author Message
Peter Duniho...
Posted: Thu Nov 05, 2009 12:26 am
Guest
Loren Pechtel wrote:
Quote:
Confirmed--it's drawn right, rendered wrong. It doesn't take blowing
it up to find, either.

Ok, I've been barking up the wrong tree. What could be causing the
errant display?

Lots of things. With a concise-but-complete code example, we could at
least examine how you're using .NET and see whether there's anything
there that would cause the problem. My guess is that it will turn out
to be a system configuration issue, with nothing at all to do with C# or
..NET (in which case, you'll want to try to reproduce similar behavior
with a delivered application -- e.g. WordPad, Paint, etc. -- so that you
can repost your question in a different context, in a different forum).

Obviously, the first thing should be to review everything you're doing
in terms of presenting the bitmap on the screen, to see if you can find
any code or Designer settings you might have enabled that cause some
scaling to occur.

But without a concise-but-complete code example, there's really nothing
more we can offer here in terms of specifics. And even with one, it's
entirely possible the answer will be "works fine on my machine...you
have a configuration problem".

One thing that does come to mind, along the "configuration" lines, is to
verify that your display is using digital input and is a discrete
display technology. Specifically, LCD or plasma, using a DVI or HDMI
input. If the signal is analog at any point, whether in transmission to
the display or in the display itself (e.g. CRT), then that could explain
the results right there. I've never seen any analog output that doesn't
have at least a little blurring.

If you're using an analog signal to an LCD, you _might_ be able to
adjust the synchronization settings (most LCD monitors have an
"auto-adjust", but at the very least there should be manual
image-registration controls) that allows you to get the image as clear
as possible. That still won't provide the perfect image an all-digital
presentation would, but it could be good enough for your purposes.

Of course, if it _is_ a configuration issue -- that is, you've posted a
concise-but-complete code example and several people have confirmed it
works fine on other computers -- then one option is to just forget about
it, at least for the moment. Smile After all, if the code is fine, you
can get on with the rest of the program rather than worrying about this
thing. :)

Pete
 
Random...
Posted: Thu Nov 05, 2009 3:23 pm
Guest
On Nov 5, 4:26 pm, Loren Pechtel <lorenpech... at (no spam) hotmail.invalid.com>
wrote:
Quote:
Since this is graphical code how can I post something that would
actually compile?  The form itself is not going to be in the file.

For the purposes of a postable example, of course it could be. Even
if it doesn't bear an resemblence to your application, it's often
helpful to go through this excercise even just to help you debug a
problem. Here's a simple self contained form that compiles and draws
a bunch of vertical lines. If this demostrated a bug, anyone else
here could run it and see the bug for themselves.

using System;
using System.Windows.Forms;
using System.Drawing;

namespace Example
{
public partial class ExampleForm : Form
{
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new ExampleForm());
}

public ExampleForm()
{
Paint += new PaintEventHandler(ExampleForm_Paint);
}

void ExampleForm_Paint(object sender, PaintEventArgs e)
{
e.Graphics.Clear(Color.White);

for (int x = 0; x < ClientSize.Width; x += 2)
{
e.Graphics.DrawLine(Pens.Black, x, 0, x,
ClientSize.Height);
}
}
}
}
 
Loren Pechtel...
Posted: Thu Nov 05, 2009 7:26 pm
Guest
On Thu, 5 Nov 2009 14:02:53 -0500, "vanderghast" <vanderghast at (no spam) com>
wrote:

Quote:
Try to change the resolution then.

It's native and when I save the image and load it with the Windows
picture viewer it works. Thus it's not the monitor but something
that's happening between the bitmap and the screen.

Quote:
Or use a texture brush.

What good would that do? (Not that it would work anyway--the stripes
aren't always the same length as each other.)
 
Loren Pechtel...
Posted: Thu Nov 05, 2009 7:26 pm
Guest
On Thu, 05 Nov 2009 13:36:11 -0800, Peter Duniho
<no.peted.spam at (no spam) no.nwlink.spam.com> wrote:

Quote:
Loren Pechtel wrote:
[...] With a concise-but-complete code example, we could at
least examine how you're using .NET and see whether there's anything
there that would cause the problem. [...]

I posted a very simple version albeit only describing how to make the
form. It misbehaved. [...]

You may find these links useful:
http://www.yoda.arachsys.com/csharp/complete.html
http://www.yoda.arachsys.com/csharp/incomplete.html
http://sscce.org/

In other words: you have yet to post a proper, useful
concise-but-complete code example.

Since this is graphical code how can I post something that would
actually compile? The form itself is not going to be in the file.
 
Random...
Posted: Thu Nov 05, 2009 7:43 pm
Guest
On Nov 5, 9:21 pm, Loren Pechtel <lorenpech... at (no spam) hotmail.invalid.com>
wrote:
Quote:
Don't you need the form information also?  There's stuff in my test
directory that isn't in this file.

My crystal ball is murky. I don't know what stuff you're talking
about. When you create a form in a designer, it generally creates 3
files, two source files and one XML file for storying resources.

The csharp compilier takes source files. Unless you've got a specific
binary resource file (i.e., images), there's no reason you can't open
the source files and post them here. After workign through the
excersize of removing any excess code, of course.
 
Peter Duniho...
Posted: Thu Nov 05, 2009 11:34 pm
Guest
Loren Pechtel wrote:
Quote:
[...]
In other words: you have yet to post a proper, useful
concise-but-complete code example.

Since this is graphical code how can I post something that would
actually compile?

You can do it the exact same way I did.

Quote:
The form itself is not going to be in the file.

It will if you put it there.

Pete
 
Loren Pechtel...
Posted: Fri Nov 06, 2009 12:21 am
Guest
On Thu, 5 Nov 2009 17:23:45 -0800 (PST), Random
<random.coder at (no spam) gmail.com> wrote:

Quote:
On Nov 5, 4:26 pm, Loren Pechtel <lorenpech... at (no spam) hotmail.invalid.com
wrote:
Since this is graphical code how can I post something that would
actually compile?  The form itself is not going to be in the file.

For the purposes of a postable example, of course it could be. Even
if it doesn't bear an resemblence to your application, it's often
helpful to go through this excercise even just to help you debug a
problem. Here's a simple self contained form that compiles and draws
a bunch of vertical lines. If this demostrated a bug, anyone else
here could run it and see the bug for themselves.

Don't you need the form information also? There's stuff in my test
directory that isn't in this file.

Quote:

using System;
using System.Windows.Forms;
using System.Drawing;

namespace Example
{
public partial class ExampleForm : Form
{
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new ExampleForm());
}

public ExampleForm()
{
Paint += new PaintEventHandler(ExampleForm_Paint);
}

void ExampleForm_Paint(object sender, PaintEventArgs e)
{
e.Graphics.Clear(Color.White);

for (int x = 0; x < ClientSize.Width; x += 2)
{
e.Graphics.DrawLine(Pens.Black, x, 0, x,
ClientSize.Height);
}
}
}
}
 
Random...
Posted: Fri Nov 06, 2009 3:45 pm
Guest
On Nov 6, 4:29 pm, Loren Pechtel <lorenpech... at (no spam) hotmail.invalid.com>
wrote:
Quote:
Which source file?  There are two for any form created in visual
studio.  One (the .Designer.cs) should be pretty much nothing but
properties you set in the form designer.

Yeah--but without it how is it going to work?

It won't, of course. Since the .designer.cs file is just normal
everyday code, you can combine the two files (and trim out bits
unrelated to your problem description) and post the results. Or, even
better yet, there's nothing stopping you from creating a form from the
ground up like's been shown in a couple of examples now.
 
Loren Pechtel...
Posted: Fri Nov 06, 2009 7:29 pm
Guest
On Fri, 6 Nov 2009 13:06:21 -0800 (PST), Random
<random.coder at (no spam) gmail.com> wrote:

Quote:
On Nov 6, 12:31 pm, Loren Pechtel <lorenpech... at (no spam) hotmail.invalid.com
wrote:
On Thu, 5 Nov 2009 21:43:11 -0800 (PST), Random
The csharp compilier takes source files.  Unless you've got a specific
binary resource file (i.e., images), there's no reason you can't open
the source files and post them here.  After workign through the
excersize of removing any excess code, of course.

I see nothing in the source file that reflects any properties I set in
the form designer.

Which source file? There are two for any form created in visual
studio. One (the .Designer.cs) should be pretty much nothing but
properties you set in the form designer.

Yeah--but without it how is it going to work?
 
Peter Duniho...
Posted: Fri Nov 06, 2009 7:38 pm
Guest
Loren Pechtel wrote:
Quote:
Which source file? There are two for any form created in visual
studio. One (the .Designer.cs) should be pretty much nothing but
properties you set in the form designer.

Yeah--but without it how is it going to work?

One more time: just look at the code example I posted for an example of
"how it is going to work".

You just need to put all the relevant stuff into a single file. It's as
simple as that.

Pete
 
 
Page 2 of 2    Goto page Previous  1, 2
All times are GMT - 5 Hours
The time now is Thu Dec 03, 2009 4:17 am