Welcome to LEAD Support Forum Login | Register | Faq  

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

VECTOR_ANTIALIASING with L_VecPaintDC ?
Started by sigma7rd at 03-12-2008 9:23. Topic has 14 replies.

Print Search « Previous Thread Next Thread »
  03-12-2008, 9:23
sigma7rd is not online. Last active: 3/21/2008 4:31:19 PM sigma7rd

Not Ranked
Joined on 03-12-2008
Posts 6
VECTOR_ANTIALIASING with L_VecPaintDC ?
Reply Quote
Hi,

We're evaluating LEAD Tools Vector Pro for its DXF rendering capabilities. I’m using a simple combination of L_VecLoadFile and L_VecPaintDC to load and paint DXF files directly to a C# .NET Graphics surface. This seems the most straightfoward way to interface from C#.

I'm trying to enable anti-aliasing, for consistency with other vector produced by our product.

I’ve experimented with the L_VecSetDisplayOptions method, using various settings, but I am unable to get anti-aliased output.

I don’t really know what the numbers mean, but I’ve tried the following (for VECTOR_ANTIALIASING) :

Threshold Dim Filter
0 3 ANTIALIAS_1
1000 3 ANTIALIAS_1
10000 3 ANTIALIAS_1


It may be my structures that are wrong (I’ve hand-built them in C# for direct use with the DLL imports). However, I do not get any error code from the L_VecSetDisplayOptions function, and everything else appears to be working properly.


Is VECTOR_ANTIALIASING unsupported in this context, or am I just doing something wrong?

Thanks in advance,
Ross.

   Report 
  03-12-2008, 14:51
GregR is not online. Last active: 1/2/2009 9:03:27 AM GregR



Top 10 Posts
Joined on 05-31-2006
In House
Posts 1,811
Re: VECTOR_ANTIALIASING with L_VecPaintDC ?
Reply Quote

As far as i know, L_VecPaintDC should work just the same in .NET as it does in  C++.  I've not personally checked the anti-aliasing before though.

Please send a small sample project (NOT your entire application) that isolates this problem so I can try to reproduce it here.

NOTE: If you are attaching a project or file to the forums...
1.) Zip the file(s) up.
2.) Make sure it is less than 5 MB.  If it is larger, please send an email to support@leadtools.com and we'll send you FTP instructions.
3.) Remove ANY AND ALL unlock codes and LEADTOOLS DLLs.
4.) Do not click the preview button, the attachment will not show up when you post it.
 
If you do not wish to post your file(s) on the forum since they are publically viewable, please send an email to support@leadtools.com and make sure that you include a link to this forum post.


Greg Ross
LEADTOOLS Technical Support
   Report 
  03-13-2008, 11:29
sigma7rd is not online. Last active: 3/21/2008 4:31:19 PM sigma7rd

Not Ranked
Joined on 03-12-2008
Posts 6
Re: VECTOR_ANTIALIASING with L_VecPaintDC ?

Attachment: LEAD_DXF_Test.zip
Reply Quote
Hi Greg,

Thanks for the response. I'm actually trying to solve a more show-stopping problem now. Before I get to that though ...

I've attached a sample project. There's a PNG file in the ZIP that illustrates the lack of anti-aliasing, and you can see from my sample project how I'm trying to initialise it.

The second problem is also shown in the sample project. To summarise... I have a set of DXF files which actually tile together. Each DXF file has a "virtual" size of 2400x1800, although most tiles do not fill that area completely.

When I try to paint these "partial" tiles with L_VecPaintDC, they get scaled-up to fit the area I'm painting into. This is no good in my case: I need the original layout of the DXF to be preserved so that the edges line up with the tile next-door.

I could potentially calculate a "fixed" destination rectangle myself, but I need information about the extent of the actual content. I tried using L_VecGetObjectRect with a null object pointer to obtain this, but it just returns a recangle with the dimensions 0,0,0,0.


I'm not sure why this would be happening?

Thanks,
Ross.
   Report 
  03-18-2008, 7:46
GregR is not online. Last active: 1/2/2009 9:03:27 AM GregR



Top 10 Posts
Joined on 05-31-2006
In House
Posts 1,811
Re: VECTOR_ANTIALIASING with L_VecPaintDC ?
Reply Quote
In regards to the anti-aliasing, I have reproduced this problem and have reported it with the incident number 6790IDT.  This incident will be reviewed and prioritized by our engineering department.  I will contact you when I get more information from our developers.
 
