forked from old/legacy-imlib2
ok, just wrote this little function to do pixel drawing with blending.
In fact, I wrote it just for the Bezier drawing function, but I thought it could be useful in other cases too. Have fun, Lightman :) SVN revision: 5302
This commit is contained in:
parent
3210af70fb
commit
830b576dd1
|
@ -354,6 +354,7 @@ extern "C"
|
|||
int height);
|
||||
|
||||
/* drawing on images */
|
||||
Imlib_Updates imlib_image_draw_pixel(int x, int y, char make_updates);
|
||||
Imlib_Updates imlib_image_draw_line(int x1, int y1, int x2, int y2,
|
||||
char make_updates);
|
||||
int imlib_clip_line(int x0, int y0, int x1, int y1, int xmin, int xmax,
|
||||
|
|
24
src/api.c
24
src/api.c
|
@ -3221,6 +3221,30 @@ imlib_apply_color_modifier_to_rectangle(int x, int y, int width, int height)
|
|||
(ImlibColorModifier *) ctx->color_modifier);
|
||||
}
|
||||
|
||||
Imlib_Updates
|
||||
imlib_image_draw_pixel(int x, int y, char make_updates)
|
||||
{
|
||||
ImlibImage *im;
|
||||
|
||||
if (!ctx) ctx = imlib_context_new();
|
||||
CHECK_PARAM_POINTER_RETURN("imlib_image_draw_pixel", "image", ctx->image,
|
||||
NULL);
|
||||
CAST_IMAGE(im, ctx->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_pixel(im, x, y,
|
||||
(DATA8) ctx->color.red,
|
||||
(DATA8) ctx->color.green,
|
||||
(DATA8) ctx->color.blue,
|
||||
(DATA8) ctx->color.alpha,
|
||||
ctx->operation,
|
||||
(char) make_updates);
|
||||
}
|
||||
|
||||
Imlib_Updates
|
||||
imlib_image_draw_line(int x1, int y1, int x2, int y2, char make_updates)
|
||||
{
|
||||
|
|
|
@ -441,6 +441,54 @@ __imlib_TileImageVert(ImlibImage * im)
|
|||
im->data = data;
|
||||
}
|
||||
|
||||
ImlibUpdate *
|
||||
__imlib_draw_pixel(ImlibImage *im, int x, int y, DATA8 r, DATA8 g, DATA8 b,
|
||||
DATA8 a, ImlibOp op, char make_updates)
|
||||
{
|
||||
int tmp;
|
||||
DATA32 *p;
|
||||
|
||||
/*clip to edges */
|
||||
if ((x < 0) || (x >= im->w) || (y < 0) || (y >= im->h))
|
||||
return NULL;
|
||||
|
||||
switch(op)
|
||||
{
|
||||
case OP_COPY:
|
||||
p = &(im->data[im->w * y + x]);
|
||||
BLEND(r, g, b, a, p);
|
||||
if (!make_updates)
|
||||
return NULL;
|
||||
return __imlib_AddUpdate(NULL, x, y, 1, 1);
|
||||
break;
|
||||
case OP_ADD:
|
||||
p = &(im->data[im->w * y + x]);
|
||||
BLEND_ADD(r, g, b, a, p);
|
||||
if (!make_updates)
|
||||
return NULL;
|
||||
return __imlib_AddUpdate(NULL, x, y, 1, 1);
|
||||
break;
|
||||
case OP_SUBTRACT:
|
||||
p = &(im->data[im->w * y + x]);
|
||||
BLEND_SUB(r, g, b, a, p);
|
||||
if (!make_updates)
|
||||
return NULL;
|
||||
return __imlib_AddUpdate(NULL, x, y, 1, 1);
|
||||
break;
|
||||
case OP_RESHADE:
|
||||
p = &(im->data[im->w * y + x]);
|
||||
BLEND_RE(r, g, b, a, p);
|
||||
if (!make_updates)
|
||||
return NULL;
|
||||
return __imlib_AddUpdate(NULL, x, y, 1, 1);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
ImlibUpdate *
|
||||
__imlib_draw_line(ImlibImage * im, int x1, int y1, int x2, int y2, DATA8 r,
|
||||
DATA8 g, DATA8 b, DATA8 a, ImlibOp op, char make_updates)
|
||||
|
|
|
@ -136,6 +136,9 @@ void __imlib_BlurImage(ImlibImage * im, int rad);
|
|||
void __imlib_SharpenImage(ImlibImage * im, int rad);
|
||||
void __imlib_TileImageHoriz(ImlibImage * im);
|
||||
void __imlib_TileImageVert(ImlibImage * im);
|
||||
ImlibUpdate *__imlib_draw_pixel(ImlibImage *im, int x, int y, DATA8 r,
|
||||
DATA8 g, DATA8 b, DATA8 a, ImlibOp op,
|
||||
char make_updates);
|
||||
ImlibUpdate *__imlib_draw_line(ImlibImage * im, int x1, int y1, int x2,
|
||||
int y2, DATA8 r, DATA8 g, DATA8 b, DATA8 a,
|
||||
ImlibOp op, char make_updates);
|
||||
|
|
Loading…
Reference in New Issue