I've been playing with "classic" VB since version 3. I have VB6 Learning
Edition. Recently, I wanted to try VB.NET. I got a beginner's book with a CD
with the software & installed it. There are things that I like about VB.NET &
there are things that I don't like. I like to do graphics like plotting math
functions & fractals & stuff. VB has Pset. In VB6, it's easy to plot a pixel.
Just use Pset. In VB.NET, it isn't. I have to create a bitmap & then set the
pixels & then draw the bitmap. VB6 makes it easier to plot pixels.
Anyway, does C# have something in the language itself, NOT in the.NET
Framework, equivalent to Pset? It obviously isn't easy to plot pixels using
the .NET Framework, that's why I'm hoping that there is something in C#
itself that's equivalent to Pset. Is there?
Thank you.
David 4 6687
pcnerd <pc****@discuss ions.microsoft. com> wrote: I've been playing with "classic" VB since version 3. I have VB6 Learning Edition. Recently, I wanted to try VB.NET. I got a beginner's book with a CD with the software & installed it. There are things that I like about VB.NET & there are things that I don't like. I like to do graphics like plotting math functions & fractals & stuff. VB has Pset. In VB6, it's easy to plot a pixel. Just use Pset. In VB.NET, it isn't. I have to create a bitmap & then set the pixels & then draw the bitmap. VB6 makes it easier to plot pixels.
Anyway, does C# have something in the language itself, NOT in the.NET Framework, equivalent to Pset?
C# knows nothing about user interfaces, graphics, etc. The only things
it intrinsically knows about the framework are things from the System
namespace: string, int, etc.
It obviously isn't easy to plot pixels using the .NET Framework, that's why I'm hoping that there is something in C# itself that's equivalent to Pset. Is there?
It's actually very, very easy. As you say, Bitmap.SetPixel is the
closest equivalent. You can set a bitmap as the background for a form or
the picture in a picturebox. Here's a complete program which uses
SetPixel to draw on the bitmap when you click on the form. If you create
a new, empty application in C# (i.e. with no forms and no classes) and
add this class to the project, it will compile. Alternatively, put it
all into a text file with a .cs extension and pass it as an argument to
csc.exe (in the C:\windows\micr osoft.net\frame work\v2.0.50727
directory).
---8<---
using System;
using System.Drawing;
using System.Windows. Forms;
class App
{
static void Main()
{
Bitmap picture = new Bitmap(500, 500);
// Draw a nice border around the picture.
using (Graphics g = Graphics.FromIm age(picture))
g.DrawRectangle (Pens.Orange, 0, 0, 499, 499);
Form form = new Form();
form.Background Image = picture;
form.Click += delegate
{
for (int i = 0; i < 500; ++i)
picture.SetPixe l(i, i, Color.White);
form.Invalidate ();
};
Application.Run (form);
}
}
--->8---
The form background causes the image to tile, but you can easily use a
PictureBox instead to avoid tiling if you want.
-- Barry
-- http://barrkel.blogspot.com/
pcnerd,
One point to note is that using SetPixel is simple from a programming point
of view but unfortunately it is very inefficient and if you want any kind of
decent performance you should not use that and use the LockBits method
instead which allows you to maipulate raw pixel values very efficiently. See http://www.bobpowell.net/lockingbits.htm for an excellent overview.
Thanks
Mark http://www.markdawson.org
"Barry Kelly" wrote: pcnerd <pc****@discuss ions.microsoft. com> wrote:
I've been playing with "classic" VB since version 3. I have VB6 Learning Edition. Recently, I wanted to try VB.NET. I got a beginner's book with a CD with the software & installed it. There are things that I like about VB.NET & there are things that I don't like. I like to do graphics like plotting math functions & fractals & stuff. VB has Pset. In VB6, it's easy to plot a pixel. Just use Pset. In VB.NET, it isn't. I have to create a bitmap & then set the pixels & then draw the bitmap. VB6 makes it easier to plot pixels.
Anyway, does C# have something in the language itself, NOT in the.NET Framework, equivalent to Pset?
C# knows nothing about user interfaces, graphics, etc. The only things it intrinsically knows about the framework are things from the System namespace: string, int, etc.
It obviously isn't easy to plot pixels using the .NET Framework, that's why I'm hoping that there is something in C# itself that's equivalent to Pset. Is there?
It's actually very, very easy. As you say, Bitmap.SetPixel is the closest equivalent. You can set a bitmap as the background for a form or the picture in a picturebox. Here's a complete program which uses SetPixel to draw on the bitmap when you click on the form. If you create a new, empty application in C# (i.e. with no forms and no classes) and add this class to the project, it will compile. Alternatively, put it all into a text file with a .cs extension and pass it as an argument to csc.exe (in the C:\windows\micr osoft.net\frame work\v2.0.50727 directory).
---8<--- using System; using System.Drawing; using System.Windows. Forms;
class App { static void Main() { Bitmap picture = new Bitmap(500, 500);
// Draw a nice border around the picture. using (Graphics g = Graphics.FromIm age(picture)) g.DrawRectangle (Pens.Orange, 0, 0, 499, 499);
Form form = new Form(); form.Background Image = picture; form.Click += delegate { for (int i = 0; i < 500; ++i) picture.SetPixe l(i, i, Color.White); form.Invalidate (); };
Application.Run (form); } } --->8---
The form background causes the image to tile, but you can easily use a PictureBox instead to avoid tiling if you want.
-- Barry
-- http://barrkel.blogspot.com/
>> Anyway, does C# have something in the language itself, NOT in the.NET Framework, equivalent to Pset?
C# knows nothing about user interfaces, graphics, etc. The only things it intrinsically knows about the framework are things from the System namespace: string, int, etc.
In fact, if you look back at the remote history of Basic, you'll find that
PSET dates from a time when Basic ran without an operating system! The
original 1981 IBM PC didn't have to have diskette drives. You could run
"Cassette Basic" from ROM and store your files on (believe it or not) a
cassette tape recorder.
Almost no one did this, but the point is that Basic could run with no
operating system at all (not even DOS). Thus all of the physical functions
of the machine had to be in the *language*, not in OS calls.
Today it's different. Today all but the simplest i/o operations are done by
passing requests to the operating system. That's why graphics is the
province of the .NET Framework rather than existing as fundamental language
constructs.
(I have on my desk a diskette drive from a 1983 PC XT. It cost $650 at the
time, so you can understand why people might want to do without them, if
they used their PC mainly as a calculator. Hard disks cost many thousands
of dollars.) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: John |
last post by:
Is there an equivalent of COM on Linux that I can get through Python.
My need is to have some sort of language independent component
framework. I can think of CORBA but I have to have a server running. I
prefer not to. I just need Python components for local consumption in
other languages. I remember Gnome libs having some thing like this.
Any thoughts?
|
by: Michael Foord |
last post by:
Please pardon my ignorance on this one - but I'm not certain how the
sign bt is treated in python bitwise operators. I've trying to convert
a javascript DES encryption routine into python.
Javascritp has >>> and >>. >>> is a zero fill bit shift whereas >> is
a sign propagating bit shift. My understanding is that the python >>
is equivalent to the javascript >> - but python has no equivalent to
>>>.
Would a >>> 3 in javascript be...
|
by: Robert Dodier |
last post by:
Hello,
Here's a thought that I'm sure has already occurred to
someone else, I just can't find any record of it yet.
An XML document is just a more verbose and clumsy representation
of an ordinary Lisp S-expression. So it's easy enough to translate
some XML into equivalent Lisp. Now I turn it over to the Lisp
parser, which creates the equivalent of the DOM for me.
|
by: Vannela |
last post by:
Is there any equivalent control in .NET for the Power
builder DataWindow control?
I am explaining the Datawindow architecture to some extent.
Power Builder DataWindow Control has got different
presentation styles and different data sources.
Presentation styles like tabular format , graph format,
grid format, freeform format, Composite format(somthing
|
by: Frank Rachel |
last post by:
So I can focus on the correct areas of research, I was wondering if someone
could give me the .NET equivelents for this J2EE architecture:
JSP's make calls to local JavaBean Controls. The controls do a JNDI lookup
to invoke methods on EJB's. The EJB's use local Java classes, and these
classes use JDBC to do database work.
Example:
Login.jsp contains "import xxx.LoginControl", and invokes the "login"
| |
by: Marty |
last post by:
Hi,
What is the VB.NET equivalent of the VB6 ADODB.Connector and
ADODB.Recordset?
Thanks
Marty
|
by: Tim Conner |
last post by:
Hi,
I am an ex-delphi programmer, and I having a real hard time with the
following simple code (example ):
Which is the equivalent to the following code ?
var
chars : PChar;
sBack, s : String;
|
by: karch |
last post by:
How would this C# contruct be represented in C++/CLI? Or is it even
possible?
PolicyLevel level = (enumerator->Current) as PolicyLevel;
Thanks,
Karch
|
by: Alan Silver |
last post by:
Hello,
I'm converting some old VB6 code to use with ASP.NET and have come
unstuck with the Asc() function. This was used in the old VB6 code to
convert a character to its ASCII numeric equivalent.
Is there such a function available in C#? I can see that VB.NET has one,
but I couldn't see how to get at it in C#.
For example, if I have ...
|
by: grid |
last post by:
Hi,
I have a certain situation where a particular piece of code works on a
particular compiler but fails on another proprietary compiler.It seems
to have been fixed but I just want to confirm if both statements are
similar :
*((char **)v)++ == *((char **)v++)
Where v is a pointer to an array of characters,defined as
char *v;
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |