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.Cre ateGraphics();
............... ...
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.DrawLin e(selPen, coord1, coord2);
graphic.DrawLin e(selPen, coord1, coord3);
graphic.DrawLin e(selPen, coord2, coord4);
graphic.DrawLin e(selPen, coord3, coord4); 4 41410
"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_Pa int(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.FromIm age(bitmap);
......
Bitmap bitmap = new Bitmap(pb.Size. Width,pb.Size.H eight );
pb.Image=bitmap ;
or :
class MyPictureBox:Pi ctureBox
{
protected override void OnPaint(PaintEv entArgs e)
{
Graphics graphic = e.Graphics;
......
}
}
Regards,
Krzemo.
Użytkownik "Jon Cosby" <jc****@nospam. net> napisał w wiadomości
news:Zv******** *********@newsr ead1.news.pas.e arthlink.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.Cre ateGraphics();
............... ...
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.DrawLin e(selPen, coord1, coord2); graphic.DrawLin e(selPen, coord1, coord3); graphic.DrawLin e(selPen, coord2, coord4); graphic.DrawLin e(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.GetImageDi alog.FileName.T oString();
MyBitmap = new Bitmap(imgFile) ;
graphic = Graphics.FromIm age(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.FromIm age(bitmap);
.....
Bitmap bitmap = new Bitmap(pb.Size. Width,pb.Size.H eight );
pb.Image=bitmap ; or :
class MyPictureBox:Pi ctureBox
{
protected override void OnPaint(PaintEv entArgs e)
{
Graphics graphic = e.Graphics;
.....
}
}
Regards,
Krzemo.
Użytkownik "Jon Cosby" <jc****@nospam. net> napisał w wiadomości news:Zv******** *********@newsr ead1.news.pas.e arthlink.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.Cre ateGraphics();
............... ...
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.DrawLin e(selPen, coord1, coord2); graphic.DrawLin e(selPen, coord1, coord3); graphic.DrawLin e(selPen, coord2, coord4); graphic.DrawLin e(selPen, coord3, coord4);
Maybe something like this:
Bitmap bitmap = new Bitmap(pb.Size. Width,pb.Size.H eight );
MyBitmap = new Bitmap(imgFile) ;
graphic = Graphics.FromIm age(bitmap);
graphic.DrawIma geUnscaled(MyBi tmap ,0,0,pb.Size.Wi dth,pb.Size.Hei ght ) ;
//draw gif image on bitmap
pb.Image=bitmap ;
Regards,
Krzemo.
Użytkownik "Jon Cosby" <jc****@nospam. net> napisał w wiadomości
news:bB******** *********@newsr ead1.news.pas.e arthlink.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.GetImageDi alog.FileName.T oString(); MyBitmap = new Bitmap(imgFile) ;
graphic = Graphics.FromIm age(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.FromIm age(bitmap);
.....
Bitmap bitmap = new Bitmap(pb.Size. Width,pb.Size.H eight );
pb.Image=bitmap ; or :
class MyPictureBox:Pi ctureBox
{
protected override void OnPaint(PaintEv entArgs e)
{
Graphics graphic = e.Graphics;
.....
}
}
Regards,
Krzemo.
Użytkownik "Jon Cosby" <jc****@nospam. net> napisał w wiadomości news:Zv******** *********@newsr ead1.news.pas.e arthlink.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.Cre ateGraphics();
............... ...
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.DrawLin e(selPen, coord1, coord2); graphic.DrawLin e(selPen, coord1, coord3); graphic.DrawLin e(selPen, coord2, coord4); graphic.DrawLin e(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 the level curve F(X, Y) = level.
Private Sub PlotLevelCurve(ByVal pic As System.Windows.Forms.PictureBox, _
ByVal level As Single, ByVal xmin As Single, ByVal xmax As Single, _
ByVal ymin As Single, ByVal ymax As Single, Optional ByRef step_size...
|
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 your help,
Here is the code.
|
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 Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Panel1.AutoScroll = True
Panel1.Width = 200
Panel1.Height = 200
|
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 actual drawing work.
But after displaying all the arrows in a flick, the arrows disappers.
I have debugged and came to know that the "Paint" event of the picturebox is refreshing the image, so the work done on the CreateGraphics created object is...
|
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 value of
PictureBox1.Image????
In the exapmle below control "D" shows only the picture(Black Image) without
the lines I added using the brush?
The Picturebox shows the lines nicely but the lines don't seem to be part of
the controls "Inage"...
| |
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 is that these lines are not recognized as the image of
the picturebox.
It shows picturebox.image = nothing.
How do we convert these lines drawn as the image of the picturebox so
that it can be saved.
|
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 disapears.
Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
x1 = e.Location.X
y1 = e.Location.Y
End Sub
Private Sub PictureBox1_MouseUp(ByVal sender As...
|
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, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
eGraphics = e.Graphics
TryToCreateRec(eGraphics)
PictureBox1.Refresh()
End Sub
Public Sub TryToCreateRec(ByVal eGraphics As Graphics)
Dim blackPen As New Pen(Color.White,...
|
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 now I am trying to create an image
overlay.
I am assuming that the best way for me to do this is to create a second
PictureBox that lays over the streaming video. I would then need to draw
directly into the bitmap shown in the overlaying...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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: 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, and deploymentwithout 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: 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...
|
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: 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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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
| |