As for the bounding rectangle problem, what flags are you passing?  Does this happen for all images or only some?  Could you post some images that you are trying to tile together?

Greg Ross
LEADTOOLS Technical Support
   Report 
  03-21-2008, 11:35
sigma7rd is not online. Last active: 3/21/2008 4:31:19 PM sigma7rd

Not Ranked
Joined on 03-12-2008
Posts 6
Re: VECTOR_ANTIALIASING with L_VecPaintDC ?
Reply Quote
Hi Greg,

I'm not sure what flags you are talking about. The sample code I gave you illustrates the problem, so hopefully you can find what you're needing in there.

At the moment you'll notice that the DXF file paints into the full window... but I'm only expecting it to paint into the lower-right quarter.

I've asked it to paint the piece of DXF represented by the coordinates (0,0)->(2400,1800) into the client area of the window (whatever size that may be). I happen to know that the supplied DXF only contains features in the range (1200,900)->(2400,1800) so I should expect to only see features in the lower-right quarter of the window. However, it seems to ignore my source rectangle parameter, instead stretching the content to fit the whole window.

For obvious reasons, this is no good if I try to tile it next to another DXF which will not be stretched (perhaps because it contains features in the full coordinate range).

   Report 
  03-24-2008, 15:04
GregR is not online. Last active: 1/2/2009 9:03:27 AM GregR



Top 10 Posts
Joined on 05-31-2006
In House
Posts 1,811
Re: VECTOR_ANTIALIASING with L_VecPaintDC ?
Reply Quote
The flags I was asking about are for the L_VecGetObjectRect, sorry for not being more specific.

The reason the file is getting "stretched" is because you destination rectangle is the entire client area.  If you only want to paint into a particular quadrant of the client area, then the coordinates of that quadrant need to be your destination rectangle.  This destination rectangle did the trick for me:


Rectangle lcDestination = new Rectangle(
    ClientRectangle.Left + ClientRectangle.Width / 2,
    ClientRectangle.Top + ClientRectangle.Height / 2,
    ClientRectangle.Width / 2,
    ClientRectangle.Height / 2);


The Raster API help file's documentation on L_PaintDC has some helpful diagrams in explaining how the coordinates in the painting functions work together.  Even though it's for Raster, the concept of source and destination and clipping rectangles are all the same in L_VecPaintDC.

I was hoping for code where you were trying to tile the images together and I thought your code was only for the antialiasing problem.  Anyways, it looks like this confusion for the Destination rectangle is all that's keeping you from getting it to work right.  If you continue to have problems, please send a small sample project that isolates the tiling problem more specifically.

Greg Ross
LEADTOOLS Technical Support
   Report 
  03-25-2008, 6:55
sigma7rd is not online. Last active: 3/21/2008 4:31:19 PM sigma7rd

Not Ranked
Joined on 03-12-2008
Posts 6
Re: VECTOR_ANTIALIASING with L_VecPaintDC ?

Attachment: dxfexample.png
Reply Quote
Hi Greg,

Thanks for the suggestion, but unfortunately it's not enough to solve my problem.

In fact, the example I gave you should not fit exactly into that quadrant... I rounded-off the numbers to make the illustration easier. Also, I have many different DXF files, and each should draw a different subset of that client area (actually, most of them cover the full area - I have a set of tiles which fit into a grid, and it's only the tiles towards the edge of the grid which are partially populated, obviously because that's where the data ends).

Anyway, I wonder if all my talk of tiles is confusing the matter. If we forget the tiles for a moment, the underlying problem is that L_VecPaintDC is not honouring my pSrc, uWidth and uHeight parameters.

I have supplied my own pSrc, uWidth and uHeight, representing a source rectangle of (0,0)-(2400,1200) and I would expect exactly this region to be drawn to my destination rectangle.

However, it appears to be using a source rectangle of approximately (1200,0)-(2400,900), completely ignoring my request.

Initially, I wasn't sure if I was using the function correctly, however your recommendation to read the help for L_PaintDC has reassured me. It states that "You can specify the various rectangles in any way that meets your needs. Coordinates can have negative values and they can extend beyond the bounds of the bitmap or the device context."

I have attached a diagram, which I hope will help.


Re: The Flags... My attempted use of L_VecGetObjectRect was to work-around the above problem. However, since that's not working either, I'd prefer to get L_VecPaintDC fixed?

For interest, I was using the method as follows:
L_VecGetObjectRect(pHandle, null, pRect, 0)

It always fills my rect with the coordinates (0,0)-(0,0). I also tried prepopulating the rect with some random data, and the function does indeed overwrite it with all-zeroes.

