Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2007-10-20 20:17:27 +0400
committerCampbell Barton <ideasman42@gmail.com>2007-10-20 20:17:27 +0400
commit46deddcc62784dab47b1f14dda0d802f5f341b18 (patch)
treee3542a1b2d10f1c77e4ac5f7078f485d5b4e1006 /source/blender/imbuf
parente5a9e0b12a6d6aa334561edaf8a839f3f1a8d7d4 (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')
-rw-r--r--source/blender/imbuf/IMB_imbuf.h4
-rw-r--r--source/blender/imbuf/intern/IMB_imginfo.h6
-rw-r--r--source/blender/imbuf/intern/imginfo.c49
-rw-r--r--source/blender/imbuf/intern/png.c1
-rw-r--r--source/blender/imbuf/intern/rectop.c53
-rw-r--r--source/blender/imbuf/intern/thumbs.c14
6 files changed, 120 insertions, 7 deletions
diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h
index 2ca21e548c4..4d91a82a58f 100644
--- a/source/blender/imbuf/IMB_imbuf.h
+++ b/source/blender/imbuf/IMB_imbuf.h
@@ -545,6 +545,10 @@ void IMB_freezbuffloatImBuf(struct ImBuf * ibuf);
* @attention Defined in rectop.c
*/
void IMB_rectfill(struct ImBuf *drect, float col[4]);
+void IMB_rectfill_area(struct ImBuf *ibuf, float *col, int x1, int y1, int x2, int y2);
+
+/* defined in imginfo.c */
+int IMB_imginfo_change_field(struct ImBuf *img, const char *key, const char *field);
/* exported for image tools in blender, to quickly allocate 32 bits rect */
short imb_addrectImBuf(struct ImBuf * ibuf);
diff --git a/source/blender/imbuf/intern/IMB_imginfo.h b/source/blender/imbuf/intern/IMB_imginfo.h
index c8e9005619c..e82cc5f32af 100644
--- a/source/blender/imbuf/intern/IMB_imginfo.h
+++ b/source/blender/imbuf/intern/IMB_imginfo.h
@@ -74,6 +74,12 @@ int IMB_imginfo_get_field(struct ImBuf* img, const char* key, char* value, int l
*/
int IMB_imginfo_add_field(struct ImBuf* img, const char* key, const char* field);
+/** delete the key/field par in the ImgInfo struct.
+ * @param img - the ImBuf that contains the image data
+ * @param key - the key of the field
+ * @return - 1 (true) if delete the key/field, 0 (false) otherwise
+ */
+int IMB_imginfo_del_field(struct ImBuf *img, const char *key);
#endif /* _IMB_IMGINFO_H */
diff --git a/source/blender/imbuf/intern/imginfo.c b/source/blender/imbuf/intern/imginfo.c
index 59fbd2f7200..37bde9e5ac3 100644
--- a/source/blender/imbuf/intern/imginfo.c
+++ b/source/blender/imbuf/intern/imginfo.c
@@ -107,3 +107,52 @@ int IMB_imginfo_add_field(struct ImBuf* img, const char* key, const char* field)
return 1;
}
+int IMB_imginfo_del_field(struct ImBuf *img, const char *key)
+{
+ ImgInfo *p, *p1;
+
+ if ((!img) || (!img->img_info))
+ return (0);
+
+ p = img->img_info;
+ p1 = NULL;
+ while (p) {
+ if (!strcmp (key, p->key)) {
+ if (p1)
+ p1->next = p->next;
+ else
+ img->img_info = p->next;
+
+ MEM_freeN(p->key);
+ MEM_freeN(p->value);
+ MEM_freeN(p);
+ return (1);
+ }
+ p1 = p;
+ p = p->next;
+ }
+ return (0);
+}
+
+int IMB_imginfo_change_field(struct ImBuf *img, const char *key, const char *field)
+{
+ ImgInfo *p;
+
+ if (!img)
+ return (0);
+
+ if (!img->img_info)
+ return (IMB_imginfo_add_field (img, key, field));
+
+ p = img->img_info;
+ while (p) {
+ if (!strcmp (key, p->key)) {
+ MEM_freeN (p->value);
+ p->value = BLI_strdup (field);
+ return (1);
+ }
+ p = p->next;
+ }
+
+ return (IMB_imginfo_add_field (img, key, field));
+}
diff --git a/source/blender/imbuf/intern/png.c b/source/blender/imbuf/intern/png.c
index bb48ff71bff..c77ff7ea56f 100644
--- a/source/blender/imbuf/intern/png.c
+++ b/source/blender/imbuf/intern/png.c
@@ -236,6 +236,7 @@ short imb_savepng(struct ImBuf *ibuf, char *name, int flags)
iptr = ibuf->img_info;
num_text = 0;
while (iptr) {
+
imginfo[num_text].compression = PNG_TEXT_COMPRESSION_NONE;
imginfo[num_text].key = iptr->key;
imginfo[num_text].text = iptr->value;
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];
+ }
+ }
+ }
+}
diff --git a/source/blender/imbuf/intern/thumbs.c b/source/blender/imbuf/intern/thumbs.c
index 493b0968f55..131d2ef38f7 100644
--- a/source/blender/imbuf/intern/thumbs.c
+++ b/source/blender/imbuf/intern/thumbs.c
@@ -281,7 +281,7 @@ ImBuf* IMB_thumb_create(const char* dir, const char* file, ThumbSize size, Thumb
if (THB_SOURCE_IMAGE == source) {
BLI_getwdN(wdir);
chdir(dir);
- img = IMB_loadiffname(file, IB_rect);
+ img = IMB_loadiffname(file, IB_rect | IB_imginfo);
if (img != NULL) {
stat(file, &info);
sprintf(mtime, "%ld", info.st_mtime);
@@ -324,13 +324,13 @@ ImBuf* IMB_thumb_create(const char* dir, const char* file, ThumbSize size, Thumb
IMB_scaleImBuf(img, ex, ey);
}
sprintf(desc, "Thumbnail for %s", uri);
- IMB_imginfo_add_field(img, "Description", desc);
- IMB_imginfo_add_field(img, "Software", "Blender");
- IMB_imginfo_add_field(img, "Thumb::URI", uri);
- IMB_imginfo_add_field(img, "Thumb::MTime", mtime);
+ IMB_imginfo_change_field(img, "Description", desc);
+ IMB_imginfo_change_field(img, "Software", "Blender");
+ IMB_imginfo_change_field(img, "Thumb::URI", uri);
+ IMB_imginfo_change_field(img, "Thumb::MTime", mtime);
if (THB_SOURCE_IMAGE == source) {
- IMB_imginfo_add_field(img, "Thumb::Image::Width", cwidth);
- IMB_imginfo_add_field(img, "Thumb::Image::Height", cheight);
+ IMB_imginfo_change_field(img, "Thumb::Image::Width", cwidth);
+ IMB_imginfo_change_field(img, "Thumb::Image::Height", cheight);
}
img->ftype = PNG;
img->depth = 32;