473,387 Members | 1,504 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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.FromImage(gBmp);

gB.DrawEllipse(pen.WHITE, point1.X, point1.Y, 1, 1);
gB.DrawRectangle(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 21008
Have u looked at the bitmap.setpixel() method?

<ct*****@gmail.comwrote in message
news:11**********************@x40g2000prg.googlegr oups.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.FromImage(gBmp);

gB.DrawEllipse(pen.WHITE, point1.X, point1.Y, 1, 1);
gB.DrawRectangle(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.DrawImageUnscaled(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
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...
5
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...
4
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
by: Hamster | last post by:
How can I draw 1x1 pixel dot?
1
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...
1
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...
2
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...
7
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...
0
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...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...

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.