Results 1 to 4 of 4

Thread: A problem about the non-uniform scaling.

  1. #1
    Junior Member
    Join Date
    Mar 2009
    Posts
    8

    A problem about the non-uniform scaling.

    In the section 8.7.6 (OpenvG Specification 1.1) indicated that
    if the user-to-surface tansformation includes non-uniform scaling, the geometry to be stroked must be transformed into surface coordinates prior to stroking. The paint transformation must also be set to the concatenation of the paint-to-user and user-to-surface transformations in order to allow correct painting of the stroked geometry.
    According to the sample code, i wrote my code as below, but had no effect to the line width.Why?

    Code :
    VGPath path;
    VGubyte segments[] = {VG_MOVE_TO_ABS, VG_LINE_TO_ABS};
    VGfloat coords[] = {20.0f, 20.0f, 20.0f, 50.0f};
    path = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, 1.0, 0.0f, 0, 0, VG_PATH_CAPABILITY_ALL);
    vgAppendPathData(path, 2, segments, coods);
    vgSeti(VG_MATRIX_MODE, VG_MATRIX_STROKE_PAINT_TO_USER);
    vgScale(5.0f, 5.0f);
    vgDrawPath(path, VG_STROKE_PATH);

  2. #2
    Senior Member
    Join Date
    May 2006
    Posts
    353

    Re: A problem about the non-uniform scaling.

    Why do you expect an effect on stroke width when the spec says the transformation happens prior to stroking?
    Georg Kolling, Imagination Technologies
    Please ask questions specific to PowerVR hardware or SDKs on the PowerVR Insider Forum
    DevTech@imgtec.com | http://www.powervrinsider.com

  3. #3
    Junior Member
    Join Date
    Mar 2009
    Posts
    8

    Re: A problem about the non-uniform scaling.

    Quote Originally Posted by Xmas
    Why do you expect an effect on stroke width when the spec says the transformation happens prior to stroking?
    hey, xmas, let me put it another way.

    Previously, with GDI+ , when i am to stroke a path, i can simply scale the Pen to change only the line width of my stroked path
    without affecting its coordinates nor shape. It seems in GDI+ , the linewidth scaling for stroking is seperated from the coordinates
    scaling of path shaping.

    Here with OpenVG, is there any way by which i can achieve the same effect as the aforementioned case.
    I mean only scale the linewidth, keeping the shape and coordinates the same.

    thanks ~~

  4. #4
    Senior Member
    Join Date
    Feb 2006
    Posts
    115

    Re: A problem about the non-uniform scaling.

    Your code does not do any non-uniform scaling. It just draws a vertical line the normal way.

    The VG 1.1 spec offers 2 different approaches to solve this problem:
    1) If the desired transformations are uniform (i.e. the geometry stretches in all directions by the same amount), then simply figure out what the new line width should be (= linewidth / sqrt(absolute value of (sx*sy shx*shy))), and use that (vgSetf(VG_STROKE_LINE_WIDTH, modified_line_width)).
    or
    2) If there are non-uniform transformations (e.g. line width stretches by a factor of 5 but the line length only by a factor of 3), then use vgTransformPath() like in the example in section 8.7.6.

    In your case, it seems like the first approach should do the trick, and simply adding a
    vgSetf(VG_STROKE_LINE_WIDTH, 4.0f/5.0f);
    before your draw call ought to work (4.0f = line width, 5.0f = sqrt(|(sx*sy shx*shy)|) = sqrt(|5*5 - 0*0|) [where sx,sy,shx,shy can be retrieved with vgGetMatrix()])

Similar Threads

  1. Scaling Texture
    By Rainmaker0929 in forum OpenGL ES general technical discussions
    Replies: 0
    Last Post: 07-04-2011, 06:32 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •