473,666 Members | 1,991 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to do this drawing in .Net?

Hi All,

To plot a circle with changeable radius by moving mouse operation, I always write "pDC->SetROP2(R2_NOT XORPEN)" in Visual C++. My question is how to realize it in .Net (I'm using VS 2003). The following is a section of plotting a circle.

void TCircleMaze::Pl otCircle(int m_CirNo,CDC * pDC)
{
CRect rect;
CPen * def_pen = pDC->SelectObject(& redPen);

int def_R2 = pDC->SetROP2(R2_NOT XORPEN);

rect = m_devCircle.Get Rect();
pDC->Ellipse(&rect) ; // circle

// retrieve
pDC->SelectObject(d ef_pen);
pDC->SetROP2(def_R2 );

return;
}

--
"Forward Galaxia"
Nov 17 '05 #1
3 3548
XOR is not supported in GDI+ and for good reasons. See here:

http://www.interact-sw.co.uk/graphic...ideredharmful/

and here:

http://www.interact-sw.co.uk/iangblo...9/xorartifacts

The first article explains what you should do instead and why it works
better than XOR ever did. The second refers to an example of why XOR is a
really bad way of doing this.
--
Ian Griffiths - http://www.interact-sw.co.uk/iangblog/

"Galaxia" <Ga*******@gmai l.com> wrote in message
news:ut******** ******@TK2MSFTN GP12.phx.gbl...
Hi All,

To plot a circle with changeable radius by moving mouse operation, I
always write "pDC->SetROP2(R2_NOT XORPEN)" in Visual C++. My question is
how to realize it in .Net (I'm using VS 2003). The following is a section
of plotting a circle.

void TCircleMaze::Pl otCircle(int m_CirNo,CDC * pDC)
{
CRect rect;
CPen * def_pen = pDC->SelectObject(& redPen);

int def_R2 = pDC->SetROP2(R2_NOT XORPEN);

rect = m_devCircle.Get Rect();
pDC->Ellipse(&rect) ; // circle

// retrieve
pDC->SelectObject(d ef_pen);
pDC->SetROP2(def_R2 );

return;
}

--
"Forward Galaxia"

Nov 17 '05 #2
Thank you very much. It's great helpful.

--
"Forward Galaxia"

"Ian Griffiths [C# MVP]" <ia************ *@nospam.nospam > news:O2******** *****@TK2MSFTNG P12.phx.gbl...
XOR is not supported in GDI+ and for good reasons. See here:

http://www.interact-sw.co.uk/graphic...ideredharmful/

and here:

http://www.interact-sw.co.uk/iangblo...9/xorartifacts

The first article explains what you should do instead and why it works
better than XOR ever did. The second refers to an example of why XOR is a
really bad way of doing this.


--
Ian Griffiths - http://www.interact-sw.co.uk/iangblog/
Nov 17 '05 #3
Thank you very much. It's great helpful.

--
"Forward Galaxia"

"Ian Griffiths [C# MVP]" <ia************ *@nospam.nospam > news:O2******** *****@TK2MSFTNG P12.phx.gbl...
XOR is not supported in GDI+ and for good reasons. See here:

http://www.interact-sw.co.uk/graphic...ideredharmful/

and here:

http://www.interact-sw.co.uk/iangblo...9/xorartifacts

The first article explains what you should do instead and why it works
better than XOR ever did. The second refers to an example of why XOR is a
really bad way of doing this.


--
Ian Griffiths - http://www.interact-sw.co.uk/iangblog/
Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2765
by: Tomi Holger Engdahl | last post by:
I am looking for a solution to add on-line drawing tool to a phpBB discussion board. The idea would be that the users can draw their own simple drawings with the tool and attach them easily as images in the discussion. The idea is to easily add small drawings to the postings. The drawign tool should be easy to use and learn. It should be easily integrate to the phpBB system.
2
12328
by: Champika Nirosh | last post by:
Hi, I want to create drawing board application that can draw Line, rectagle, circle and free hand drawing. Each drawing need to be transparent, moveable (draggable), have bring to front and send to back feature etc. How can I do this .. where should I start?
1
3222
by: Hadar | last post by:
Hi, I'm getting "object is currently in use elsewhere" when I use System.Drawing.Graphics.MesureString. This is what I do: My controls use a utility class the helps it to mesure strings. To get the best performance for the utility class, its members, as well as the System.Drawing.Graphics object, are static:
7
8729
by: Marc Pelletier | last post by:
Hello all, I have a class which includes a method to create a chart. I want to be able to call this method from asp.net code as well as windows application code, so I have sketched it out as returning a bitmap instance. In my asp.net code I think I should call this method to return a bitmap and then somehow stream it using the response object to the Webcontrols.image. Is that right? The image object is on a page with a number of...
2
6690
by: active | last post by:
I find Bitmap.Save works for WMF files but Bitmap.FromFile does not. If I use FromFile on a WMF file that came with VS I get an exception. If I use it on a WMF file created with Bitmap.Save I don't get an exception but it appears the Bitmap is blank. Can anyone share some knowledge on this?
3
2604
by: Chris Saunders | last post by:
I am fairly new to .Net and C# but am familiar with the Win32 API. I wish to set the pixels of the client area of a window one at a time with a specific color. I have so far discovered that System.Drawing.Bitmap has a SetPixel() method but I can't seem to find out how to have the bitmap displayed. I would actually like to have the pixels appear as I set them. Regards Chris Saunders
5
3367
by: Jerry J | last post by:
I want to use the System.Drawing.Image class. According to the help file, this is an abstract base class. Because it is supposedly abstract, I created another class that inherits from it. However, when I did this I got the following error: 'System.Drawing.Image.Image()' is inaccessible due to its protection level Looking at other online examples, I found that the proper way to use it is like this:
1
3960
by: YouPoP | last post by:
I am doing an app (C# 2.0) where you can draw in a panel with your mouse in "real time". I actually have 2 problems; 1- it does not really is "real time", if your mouse move fast or very fast the line is added after a very small delay. 2-Because I use AddLine(), it adds very short lines from one point to another and it does not give a very good result. Also because of this and my "not real time" problem, when the mouse moves fast it adds...
2
2327
by: ThatsIT.net.au | last post by:
I have this code that writes a pie chart in a asp.net page, but I want to use it in a server control. When I try I get a error on the last line "Response.OutputStream" Obviously there is no response object but how do I write it to screen? Dim objBitmap As New System.Drawing.Bitmap(400, 440) Dim objGraphics As System.Drawing.Graphics objGraphics = System.Drawing.Graphics.FromImage(objBitmap) objGraphics.Clear(Drawing.Color.White)
7
3550
by: raylopez99 | last post by:
I have a logical drawing space much bigger than the viewport (the screen) and I'd like to center the viewport (the screen) to be at the center of the logical drawing space. After following the excellent transforms specified on Bob Powell's site, I still wonder if there's an easier way of centering it than the following procedure? Here is what I do now (it's awkward but it works): 1) I follow the transforms specified on Bob Powell's...
0
8445
marktang
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...
0
8781
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8551
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,...
0
8640
tracyyun
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...
0
7386
agi2029
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...
1
6198
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4198
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4369
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2771
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.