Added line drawing with clipping.
Same as _draw_line but with extra parameters for the clipping region. Tested and seems to work well. Will check further tomorrow when I convert geist to use this instead of doing it internally. Imlib_Updates imlib_image_draw_line_clipped(int x1, int y1, int x2, int y2, int clip_xmin, int clip_xmax, int clip_ymin, int clip_ymax, char make_updates); SVN revision: 3273
This commit is contained in:
parent
f16c92658f
commit
4f72d15e1e
|
@ -229,6 +229,9 @@ void imlib_apply_color_modifier(void);
|
||||||
void imlib_apply_color_modifier_to_rectangle(int x, int y, int width, int height);
|
void imlib_apply_color_modifier_to_rectangle(int x, int y, int width, int height);
|
||||||
|
|
||||||
Imlib_Updates imlib_image_draw_line(int x1, int y1, int x2, int y2, char make_updates);
|
Imlib_Updates imlib_image_draw_line(int x1, int y1, int x2, int y2, char make_updates);
|
||||||
|
/* draw line clipped into rectangle - results in no draw if line is not inside
|
||||||
|
* rectangle */
|
||||||
|
Imlib_Updates imlib_image_draw_line_clipped(int x1, int y1, int x2, int y2, int clip_xmin, int clip_xmax, int clip_ymin, int clip_ymax, char make_updates);
|
||||||
void imlib_image_draw_rectangle(int x, int y, int width, int height);
|
void imlib_image_draw_rectangle(int x, int y, int width, int height);
|
||||||
void imlib_image_fill_rectangle(int x, int y, int width, int height);
|
void imlib_image_fill_rectangle(int x, int y, int width, int height);
|
||||||
void imlib_image_copy_alpha_to_image(Imlib_Image image_source, int x, int y);
|
void imlib_image_copy_alpha_to_image(Imlib_Image image_source, int x, int y);
|
||||||
|
|
24
src/api.c
24
src/api.c
|
@ -2004,6 +2004,30 @@ imlib_image_draw_line(int x1, int y1, int x2, int y2, char make_updates)
|
||||||
(char)make_updates);
|
(char)make_updates);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Imlib_Updates
|
||||||
|
imlib_image_draw_line_clipped(int x1, int y1, int x2, int y2, int clip_xmin, int clip_xmax, int clip_ymin, int clip_ymax, char make_updates)
|
||||||
|
{
|
||||||
|
ImlibImage *im;
|
||||||
|
|
||||||
|
CHECK_PARAM_POINTER_RETURN("imlib_image_draw_line_clipped", "image", ctxt_image, NULL);
|
||||||
|
CAST_IMAGE(im, ctxt_image);
|
||||||
|
if ((!(im->data)) && (im->loader) && (im->loader->load))
|
||||||
|
im->loader->load(im, NULL, 0, 1);
|
||||||
|
if (!(im->data))
|
||||||
|
return NULL;
|
||||||
|
__imlib_DirtyImage(im);
|
||||||
|
__imlib_DirtyPixmapsForImage(im);
|
||||||
|
return (Imlib_Updates)__imlib_draw_line_clipped(im, x1, y1, x2, y2,
|
||||||
|
clip_xmin, clip_xmax, clip_ymin, clip_ymax,
|
||||||
|
(DATA8)ctxt_color.red,
|
||||||
|
(DATA8)ctxt_color.green,
|
||||||
|
(DATA8)ctxt_color.blue,
|
||||||
|
(DATA8)ctxt_color.alpha,
|
||||||
|
ctxt_operation,
|
||||||
|
(char)make_updates);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
imlib_image_draw_rectangle(int x, int y, int width, int height)
|
imlib_image_draw_rectangle(int x, int y, int width, int height)
|
||||||
{
|
{
|
||||||
|
|
|
@ -89,7 +89,7 @@ __imlib_FileIsFile(const char *s)
|
||||||
|
|
||||||
buf = malloc(strlen(s));
|
buf = malloc(strlen(s));
|
||||||
if (!buf) return 0;
|
if (!buf) return 0;
|
||||||
strcpy(buf, s);
|
strcpy(buf, s);
|
||||||
p = strrchr(buf, ':');
|
p = strrchr(buf, ':');
|
||||||
if (p) *p = 0;
|
if (p) *p = 0;
|
||||||
s = buf;
|
s = buf;
|
||||||
|
@ -100,10 +100,10 @@ __imlib_FileIsFile(const char *s)
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
if (S_ISREG(st.st_mode))
|
if (S_ISREG(st.st_mode))
|
||||||
{
|
{
|
||||||
if (buf) free(buf);
|
if (buf) free(buf);
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
if (buf) free(buf);
|
if (buf) free(buf);
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
2520
src/rgbadraw.c
2520
src/rgbadraw.c
File diff suppressed because it is too large
Load Diff
|
@ -1,6 +1,13 @@
|
||||||
#ifndef __RGBADRAW
|
#ifndef __RGBADRAW
|
||||||
#define __RGBADRAW 1
|
#define __RGBADRAW 1
|
||||||
|
|
||||||
|
|
||||||
|
typedef unsigned int ImlibOutCode;
|
||||||
|
enum
|
||||||
|
{ TOP = 0x1, BOTTOM = 0x2, RIGHT = 0x4, LEFT = 0x8 };
|
||||||
|
#define TRUE 1
|
||||||
|
#define FALSE 0
|
||||||
|
|
||||||
void __imlib_FlipImageHoriz(ImlibImage *im);
|
void __imlib_FlipImageHoriz(ImlibImage *im);
|
||||||
void __imlib_FlipImageVert(ImlibImage *im);
|
void __imlib_FlipImageVert(ImlibImage *im);
|
||||||
void __imlib_FlipImageBoth(ImlibImage *im);
|
void __imlib_FlipImageBoth(ImlibImage *im);
|
||||||
|
@ -15,4 +22,15 @@ void __imlib_draw_filled_box(ImlibImage *im, int x, int y, int w, int h, DATA8 r
|
||||||
void __imlib_draw_filled_box(ImlibImage *im, int x, int y, int w, int h, DATA8 r, DATA8 g, DATA8 b, DATA8 a, ImlibOp op);
|
void __imlib_draw_filled_box(ImlibImage *im, int x, int y, int w, int h, DATA8 r, DATA8 g, DATA8 b, DATA8 a, ImlibOp op);
|
||||||
void __imlib_copy_image_data(ImlibImage *im, int x, int y, int w, int h, int nx, int ny);
|
void __imlib_copy_image_data(ImlibImage *im, int x, int y, int w, int h, int nx, int ny);
|
||||||
void __imlib_copy_alpha_data(ImlibImage *src, ImlibImage *dst, int x, int y, int w, int h, int nx, int ny);
|
void __imlib_copy_alpha_data(ImlibImage *src, ImlibImage *dst, int x, int y, int w, int h, int nx, int ny);
|
||||||
|
ImlibOutCode __imlib_comp_outcode(double x, double y, double xmin, double xmax,
|
||||||
|
double ymin, double ymax);
|
||||||
|
int
|
||||||
|
__imlib_clip_line(int x0, int y0, int x1, int y1, int xmin, int xmax, int ymin,
|
||||||
|
int ymax, int *clip_x0, int *clip_y0, int *clip_x1,
|
||||||
|
int *clip_y1);
|
||||||
|
ImlibUpdate *
|
||||||
|
__imlib_draw_line_clipped(ImlibImage * im, int x1, int y1, int x2, int y2,
|
||||||
|
int clip_xmin, int clip_xmax, int clip_ymin,
|
||||||
|
int clip_ymax, DATA8 r, DATA8 g, DATA8 b, DATA8 a,
|
||||||
|
ImlibOp op, char make_updates);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -761,6 +761,8 @@ int main (int argc, char **argv)
|
||||||
imlib_context_set_color(255, 255, 255, 255);
|
imlib_context_set_color(255, 255, 255, 255);
|
||||||
uu = imlib_image_draw_line(200, 200, x, y, 1);
|
uu = imlib_image_draw_line(200, 200, x, y, 1);
|
||||||
up = imlib_updates_append_updates(up, uu);
|
up = imlib_updates_append_updates(up, uu);
|
||||||
|
uu = imlib_image_draw_line_clipped(200, 0, 0, 200, 50, 100, 0, 300, 1);
|
||||||
|
up = imlib_updates_append_updates(up, uu);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
static Imlib_Color_Range rg = NULL;
|
static Imlib_Color_Range rg = NULL;
|
||||||
|
|
Loading…
Reference in New Issue