36 views
in GUI Development by

Hi,

I used Stroked path to draw a lot of patterns (about 6-700)on view.

below is my settings

my pattern is composed of 1 triangle and 1 line.

var int32 tmpNum = 720;

TargetIcon_base.SetMaxNoOfSubPaths( 20 );
TargetIcon_Normal.SetMaxNoOfSubPaths( tmpNum*2 );
TargetIcon_Danger.SetMaxNoOfSubPaths( tmpNum*2 );
TargetIcon_Search.SetMaxNoOfSubPaths( 1 );

TargetIcon_base.InitSubPath( 0, 3 );      //Triangle
TargetIcon_base.Begin  ( 0, -4.0, 4.0 );
TargetIcon_base.AddLine( 0, 0.0, -8.0 );
TargetIcon_base.AddLine( 0, 4.0, 4.0 );
TargetIcon_base.Close( 0 );    

TargetIcon_base.InitSubPath( 1, 2 );     //one line
TargetIcon_base.Begin  ( 1, 0, 0 );
TargetIcon_base.AddLine( 1, 0, -16 );
TargetIcon_base.Close( 1 );

and it's my draw function 

TargetIcon_Normal.PushMatrix();
TargetIcon_Normal.InitSubPath( 2*n, 3 );
TargetIcon_Normal.Translate(x,y);
TargetIcon_Normal.Rotate(angle1);
TargetIcon_Normal.AddCopy( 2*n, TargetIcon_base, 0, 0, 3 );
TargetIcon_Normal.Close(2*n);
TargetIcon_Normal.PopMatrix();

TargetIcon_Normal.PushMatrix();
TargetIcon_Normal.InitSubPath( 2*n+1, 1 );
TargetIcon_Normal.Translate(x,y);
TargetIcon_Normal.Rotate(angle2);
TargetIcon_Normal.AddCopy( 2*n+1, TargetIcon_base, 1, 0, 1 );
TargetIcon_Normal.Close(2*n+1);
TargetIcon_Normal.PopMatrix();

 

when I draw a lot of patterns on view, it will appear some weird horizontal line( in the red line )

     

is there any suggestions to fix it ?

Thanks!

 

Best Regards,

Andy

2 Answers

0 votes
by
 
Best answer

Hallo Andy,

I have just tried your code and I was not able to see the suspect lines. Using random data for x, y, angle1 and angle2, it look very well. 

If there are no error messages (see the answer from Manfred above):

- Do you observe this issue in the target system only or also in the Prototyping environment?

- Are you able to reproduce the effect? Or, better, can you provide us an example demonstrating the issue?

Best regards

Paul Banach

by

Hi Paul , Manfred

I used IMXRT1050 and my Embedded Version is 9.30

I didn't get the error messages.

because of my resolution, many of my patterns will have the same position, angle1 and angle2.

I have use the below settings to reproduce the effect.

var int32 tmpNum=80;
var int32 i = 0;  
//ResetPath();
for(i=0;i<tmpNum;i=i+1)
{
  var int32 tmpX = math_rand(129,131);
  var int32 tmpY = math_rand(119,121);
  var int32 a1 = math_rand(0,90);
  var int32 a2 = math_rand(0,10);
  DrawNormal(i,tmpX,tmpY,a1,a2);
  //DrawNormal(i,116,118,83,160);
}

DrawNormal is the above draw function.

when you use the above settings , sometimes it will appear the suspect horizontal lines.

if the tmpNum is more bigger, then it must appear the suspect lines.

Best Regards,

Andy

by
Hello Andy,

with your version of the random data calculation I'm able to see some suspect lines. I will need to analyze this issue more in detail.

Best regards

Paul Banach
by
Hello Andy,

I was able to find the cause of the suspect lines. The algorithm used to raster the vector graphic manages counters for each sub-pixel where intersecting edges are counted. Right turning edge intersecting a sub-pixel increments the corresponding counter while a left turning edge decrements it. Based on these counters the raster algorithm detects which row areas have to be filled. So far the theory.

