Rotated copies of surface


    Jul 07 2014 | 6:05 pm
    Hi, i need to paint rotated copies of a given jsurface.
    I tried to do something like
    jgraphics_rotate(g, 0.2);
    jgraphics_image_surface_draw(g, my_surface, source_rect, dest_rect);
    but it doesn't work. This might make sense since apparently jgraphics_image_surface_draw does not support rotations.
    Any hint on how I might need to proceed?
    Thanks! Daniele

    • Jul 07 2014 | 7:04 pm
      u may try to use jgraphics_rotate before your jgraphics_image_surface_draw method .
    • Jul 07 2014 | 7:22 pm
      Hi Do...while, actually my example was wrongly extrapolated – sorry (I've fixed it). It was inside a for loop, so I'm 100% sure that the function are called in the proper order. However, no rotation appears, only a weird shear of the image.
    • Jul 07 2014 | 7:32 pm
      ok , thats weird . can u post how the output image looks like after all (these weird shears)?
    • Jul 07 2014 | 8:37 pm
      Well, actually that's no shear, just a non-uniform scaling. Here's what happens with these lines of code!
      Code ("temp" is the angle, lena is charged with the standard lena png image):
      t_jsurface *lena = jgraphics_image_surface_create_from_file(filename, path);
      double height = jgraphics_image_surface_get_height(lena);
      double width = jgraphics_image_surface_get_width(lena);
      jgraphics_rotate(g, x->temp);
      jgraphics_image_surface_draw(g, lena, build_rect(0, 0, width, height), build_rect(0, 0, rect.width, rect.height));
      Does anybody know which is the most efficient way to bypass this issue?
    • Jul 07 2014 | 8:59 pm
      ok . i cant prove it now but working directly on a image_surface will distort its source . you could use it as a pattern . i remember the same issue with JavaScript , where ive been in need to set source as a pattern first . Does SDK provide pattern setup ? . sorry i cant look into SDK right now
    • Jul 07 2014 | 10:24 pm
      Hi Do...while, actually using patterns has partially solved my issue. Now I'm able to rotate the image. However, I don't seem to be able to put in the same graphic context both the image (say, inside a portion of it), and its rotated copy (inside another portion of it). Apparently the rotation applies to all portions of the graphic context.
      Any idea of how I can fix this?
    • Jul 07 2014 | 10:50 pm
      Although I guess the only solution is to create a pattern for each portion (which unfortunately makes a lot of patterns, in my case...)
    • Jul 08 2014 | 9:01 am
      yes u need work with pattern instances separately :/ but its just a bit more of a code (yeah might become messy), i cant say that its much less efficient way even if it adds another layer to manage .