Two questions - drawing a single pixel and writing vertically

C

C

In VB6, PSet was very good. Now I have tried various things and
nothing works well enough. FillEllipse,DrawEllipse,DrawLine all
produce either a small line of 2 pixels or something else other than a
single pixel, when I am plotting dozens of points. What is a good way
to draw a single pixel?

Writing vertical text was done using GDI in VB6. Now there are
probably simpler ways using the RotateTransform. Could someone tell me
how to write a string like "temperature" vertically (say, the label on
a y axis) with minimal, simple code? Thanks.
 
A

Armin Zingler

Am 12.09.2010 20:35, schrieb C:
In VB6, PSet was very good. Now I have tried various things and
nothing works well enough. FillEllipse,DrawEllipse,DrawLine all
produce either a small line of 2 pixels or something else other than a
single pixel, when I am plotting dozens of points. What is a good way
to draw a single pixel?
http://bobpowell.net/single_pixel_lines.htm
http://bobpowell.net/pixel_dot.htm

Writing vertical text was done using GDI in VB6. Now there are
probably simpler ways using the RotateTransform. Could someone tell me
how to write a string like "temperature" vertically (say, the label on
a y axis) with minimal, simple code? Thanks.


http://msdn.microsoft.com/en-us/library/da9f790s(VS.90).aspx
 
C

C


Looks like VB.net is too inefficient inspite of a huge number of
classes, objects, properties.

I didn't like the idea of creating a 1 pixel bitmap and then drawing
it unscaled every time I want to paint one pixel.

This seems to draw only pointing downwards, which is not suitable for
writing a string or a label for the y-axis. Is there some StringFormat
which will write vertically but upwards?

Thanks.
 
A

Armin Zingler

Am 14.09.2010 19:23, schrieb C:
Looks like VB.net is too inefficient inspite of a huge number of
classes, objects, properties.

The problem is that the .Net Framework is based on GDI+ in opposite to
GDI with VB6. The Graphics class
http://msdn.microsoft.com/en-us/library/ms534453(VS.85).aspx
- you won't see a difference to .Net's Graphics class - does not have
a SetPixel method.
But what you can do is draw a line from 50 to 50.4, so you get a 1 pixel wide
line.
I didn't like the idea of creating a 1 pixel bitmap and then drawing
it unscaled every time I want to paint one pixel.

You can, instead, always paint on a Bitmap, which has a SetPixel method,
then draw the Bitmap that is used as a background buffer on the graphics
object.
This seems to draw only pointing downwards, which is not suitable for
writing a string or a label for the y-axis. Is there some StringFormat
which will write vertically but upwards?

Haven't tried it, but by applying rotation, as mentioned by yourself, you
can draw in any direction.
 
T

Tom Shelton

C wrote on 9/14/2010 :
Looks like VB.net is too inefficient inspite of a huge number of
classes, objects, properties.

This is not a VB.NET issue - it is a GDI+ issue. GDI+ is resolution
independant, and therefore has no pixel drawing type functions. .NET
uses GDI+ for it's drawing.
I didn't like the idea of creating a 1 pixel bitmap and then drawing
it unscaled every time I want to paint one pixel.

Why? It's simple and fast.
This seems to draw only pointing downwards, which is not suitable for
writing a string or a label for the y-axis. Is there some StringFormat
which will write vertically but upwards?

Write it to a bitmap, with the backcolor set with a transparent color,
then rotate it the way you need it.
 
C

C

Am 14.09.2010 19:23, schrieb C:



The problem is that the .Net Framework is based on GDI+ in opposite to
GDI with VB6. The Graphics classhttp://msdn.microsoft.com/en-us/library/ms534453(VS.85).aspx
- you won't see a difference to .Net's Graphics class - does not have
a SetPixel method.
But what you can do is draw a line from 50 to 50.4, so you get a 1 pixel wide
line.

Thanks. This is simple and will hopefully work every time.
You can, instead, always paint on a Bitmap, which has a SetPixel method,
then draw the Bitmap that is used as a background buffer on the graphics
object.

I always use frmImage As Bitmap and then Dim g As Graphics =
Graphics.FromImage(frmImage). Perhaps SetPixel on this frmImage should
work equally well.
 
C

C

C wrote on 9/14/2010 :



This is not a VB.NET issue - it is a GDI+ issue.  GDI+ is resolution
independant, and therefore has no pixel drawing type functions.  .NET
uses GDI+ for it's drawing.


Why?  It's simple and fast.

It is not simple in terms of code. What I could do earlier with one
line of code will now need several.
Write it to a bitmap, with the backcolor set with a transparent color,
then rotate it the way you need it.

I am very much a beginner. I will appreciate if you could kindly write
this in VB.net. Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top