Re: the Project... It would take me a considerable time to put together an isolated sample that uses tiling. I am hoping that the supplied image will be useful instead.

   Report 
  03-25-2008, 9:53
GregR is not online. Last active: 1/2/2009 9:03:27 AM GregR



Top 10 Posts
Joined on 05-31-2006
In House
Posts 1,811
Re: VECTOR_ANTIALIASING with L_VecPaintDC ?
Reply Quote
Thanks for the diagram, that was helpful.
 
According to the documentation of the L_VecPaintDC function, the uWidth and uHeight are what would "flatten" out the vector space and make it a bitmap.  Therefore, your source rectangles will be based on the values you pass to those parameters.  
 
In your example, you are using the same values for this, which means your source rectangle is always the entire vector.  To do what you're trying to accomplish, you would need to make the width and height the tile size, and then the source rectangle the entire vector space you're trying to do.  In theory, these are the values you should use if I'm understanding your goal correctly:
 

DxfAPI.WinRect lcSource = (DxfAPI.WinRect)new Rectangle(-1200, -900, 2400, 1800);
DxfAPI.WinRect lcDestination = (DxfAPI.WinRect)inDestination; // = ClientRectangle
DxfAPI.WinRect lcDestinationClip = (DxfAPI.WinRect)inDestinationClip; // = e.ClipRectangle from the OnPaint event

// paint to the DC ...
ThrowOnError(
    DxfAPI.L_VecPaintDC(
        lcHDC,
        ref m_Handle,
        1200,
        900,
        ref lcSource,
        IntPtr.Zero,
        ref lcDestination,
        ref lcDestinationClip,
        0
    )
);


 
Unfortunately, it appears there's a problem with the L_VecPaintDC or the documentation becuase it doesn't look like the source rectangles work unless they are completely within the bounds of the virtual width and height (uWidth, uHeight).  When I used a source rectangle that was smaller than the virtual size it worked as expected and only the portion I selected was painted to the entire destination rectangle.
 
I have reproduced this problem and have reported it with the incident number 6810IDT.  This incident will be reviewed and prioritized by our engineering department.  I will contact you when I get more information from our developers.
 
The only way you will be able to work around this is to do the logic backwards, and apply the necessary math to alter the detination rectangle rather than the source rectangle.
 
If you have any more questions, please let me know.

Greg Ross
LEADTOOLS Technical Support
   Report 
  03-25-2008, 12:22
sigma7rd is not online. Last active: 3/21/2008 4:31:19 PM sigma7rd

Not Ranked
Joined on 03-12-2008
Posts 6
Re: VECTOR_ANTIALIASING with L_VecPaintDC ?
Reply Quote
Hi Greg,

Thanks again for your quick response.

I'm more than happy to use math on the destination rectangle as a work-around. In fact, if the uWidth and uHeight work in the way you suggest, I would need to do this an all cases. However, the only way to calculate that is to know the real extent of the source features.

In your example, you've simply assumed my numbers of (1200,0)-(2400,900), which are actually rounded off. I've no idea what the exact coordinate space of that tile is.

I've tried to use L_VecGetObjectRect to query this information, but it just gives me a bunch of zeroes.

If you'd like to reproduce this, you can uncomment my code in DxfFile's constructor and inspect the value it returns with the debugger.

For me, this is more of a priority than fixing L_VecPaintDC... I can work-around the L_VecPaintDC behaviour with a working L_VecGetObjectRect, but I need the L_VecGetObjectRect in either case.

Thanks again,
Ross.
   Report 
  03-25-2008, 16:10
GregR is not online. Last active: 1/2/2009 9:03:27 AM GregR



Top 10 Posts
Joined on 05-31-2006
In House
Posts 1,811
Re: VECTOR_ANTIALIASING with L_VecPaintDC ?
Reply Quote
I played around with L_VecGetObjectRect in the main vector demo that ships with the toolkit, and it also returns a zeroed out rectangle if you call it right after loading.  However if I add a new menu item and call it after the file's been loaded and painted and everything, it will return values in the rectangle.  I also discovered that the rectangle is in client coordinates, because the values of the rectangle changed whenever I changed the size of the window.  Therefore, it appears that L_VecGetObjectRect depends on all of the other painting properties such as the camera, parallelogram, pan values, etc and that this function isn't going to accomplish what you're trying to do.

You will want to use L_VecGetObjectParallelogram because this returns the data in vector coordinates.  I tested this in the main API demo just after the call to L_VecLoadFile and it returned these values which appear to be right on:

