473,545 Members | 2,070 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to draw only one pixel on form

I need to draw only 1 pixel but I can not found out the way...

I tried to use like following in some function
(point1 is Point instance)

Graphics gB = Graphics.FromIm age(gBmp);

gB.DrawEllipse( pen.WHITE, point1.X, point1.Y, 1, 1);
gB.DrawRectangl e(pen.WHITE, point1.X, point1.Y, 1, 1);
gB.DrawLine(pen .WHITE, point1,point1);

All of above example are not drawing only 1 pixel (looks 4 pixel...)

Someone recommand me drawEllipse or drawLine but the result was not
only 1 pixel...
I tried to find out the solution in web site but I could not find....

How to draw ONLY one pixel?????

Aug 23 '07 #1
2 21020
Have u looked at the bitmap.setpixel () method?

<ct*****@gmail. comwrote in message
news:11******** **************@ x40g2000prg.goo glegroups.com.. .
>I need to draw only 1 pixel but I can not found out the way...

I tried to use like following in some function
(point1 is Point instance)

Graphics gB = Graphics.FromIm age(gBmp);

gB.DrawEllipse( pen.WHITE, point1.X, point1.Y, 1, 1);
gB.DrawRectangl e(pen.WHITE, point1.X, point1.Y, 1, 1);
gB.DrawLine(pen .WHITE, point1,point1);

All of above example are not drawing only 1 pixel (looks 4 pixel...)

Someone recommand me drawEllipse or drawLine but the result was not
only 1 pixel...
I tried to find out the solution in web site but I could not find....

How to draw ONLY one pixel?????

Aug 23 '07 #2
I searched for a long time today to answer this question and finally
found something that works:

System.Drawing. Bitmap bm = new System.Drawing. Bitmap(1,1);
bm.SetPixel(0, 0, color);
graphics.DrawIm ageUnscaled(bm, x , y);

Creates a new 1x1 bitmap, sets it color, then adds it to your graphics
object. I lost the source where I found this now, but many thanks to
whomever that was!

Aug 30 '07 #3

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

Similar topics

2
1635
by: Ivan D | last post by:
(planning to do this in C#) plz, if you know tell me :) Im interested in handling the drawing to a surface manually pixel by pixel. For example I want to draw a 640x480 image according to some method I make, perhaps each pixel is randomly colored. I know there is the set pixel method, but thats not fast enough for such a large surface. So...
5
2496
by: George | last post by:
I cannot understand how to fix my code so that it will work. It needs to draw a series of lines in different colors and save it to a ppm file. Could someone tell me what I have done wrong. Thanks a lot. #include <stdio.h> #include <stdlib.h> #include <assert.h> struct Pixel {
4
12769
by: Pat Keel | last post by:
Hi there, Im looking for a solution to draw a one pixel sized point to a graphics control. E.g. DrawLine(10,10, 11,11) draws 2 pixels, DrawLine(10,10, 10,10) has no effect. How to do? Thanks Pat
1
1568
by: Hamster | last post by:
How can I draw 1x1 pixel dot?
1
3001
by: Carsten Klotz | last post by:
Hi, I've set the TransparencyKey of a form to black. That means, all black pixel will be shown transparent within the drawing content of that form. If I set the background to black, I can see the underlying window (ie. Desktop or IE). But when I want to draw with the mouse inside that transparent area, my form/window lost its focus...
1
4102
by: Robert W. | last post by:
In my Winforms app I'm trying to get an image's background to appear transparent on a form that has a gradient background. So I added a PictureBox and then attempted to add a custom paint command for the PictureBox. But it's not working. Here's the code I've written: public void InitializeLinearGradients() { this.Paint += new...
2
3113
by: dan heskett | last post by:
I am owner-drawing a listbox, in an attempt to create a nice list with some custom "fields" and text layout. Essentially it works, but I must be missing something big, conceptually, because I get all kinds of screen artifacts and weirdness. My general goal is: list item with a few areas for text, every other item shaded a light color for...
7
10684
by: Mark Ingram | last post by:
Hi, how can i draw a rounded rectange, with a border within a specified area? i.e. if i have a Rectangle with width and height of 100, how can i draw a rectange with 2 pixel border inside of the original one? (the current attempts all draw the border just outside of the original rectangle). At the moment im using the following code, but...
0
1336
by: Kevinst | last post by:
Hello, currently I am working on the following scenario: There is a device connected to my application. That device has a 256x256 pixel display showing graphics and text. Now for each pixel of that display I receive a flag whether the pixel is to be drawn or not. Furthermore to display text you can imagine the surface as divided in 21...
0
7473
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...
0
7661
Oralloy
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. ...
0
7815
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...
0
5976
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...
0
4949
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...
0
3458
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...
0
3444
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1891
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
0
712
bsmnconsultancy
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...

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.