Willem's rotation patch.

SVN revision: 2889
This commit is contained in:
Tom Gilbert 2000-06-25 18:13:36 +00:00
parent 00dcd44c89
commit ce84557641
5 changed files with 139 additions and 0 deletions

View File

@ -0,0 +1 @@
timestamp

View File

@ -257,6 +257,17 @@ Imlib_Image imlib_create_rotated_image(double angle);
void imlib_blend_image_onto_image_at_angle(Imlib_Image source_image, char merge_alpha, int source_x, int source_y, int source_width, int source_height, int destination_x, int destination_y, int angle_x, int angle_y);
void imlib_blend_image_onto_image_skewed(Imlib_Image source_image, char merge_alpha, int source_x, int source_y, int source_width, int source_height, int destination_x, int destination_y, int h_angle_x, int h_angle_y, int v_angle_x, int v_angle_y);
void imlib_render_image_on_drawable_skewed(int source_x, int source_y,
int source_width, int source_height,
int destination_x, int destination_y,
int h_angle_x, int h_angle_y,
int v_angle_x, int v_angle_y);
void imlib_render_image_on_drawable_at_angle(int source_x, int source_y,
int source_width, int source_height,
int destination_x, int destination_y,
int angle_x, int angle_y);
void imlib_image_filter(void);
Imlib_Filter imlib_create_filter(int initsize);
void imlib_context_set_filter(Imlib_Filter filter);

View File

@ -2347,6 +2347,57 @@ imlib_blend_image_onto_image_skewed(Imlib_Image source_image,
ctxt_color_modifier, ctxt_operation);
}
void
imlib_render_image_on_drawable_skewed(int source_x, int source_y,
int source_width, int source_height,
int destination_x, int destination_y,
int h_angle_x, int h_angle_y,
int v_angle_x, int v_angle_y)
{
ImlibImage *im;
CHECK_PARAM_POINTER("imlib_render_image_on_drawable_skewed", "image", ctxt_image);
CAST_IMAGE(im, ctxt_image);
if ((!(im->data)) && (im->loader) && (im->loader->load))
im->loader->load(im, NULL, 0, 1);
if (!(im->data))
return;
CAST_IMAGE(im, ctxt_image);
__imlib_RenderImageSkewed(ctxt_display, im, ctxt_drawable, ctxt_mask,
ctxt_visual, ctxt_colormap, ctxt_depth,
source_x, source_y, source_width, source_height,
destination_x, destination_y,
h_angle_x, h_angle_y, v_angle_x, v_angle_y,
ctxt_anti_alias, ctxt_dither, ctxt_blend,
ctxt_dither_mask, ctxt_color_modifier,
ctxt_operation);
}
void
imlib_render_image_on_drawable_at_angle(int source_x, int source_y,
int source_width, int source_height,
int destination_x, int destination_y,
int angle_x, int angle_y)
{
ImlibImage *im;
CHECK_PARAM_POINTER("imlib_render_image_on_drawable_at_angle", "image", ctxt_image);
CAST_IMAGE(im, ctxt_image);
if ((!(im->data)) && (im->loader) && (im->loader->load))
im->loader->load(im, NULL, 0, 1);
if (!(im->data))
return;
CAST_IMAGE(im, ctxt_image);
__imlib_RenderImageSkewed(ctxt_display, im, ctxt_drawable, ctxt_mask,
ctxt_visual, ctxt_colormap, ctxt_depth,
source_x, source_y, source_width, source_height,
destination_x, destination_y,
angle_x, angle_y, 0, 0,
ctxt_anti_alias, ctxt_dither, ctxt_blend,
ctxt_dither_mask, ctxt_color_modifier,
ctxt_operation);
}
void
imlib_image_filter(void)
{

View File

@ -275,3 +275,69 @@ __imlib_RenderImage(Display *d, ImlibImage *im,
__imlib_ConsumeXImage(d, mxim);
}
void
__imlib_RenderImageSkewed(Display *d, ImlibImage *im, Drawable w, Drawable m,
Visual *v, Colormap cm, int depth,
int sx, int sy, int sw, int sh, int dx, int dy,
int hsx, int hsy, int vsx, int vsy,
char antialias, char hiq, char blend,
char dither_mask, ImlibColorModifier *cmod,
ImlibOp op)
{
XImage *xim = NULL, *mxim = NULL;
Context *ct;
static GC gc = 0;
static GC gcm = 0;
XGCValues gcv;
int dx1, dy1, dx2, dy2, dw, dh, tsx, tsy;
ImlibImage *back;
dx1 = dx2 = dx;
dy1 = dy2 = dy;
if (hsx < 0) dx1 += hsx;
else dx2 += hsx;
if (hsy < 0) dy1 += hsy;
else dy2 += hsy;
tsx = vsx; tsy = vsy;
if (!tsx && !tsy) {
tsy = (hsx * im->h) / im->w;
tsx = -(hsy * im->h) / im->w;
}
if (tsx < 0) dx1 += tsx;
else dx2 += tsx;
if (tsy < 0) dy1 += tsy;
else dy2 += tsy;
if ((dx2 < 0) || (dy2 < 0)) return;
dw = dx2 - dx1;
dh = dy2 - dy1;
if ((dw <= 0) || (dh <= 0)) return;
if (dx1 < 0) {
dw += dx1;
dx1 = 0;
}
if (dy1 < 0) {
dh += dy1;
dy1 = 0;
}
ct = __imlib_GetContext(d, v, cm, depth);
back = __imlib_CreateImage(dw, dh, NULL);
back->data = malloc(dw * dh * sizeof(DATA32));
memset(back->data, 0, dw * dh * sizeof(DATA32));
__imlib_GrabDrawableToRGBA(back->data, 0, 0, dw, dh, d, w, 0, v, cm,
depth, dx1, dy1, dw, dh, 0, 1);
__imlib_BlendImageToImageSkewed(im, back, antialias, 1, 0, sx, sy, sw, sh,
dx - dx1, dy - dy1, hsx, hsy, vsx, vsy,
cmod, op);
__imlib_RenderImage(d, back, w, m, v, cm, depth, 0, 0, dw, dh,
dx1, dy1, dw, dh, 0, hiq, 0, dither_mask, 0, OP_COPY);
__imlib_FreeImage(back);
}

View File

@ -8,4 +8,14 @@ __imlib_RenderImage(Display *d, ImlibImage *im,
int dx, int dy, int dw, int dh,
char anitalias, char hiq, char blend, char dither_mask,
ImlibColorModifier *cmod, ImlibOp op);
void
__imlib_RenderImageSkewed(Display *d, ImlibImage *im, Drawable w,
Drawable m, Visual *v, Colormap cm, int depth,
int sx, int sy, int sw, int sh, int dx, int dy,
int hsx, int hsy, int vsx, int vsy,
char antialias, char hiq, char blend,
char dither_mask, ImlibColorModifier *cmod,
ImlibOp op);
#endif