Rotated copies of surface
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
u may try to use jgraphics_rotate before your jgraphics_image_surface_draw method .
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.
ok , thats weird . can u post how the output image looks like after all (these weird shears)?
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?
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
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?
Although I guess the only solution is to create a pattern for each portion (which unfortunately makes a lot of patterns, in my case...)
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 .