Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 82 - sub-pixel line width always results in 0 twip line width #22

Open
netsweng opened this issue Aug 18, 2013 · 2 comments
Open

Bug 82 - sub-pixel line width always results in 0 twip line width #22

netsweng opened this issue Aug 18, 2013 · 2 comments

Comments

@netsweng
Copy link
Member

Philip de Nier 2009-03-14 11:02:01 EDT

Created an attachment (id=19) [details]
fix truncation of sub-pixel line widths

The functions to set the line width (in pixel units) in ming.h uses the
"unsigned short" type. The value is then multiplied by Ming_scale internally.
This means that a line width of < 1 pixel is stored as as a line width of 0
twips and flash renders this as a line with the minimum width.

The ming.h API should be changed to accept pixel unit line widths as a float so
that a pixel unit line width < 1 results in a twip unit line width of >= 0 and
< Ming_scale and not 0.

The attached patch file has this change.

p.s. it is a pity that 1 pixel and sub-pixel line widths look the same unless
you zoom in enough. The sub-pixel line would appear lighter in other formats.

@netsweng
Copy link
Member Author

strk@keybit.net 2009-05-20 05:39:17 EDT

This is a known problem. Can't remember now if a new interface was added.
The aim is not breaking ABI nor API, so I'd rather add a new interface
for correct behaving one.

Klaus ?

@netsweng
Copy link
Member Author

Index: src/ming.h.in

RCS file: /cvsroot/ming/ming/src/ming.h.in,v
retrieving revision 1.104
diff -u -8 -p -r1.104 ming.h.in
--- src/ming.h.in 16 Feb 2009 18:04:34 -0000 1.104
+++ src/ming.h.in 14 Mar 2009 14:38:59 -0000
@@ -937,24 +937,24 @@ void SWFFill_move(SWFFill fill, float x,
void SWFFill_moveTo(SWFFill fill, float x, float y);

void SWFFill_setMatrix(SWFFill fill, float a, float b,
float c, float d, float x, float y);

/***** shape_util.h *****/

-void SWFShape_setLine(SWFShape shape, unsigned short width,
+void SWFShape_setLine(SWFShape shape, float width,
byte r, byte g, byte b, byte a);

-void SWFShape_setLine2Filled(SWFShape shape, unsigned short width,
+void SWFShape_setLine2Filled(SWFShape shape, float width,
SWFFillStyle fill,
int flags, float miterLimit);

-void SWFShape_setLine2(SWFShape shape, unsigned short width,
+void SWFShape_setLine2(SWFShape shape, float width,
byte r, byte g, byte b, byte a,
int flags, float miterLimit);

SWFFill SWFShape_addSolidFill(SWFShape shape, byte r, byte g, byte b, byte a);
SWFFill SWFShape_addGradientFill(SWFShape shape, SWFGradient gradient, byte flags);
SWFFill SWFShape_addBitmapFill(SWFShape shape, SWFBitmap bitmap, byte flags);

void SWFShape_setLeftFill(SWFShape shape, SWFFill fill);

Index: src/shape_util.c

RCS file: /cvsroot/ming/ming/src/shape_util.c,v
retrieving revision 1.26
diff -u -8 -p -r1.26 shape_util.c
--- src/shape_util.c 31 May 2008 14:26:09 -0000 1.26
+++ src/shape_util.c 14 Mar 2009 14:38:59 -0000
@@ -57,20 +57,20 @@ float SWFCharacter_getHeight(SWFCharacte

/*

  • set line width and line color
    *

  • set line width in px

  • set line color as {r, g, b, a}
    *
    */
    -void SWFShape_setLine(SWFShape shape, unsigned short width,
    +void SWFShape_setLine(SWFShape shape, float width,
    byte r, byte g, byte b, byte a)
    {

    • SWFShape_setLineStyle_internal(shape, width * Ming_scale, r, g, b, a);
    • SWFShape_setLineStyle_internal(shape, (unsigned short)(width * Ming_scale), r, g, b, a);
      }

    /*

  • set Linestyle2 introduce with SWF 8.
    *

  • set line width in pixel

  • set color {r, g, b, a}
    *
    @@ -103,21 +103,21 @@ void SWFShape_setLine(SWFShape shape, un

  • SWF_LINESTYLE_FLAG_ENDCAP_NONE

  • SWF_LINESTYLE_FLAG_ENDCAP_SQUARE
    *

  • If join style is SWF_LINESTYLE_JOIN_MITER a miter limit factor

  • must be set. Miter max length is then calculated as:

  • max miter len = miter limit * width.

  • If join style is not miter, this value will be ignored.
    */
    -void SWFShape_setLine2(SWFShape shape, unsigned short width,
    +void SWFShape_setLine2(SWFShape shape, float width,
    byte r, byte g, byte b, byte a,
    int flags, float miterLimit)
    {

    • SWFShape_setLineStyle2_internal(shape, width * Ming_scale,
    • SWFShape_setLineStyle2_internal(shape, (unsigned short)(width * Ming_scale),
      r, g, b, a, flags, miterLimit);
      }

    /*

  • set filled Linestyle2 introduce with SWF 8.

  • set line width in pixel
    *
    @@ -153,21 +153,21 @@ void SWFShape_setLine2(SWFShape shape, u

  • SWF_LINESTYLE_FLAG_ENDCAP_NONE

  • SWF_LINESTYLE_FLAG_ENDCAP_SQUARE
    *

  • If join style is SWF_LINESTYLE_JOIN_MITER a miter limit factor

  • must be set. Miter max length is then calculated as:

  • max miter len = miter limit * width.

  • If join style is not miter, this value will be ignored.
    */
    -void SWFShape_setLine2Filled(SWFShape shape, unsigned short width,
    +void SWFShape_setLine2Filled(SWFShape shape, float width,
    SWFFillStyle fill,
    int flags, float miterLimit)
    {

    • SWFShape_setLineStyle2filled_internal(shape, width * Ming_scale,
    • SWFShape_setLineStyle2filled_internal(shape, (unsigned short)(width * Ming_scale),
      fill, flags, miterLimit);
      }

    SWFFill SWFShape_addSolidFill(SWFShape shape, byte r, byte g, byte b, byte a)
    {
    return newSWFFill(SWFShape_addSolidFillStyle(shape, r, g, b, a));
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant