diff options
author | Campbell Barton <ideasman42@gmail.com> | 2007-10-20 20:17:27 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2007-10-20 20:17:27 +0400 |
commit | 46deddcc62784dab47b1f14dda0d802f5f341b18 (patch) | |
tree | e3542a1b2d10f1c77e4ac5f7078f485d5b4e1006 /source/blender/imbuf/intern/rectop.c | |
parent | e5a9e0b12a6d6aa334561edaf8a839f3f1a8d7d4 (diff) |
Image Stamping patch by Diego (and peach request)- stamps image info into metadata and optionally
draws into the
frame.
This patch includes some changes I made...
* use blenders bitmap fonts (rather then own fonts)
* select font size
* user interface layout changes
* Marker as another image stamp option
Also added some new API calls
BMF_GetFontHeight(font);
BMF_DrawStringBuf(...); - so we can draw text into an imbuf's image buffer.
get_frame_marker(frame) - get the last marker from the frame.
IMB_rectfill_area(...) - fill in an image buffer with a rectangle area of color.
TODO - draw stamp info in 3d view, at the moment it just displays in the animation.
Diffstat (limited to 'source/blender/imbuf/intern/rectop.c')
-rw-r--r-- | source/blender/imbuf/intern/rectop.c | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/source/blender/imbuf/intern/rectop.c b/source/blender/imbuf/intern/rectop.c index 85c5e07bb8e..55cd4b9b6a1 100644 --- a/source/blender/imbuf/intern/rectop.c +++ b/source/blender/imbuf/intern/rectop.c @@ -517,3 +517,56 @@ void IMB_rectfill(struct ImBuf *drect, float col[4]) } } +/* maybe we should use BKE_utildefines.h */ +#define FTOCHAR(val) (val<=0.0f ? 0: (val>=1.0f ? 255: (char)(255.99f*val))) +#define CLAMP(a, b, c) if((a)<(b)) (a)=(b); else if((a)>(c)) (a)=(c) +#define SWAP(type, a, b) { type sw_ap; sw_ap=(a); (a)=(b); (b)=sw_ap; } +void IMB_rectfill_area(struct ImBuf *ibuf, float *col, int x1, int y1, int x2, int y2) +{ + int i, j; + + if ((!ibuf) || (!col)) + return; + + /* sanity checks for coords */ + CLAMP(x1, 0, ibuf->x); + CLAMP(x2, 0, ibuf->x); + CLAMP(y1, 0, ibuf->y); + CLAMP(y2, 0, ibuf->y); + + if (x1>x2) SWAP(int,x1,x2); + if (y1>y2) SWAP(int,y1,y2); + if (x1==x2 || y1==y2) return; + + if (ibuf->rect) { + unsigned char *img, *pixel; + unsigned char chr, chg, chb; + + chr = FTOCHAR(col[0]); + chg = FTOCHAR(col[1]); + chb = FTOCHAR(col[2]); + + img = (unsigned char *) ibuf->rect; + for (j = 0; j < y2-y1; j++) { + for (i = 0; i < x2-x1; i++) { + pixel = img + 4 * (((y1 + j) * ibuf->x) + (x1 + i)); + pixel[0] = chr; + pixel[1] = chg; + pixel[2] = chb; + } + } + } + + if (ibuf->rect_float) { + float *img, *pixel; + img = ibuf->rect_float; + for (j = 0; j < y2-y1; j++) { + for (i = 0; i < x2-x1; i++) { + pixel = img + 4 * (((y1 + j) * ibuf->x) + (x1 + i)); + pixel[0] = col[0]; + pixel[1] = col[1]; + pixel[2] = col[2]; + } + } + } +} |