For memory and performance optimization purpose our implementation of the algorithm uses 1 byte for such counters. The information stored there is interpreted as signed 8-bit integer. It can store values in range -128 .. +127. In other words, the counter will overflow if there are more than 127 edges intersecting the same pixel and turning in the same direction. If the raster operation is performed with anti-aliasing, the max value is even reduced to 31 edges. This is because with anti-aliasing the edge can intersect up to 4 times one and the same sub-pixel within the rasterized row. It can thus increment or decrement the counter up to four times.

In your application there are many small 'figures' which sometimes intersect the same sub-pixel for more than 31 times. This leads to the overflow. The algorithm assumes there is more content to raster. The suspect lines appear.

To solve this problem, we will modify the raster algorithm to use a 16-bit signed integer instead of 8-bit. This elevates the max. number of edges intersecting the same sub-pixel to 32767 or 8191 in case of active anti-aliasing. On the other hand this modification occupies more RAM for internal raster buffer and may be slightly slower, but this is the unique possible approach to provide you a solution for your application case.

Fortunately, we are actually working on an update for IMXRT1050 and plan to release it very soon. I would ask you to ignore the suspect lines for the moment and as soon as we updated the software use this new version. We will inform you when the new version is available. Is this ok?

Best regards

Paul Banach
by
Hi Paul,

It's ok to wait for the new version.

Also, I will inform my agent for this issue.

Thanks for your help!!

 

Best Regards,

Andy
by

Hello Andy,

my colleagues have finalised the update of software components for several NXP iMXRT targets in version 9.30. It includes the above explained modification to enhance the raster algorithm so that it allows more edges intersecting the same sub-pixel. To use this new version, please log-in on our download center and download the ZIP files found below the sections:

* Embedded Wizard Build Environment for IMXRT1050-EVK

* NXP iMX_RT Professional AddOn

Use the contents of the ZIP files to replace the corresponding preceding versions. I hope, this update eliminates the suspect lines. Concerning your actual implementation I also see an additional optimization:

Your actual code:

TargetIcon_Normal.PushMatrix();
TargetIcon_Normal.InitSubPath( 2*n, 3 );
TargetIcon_Normal.Translate(x,y);
TargetIcon_Normal.Rotate(angle1);
TargetIcon_Normal.AddCopy( 2*n, TargetIcon_base, 0, 0, 3 );
TargetIcon_Normal.Close(2*n);
TargetIcon_Normal.PopMatrix();

TargetIcon_Normal.PushMatrix();
TargetIcon_Normal.InitSubPath( 2*n+1, 1 );
TargetIcon_Normal.Translate(x,y);
TargetIcon_Normal.Rotate(angle2);
TargetIcon_Normal.AddCopy( 2*n+1, TargetIcon_base, 1, 0, 1 );
TargetIcon_Normal.Close(2*n+1);
TargetIcon_Normal.PopMatrix();

... could be replaced by following code (the matrix stack is not used anymore and Close() path is not necessary since the original path is already closed):

TargetIcon_Normal.InitMatrix();
TargetIcon_Normal.InitSubPath( 2*n, 3 );
TargetIcon_Normal.Translate(x,y);
TargetIcon_Normal.Rotate(angle1);
TargetIcon_Normal.AddCopy( 2*n, TargetIcon_base, 0, 0, 3 );

TargetIcon_Normal.InitMatrix();
TargetIcon_Normal.InitSubPath( 2*n+1, 1 );
TargetIcon_Normal.Translate(x,y);
TargetIcon_Normal.Rotate(angle2);
TargetIcon_Normal.AddCopy( 2*n+1, TargetIcon_base, 1, 0, 1 );

Please let me know, whether the new updates do improve the behavior.

Best regards

Paul Banach

by
Hi Paul,

The new version is worked.

It eliminates the suspect lines.

Thanks for your help.

Best Regards,

Andy
0 votes
by
Hello Andy,

please let me know the version of Embedded Wizard that you are using and the target that you are using.

I assume that you get an error message - have you connected a console window via serial connection in order to get messages from the system?

Let me know...

Best regards

Manfred.

Ask Embedded Wizard

Welcome to the question and answer site for Embedded Wizard users and UI developers.

Ask your question and receive answers from the Embedded Wizard support team or from other members of the community!

Embedded Wizard Website | Privacy Policy | Imprint

...