I'm using this to draw rectangles in a PictureBox image. Not all of the
rectangles are complete, and after drawing several, some of them start
disapearing. What's the reason for this?
Pen selPen = new Pen(Color.White);
Graphics graphic = this.PicBox.CreateGraphics();
..................
Point coord1 = new Point(x0, y0);
Point coord2 = new Point(x0, y);
Point coord3 = new Point(x, y0);
Point coord4 = new Point(x, y);
graphic.DrawLine(selPen, coord1, coord2);
graphic.DrawLine(selPen, coord1, coord3);
graphic.DrawLine(selPen, coord2, coord4);
graphic.DrawLine(selPen, coord3, coord4); 4 41330
"Jon Cosby" <jc****@nospam.net> wrote: I'm using this to draw rectangles in a PictureBox image. Not all of the rectangles are complete, and after drawing several, some of them start disapearing. What's the reason for this?
Unless you draw your graphics in response to a Paint event, they won't be
updated with the rest of the form. You can see this effect by dragging
another window over your window. Try something like this instead:
private void MyPictureBox_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
using Pen selPen = new Pen(Color.White)
{
// do your drawing here
}
}
PictureBox is not necessarily the best control to use, as this page
explains: http://www.bobpowell.net/picturebox.htm
P.
Bitmap bitmap = new Bitmap(100, 100);
Graphics graphic = Graphics.FromImage(bitmap);
......
Bitmap bitmap = new Bitmap(pb.Size.Width,pb.Size.Height );
pb.Image=bitmap;
or :
class MyPictureBox:PictureBox
{
protected override void OnPaint(PaintEventArgs e)
{
Graphics graphic = e.Graphics;
......
}
}
Regards,
Krzemo.
Użytkownik "Jon Cosby" <jc****@nospam.net> napisał w wiadomości
news:Zv*****************@newsread1.news.pas.earthl ink.net... I'm using this to draw rectangles in a PictureBox image. Not all of the rectangles are complete, and after drawing several, some of them start disapearing. What's the reason for this?
Pen selPen = new Pen(Color.White); Graphics graphic = this.PicBox.CreateGraphics();
..................
Point coord1 = new Point(x0, y0); Point coord2 = new Point(x0, y); Point coord3 = new Point(x, y0); Point coord4 = new Point(x, y);
graphic.DrawLine(selPen, coord1, coord2); graphic.DrawLine(selPen, coord1, coord3); graphic.DrawLine(selPen, coord2, coord4); graphic.DrawLine(selPen, coord3, coord4);
This works for Windows bitmaps and jpeg, but it doesn't like the formatting
of gif files. Is there a way to reset this?
imgFile = this.GetImageDialog.FileName.ToString();
MyBitmap = new Bitmap(imgFile);
graphic = Graphics.FromImage(MyBitmap); // A Graphics object cannot be
created from
//
an image that has an indexed pixel format.
"Krzemo" <pk****@ka.onet.pl> wrote in message
news:c6**********@news.onet.pl... Bitmap bitmap = new Bitmap(100, 100); Graphics graphic = Graphics.FromImage(bitmap);
.....
Bitmap bitmap = new Bitmap(pb.Size.Width,pb.Size.Height );
pb.Image=bitmap; or :
class MyPictureBox:PictureBox
{
protected override void OnPaint(PaintEventArgs e)
{
Graphics graphic = e.Graphics;
.....
}
}
Regards,
Krzemo.
Użytkownik "Jon Cosby" <jc****@nospam.net> napisał w wiadomości news:Zv*****************@newsread1.news.pas.earthl ink.net... I'm using this to draw rectangles in a PictureBox image. Not all of the rectangles are complete, and after drawing several, some of them start disapearing. What's the reason for this?
Pen selPen = new Pen(Color.White); Graphics graphic = this.PicBox.CreateGraphics();
..................
Point coord1 = new Point(x0, y0); Point coord2 = new Point(x0, y); Point coord3 = new Point(x, y0); Point coord4 = new Point(x, y);
graphic.DrawLine(selPen, coord1, coord2); graphic.DrawLine(selPen, coord1, coord3); graphic.DrawLine(selPen, coord2, coord4); graphic.DrawLine(selPen, coord3, coord4);
Maybe something like this:
Bitmap bitmap = new Bitmap(pb.Size.Width,pb.Size.Height );
MyBitmap = new Bitmap(imgFile);
graphic = Graphics.FromImage(bitmap);
graphic.DrawImageUnscaled(MyBitmap ,0,0,pb.Size.Width,pb.Size.Height ) ;
//draw gif image on bitmap
pb.Image=bitmap;
Regards,
Krzemo.
Użytkownik "Jon Cosby" <jc****@nospam.net> napisał w wiadomości
news:bB*****************@newsread1.news.pas.earthl ink.net... This works for Windows bitmaps and jpeg, but it doesn't like the
formatting of gif files. Is there a way to reset this?
imgFile = this.GetImageDialog.FileName.ToString(); MyBitmap = new Bitmap(imgFile);
graphic = Graphics.FromImage(MyBitmap); // A Graphics object cannot
be created from // an image that has an indexed pixel format.
"Krzemo" <pk****@ka.onet.pl> wrote in message news:c6**********@news.onet.pl... Bitmap bitmap = new Bitmap(100, 100); Graphics graphic = Graphics.FromImage(bitmap);
.....
Bitmap bitmap = new Bitmap(pb.Size.Width,pb.Size.Height );
pb.Image=bitmap; or :
class MyPictureBox:PictureBox
{
protected override void OnPaint(PaintEventArgs e)
{
Graphics graphic = e.Graphics;
.....
}
}
Regards,
Krzemo.
Użytkownik "Jon Cosby" <jc****@nospam.net> napisał w wiadomości news:Zv*****************@newsread1.news.pas.earthl ink.net... I'm using this to draw rectangles in a PictureBox image. Not all of
the rectangles are complete, and after drawing several, some of them start disapearing. What's the reason for this?
Pen selPen = new Pen(Color.White); Graphics graphic = this.PicBox.CreateGraphics();
..................
Point coord1 = new Point(x0, y0); Point coord2 = new Point(x0, y); Point coord3 = new Point(x, y0); Point coord4 = new Point(x, y);
graphic.DrawLine(selPen, coord1, coord2); graphic.DrawLine(selPen, coord1, coord3); graphic.DrawLine(selPen, coord2, coord4); graphic.DrawLine(selPen, coord3, coord4);
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Dr. Zharkov |
last post by:
Hello. I converted the project from VB6 in VB .NET 2003, however in the
following two procedures there are errors (in Help of VB .NET 2003 it is not
written, how to correct these errors):
' Plot...
|
by: akh |
last post by:
I want to use de Drag and Drop ´s event to move a picture box from a
form and within a Picture Box.
But I have behaviour if the MyPBox As PictureBox as the Globale
varible or not
Thanks for...
|
by: John |
last post by:
I created a number of pictureboxes in a panel, and want to draw lines in
those pictureboxes but I cannot. Please see the following code and make
corrections.
Thanks.
Private Sub...
|
by: kalp suth via DotNetMonster.com |
last post by:
I want to create arrows using lines on a picture in the picture box.
On clicking the button "btnShowAll", the image is loaded and the lines drawn. "RGSShowAll()" calls "DrawObjs()" which does the...
|
by: Lou |
last post by:
I have a picture box with an image loaded into it from an Image list (Its a
solid Black Image).
Next I draw some lines into the picture box.
The resulting image with the lines is NOT the return...
|
by: Yash |
last post by:
Have used DrawLine() method to draw some lines in the picturebox (sort
of a barcode) in the picturebox paint event.
This diagram has to be saved as an image in bmp or tiff format.
But the problem...
|
by: motiee |
last post by:
I'm having a problem with drawing on picturebox in vb.net programing.
I draw line(or another shape's) on picturebox, anytime screen refreshes(open dialogbox ro menu,...) the drawn line on picturebox...
|
by: swagatikasahoo |
last post by:
how to display all lines if i will scroll the picturebox. hi,
ok i m sending the code.
******************************************************
Private Sub PictureBox1_Paint(ByVal sender As Object,...
|
by: =?Utf-8?B?RG9jdG9y?= |
last post by:
I am making an application that streams video from a web camera onto the
client area of a PictureBox on a Windows CLR Form in MS Visual Studio 2005
(using C++).
The streaming video works fine, and...
|
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...
|
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...
|
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...
|
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,...
|
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,...
|
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...
|
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...
|
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 projectplanning, coding, testing,...
|
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...
| |