L_VecGetObjectParallelogram(pCreateData->pVector, NULL, &ptMin, &ptMax, NULL);
ptMin    {x=1277.1199999999999 y=0.00000000000000000 z=0.00000000000000000}   
ptMax    {x=2399.0000000000000 y=891.36000000000001 z=3.0000000000000000}   

Sorry it took so long to get to this point, I don't get into the vector toolkit as much =).



Greg Ross
LEADTOOLS Technical Support
   Report 
  03-26-2008, 12:10
sigma7rd is not online. Last active: 3/21/2008 4:31:19 PM sigma7rd

Not Ranked
Joined on 03-12-2008
Posts 6
Re: VECTOR_ANTIALIASING with L_VecPaintDC ?

Attachment: success.png
Reply Quote
Hi Greg,

That last one's done it! The math was a bit of a headache but I've managed to get it working using L_VecGetObjectParallelogram() and a manually calculated destination rectangle.

For reference, the DXF's Y axis goes in the opposite direction from that of L_VecPaintDC (as you would expect if it mirrors L_PaintDC). This needs to be accounted for in the math.

I've attached a screenshot from our software... there's 7 separate DXF files shown in the viewport, and they all tile together seemlessly!

Thanks for all your help, very much appreciated.

   Report 
  03-26-2008, 13:30
GregR is not online. Last active: 1/2/2009 9:03:27 AM GregR



Top 10 Posts
Joined on 05-31-2006
In House
Posts 1,811
Re: VECTOR_ANTIALIASING with L_VecPaintDC ?
Reply Quote
Very cool.  I'll still update you whenever I get more information for the incident for L_VecPaintDC.  Glad we were able to find a suitable workaround.

Greg Ross
LEADTOOLS Technical Support
   Report 
  09-08-2008, 16:25
GregR is not online. Last active: 1/2/2009 9:03:27 AM GregR



Top 10 Posts
Joined on 05-31-2006
In House
Posts 1,811
Re: VECTOR_ANTIALIASING with L_VecPaintDC ?
Reply Quote
The developers working on your incident, 6810IDT, have let me know that this is not a bug with L_VecPaintDC, just a documentation error.  L_VecPaintDC doesn't work exactly like L_PaintDC in the fact that it does not allow negative values.  This has been assigned to our documentation team to clarify.

Greg Ross
LEADTOOLS Technical Support
   Report 
  09-16-2008, 12:47
GregR is not online. Last active: 1/2/2009 9:03:27 AM GregR



Top 10 Posts
Joined on 05-31-2006
In House
Posts 1,811
Re: VECTOR_ANTIALIASING with L_VecPaintDC ?

Attachment: LEAD_DXF_Test_VecPaint_antialiasing.zip
Reply Quote
The developers working on your incident 6790IDT, have let me know that they've fixed the problem with anti aliasing for L_VecPaint but not for L_VecPaintDC.  For tracking purposes, we added a new incident for the anti aliasing problem for L_VecPaintDC and that number is 7298IDT.

I've modified your original sample to use L_VecPaint rather than L_VecPaintDC.  Since L_VecPaint doesn't have the same control over source and destination rectangles, you would need to change the viewport and camera in order to set up where individual images are getting painted to.  That logic may end up being more complicated than what you already did for L_VecPaintDC, so unless anti aliasing is really important to your application, you might not want to reinvent the wheel for now.

Greg Ross
LEADTOOLS Technical Support
   Report 
  11-18-2008, 11:40
GregR is not online. Last active: 1/2/2009 9:03:27 AM GregR



Top 10 Posts
Joined on 05-31-2006
In House
Posts 1,811
Re: VECTOR_ANTIALIASING with L_VecPaintDC ?
Reply Quote
Your incident, 7298IDT, has been fixed in the latest build of v15.  Similarly to using L_VecPaint, you will also need to call L_VecAttachToWindow and L_VecSetViewport.

Please send an email to support@leadtools.com in order to get the download instructions for the latest patch.  For verification purposes, I need you to include the following information:

1. The company you work for
2. The LEADTOOLS serial number(s) you own (if you are evaluating, just say so)
3. The name(s) of the developer(s) using the serial number
4. A link to this forum post

Greg Ross
LEADTOOLS Technical Support
   Report 
Post
LEAD Support Fo... » Developer » Vector » VECTOR_ANTIALIASING with L_VecPaintDC ?

Powered by Community Server, by Telligent Systems