Welcome to LEAD Support Forum Login | Register | Faq  

    LEAD Support Forum
  Resource to find answers and post technical questions about LEAD products.
Search    
   

Re: how to display straight lines
Started by martin.pastor at 07-01-2009 8:11. Topic has 8 replies.

Print Search « Previous Thread Next Thread »
  07-01-2009, 8:11
martin.pastor is not online. Last active: 7/27/2009 1:28:55 PM martin.pastor

Top 100 Posts
Joined on 11-25-2008
Posts 29
how to display straight lines
Reply Quote
Dear Friends,

I am using Leadtools v16.0 and MS Visual Studio 2005 in order to load and display an image. When the image is displayed, I want to plot some straight lines on it. According to the examples, I am using
“ri = codecs.Load(path);
RasterImageViewer riv = new RasterImageViewer();
riv.Image = new RasterImage(ri);
using (RasterImageGdiPlusGraphicsContainer container = riv.Image.CreateGdiPlusGraphics())
{using (Pen pen = new Pen(Color.FromArgb(alpha, Color.Red), w))
{
Point p1 = new Point(x1, y1);
Point p2 = new Point(x2, y2);

container.Graphics.DrawLine(pen, pp1, pp2);
}
}”
The main problem occurs because of the displayed images are in 8-bits gray scale and are about 200 Mpx. When the images are turn into a GDI, it changes from 8-bits to 32-bits, I computer has enough memory.

My question is, is there another way to plot a line on image?

Thanks in advanced,

Martín

   Report 
  07-02-2009, 11:46
Maen Hasan is not online. Last active: 3/15/2010 4:38:38 PM Maen Hasan



Top 10 Posts
Joined on 08-05-2004
Posts 2,563
Re: how to display straight lines
Reply Quote
Martin,

1. Do you want to make the line part of the image's pixel data or do you want to draw it on the viewer control?
2. How long is the line? If it will only be on a small part of the image (not from one corner to opposite corner), it is better not to create a GDI container for the whole image. Instead, create a smaller image, draw the line on that image, then combine the 2 images.

Thanks,
Maen Badwan
LEADTOOLS Technical Support
   Report 
  07-03-2009, 9:13
martin.pastor is not online. Last active: 7/27/2009 1:28:55 PM martin.pastor

Top 100 Posts
Joined on 11-25-2008
Posts 29
Re: how to display straight lines
Reply Quote
Dear Maen,
I only want to draw it on the viewer control. This line is on an large part of the image, from one side to the opposite side. Is there another way that the GDI?
Thanks.
   Report 
  07-05-2009, 4:03
Maen Hasan is not online. Last active: 3/15/2010 4:38:38 PM Maen Hasan



Top 10 Posts
Joined on 08-05-2004
Posts 2,563
Re: how to display straight lines
Reply Quote
If you want to draw the line on the viewer (not directly on the image), you can use the following code:
+------+
Pen pen = new Pen(Color.FromArgb(alpha, Color.Red), w);
Point p1 = new Point(x1, y1);
Point p2 = new Point(x2, y2);
rasterImageViewer1.CreateGraphics().DrawLine(pen, pp1, pp2);
+------+

Thanks,
Maen Badwan
LEADTOOLS Technical Support
   Report 
  07-15-2009, 9:39
martin.pastor is not online. Last active: 7/27/2009 1:28:55 PM martin.pastor

Top 100 Posts
Joined on 11-25-2008
Posts 29
Re: how to display straight lines
Reply Quote
Dear Maen,

The first of all, I am out of the office for 10 days. So, sorry for my late. I have try, but the line is drawn for a very short time and then it disappears. How can I maintain the line? Anyway, maybe I could draw the line in ther rasterImage modiffing it, showing it. How can I do?

Thanks in advanced.

Martin
   Report 
  07-15-2009, 10:07
Maen Hasan is not online. Last active: 3/15/2010 4:38:38 PM Maen Hasan



Top 10 Posts
Joined on 08-05-2004
Posts 2,563
Re: how to display straight lines
Reply Quote
To keep the line after drawing it, you need to draw it directly on the image.
After drawing the line, you can convert the image to 8-bit by using the ColorResolutionCommand Class.

Thanks,
Maen Badwan
LEADTOOLS Technical Support
   Report 
  07-16-2009, 7:32
martin.pastor is not online. Last active: 7/27/2009 1:28:55 PM martin.pastor

Top 100 Posts
Joined on 11-25-2008
Posts 29
Re: how to display straight lines
Reply Quote
Dear Maen,

Thank you for your advices. I don't know how to paint a line with Leadtools. Is there some method or I must paint pixels by pixel?

Thanks in advanced.

Martin
   Report 
  07-16-2009, 9:23
Maen Hasan is not online. Last active: 3/15/2010 4:38:38 PM Maen Hasan



Top 10 Posts
Joined on 08-05-2004
Posts 2,563
Re: how to display straight lines
Reply Quote
You can use RasterImage.CreateGdiPlusGraphics().Graphics.DrawLine method. In this case, if the image is changed to 24-bit or 32-bit, you can convert it to 8-bit by using the ColorResolutionCommand class or GrayscaleCommand Class.

Thanks,
Maen Badwan
LEADTOOLS Technical Support
   Report 
  07-17-2009, 8:22
martin.pastor is not online. Last active: 7/27/2009 1:28:55 PM martin.pastor

Top 100 Posts
Joined on 11-25-2008
Posts 29
Re: how to display straight lines
Reply Quote
Ok,

Thank you very much
   Report 
Post
LEAD Support Fo... » Developer » Image Display » Re: how to display straight lines

Powered by Community Server, by Telligent Systems