Permalink
Browse files

simple-border: fix border.

  • Loading branch information...
1 parent 2ca2f02 commit 6ac30bbc48dbb6ed81f639ce17b8267f43a51a2a @hejiann committed Aug 11, 2012
Showing with 26 additions and 11 deletions.
  1. +2 −0 .gitignore
  2. +4 −1 Makefile
  3. +0 −5 border-textures.list
  4. +5 −0 simple-border-textures.list
  5. +15 −5 simple-border.c
View
2 .gitignore
@@ -3,5 +3,7 @@
beautify-textures.h
# skin-whitening
skin-whitening-images.h
+# simple-border
+simple-border-textures.h
# border
border-textures.h
View
5 Makefile
@@ -97,9 +97,12 @@ skin-whitening-effect.o: skin-whitening-effect.c skin-whitening-effect.h
simple-border: simple-border.o
$(CC) -o $@ $^ $(LIBS)
-simple-border.o: simple-border.c border-textures.h
+simple-border.o: simple-border.c simple-border-textures.h
$(CC) $(CFLAGS) -c simple-border.c -o simple-border.o
+simple-border-textures.h: simple-border-textures.list
+ $(GDK_PIXBUF_CSOURCE) --raw --build-list `cat simple-border-textures.list` > $(@F)
+
border: border.o
$(CC) -o $@ $^ $(LIBS)
View
5 border-textures.list
@@ -1,8 +1,3 @@
-texture_15356
- ./textures/simple-border/15356.png
-texture_15327
- ./textures/simple-border/15327.png
-
texture_14911
./textures/rip-border/others/14911.jpg
texture_12847
View
5 simple-border-textures.list
@@ -0,0 +1,5 @@
+texture_15356
+ ./textures/simple-border/15356.png
+texture_15327
+ ./textures/simple-border/15327.png
+
View
20 simple-border.c
@@ -18,7 +18,7 @@
#include <libgimp/gimp.h>
#include <libgimp/gimpui.h>
-#include "border-textures.h"
+#include "simple-border-textures.h"
#define PLUG_IN_PROC "plug-in-simple-border"
#define PLUG_IN_BINARY "border"
@@ -212,13 +212,17 @@ static void
border (gint32 image_ID)
{
GdkPixbuf *pixbuf = NULL;
+ int texture_width;
+ int texture_height;
+ gdouble margin_x;
+ gdouble margin_y;
pixbuf = gdk_pixbuf_new_from_inline (-1, bvals.border->texture, FALSE, NULL);
if (pixbuf)
{
- gint texture_width = gdk_pixbuf_get_width (pixbuf);
- gint texture_height = gdk_pixbuf_get_height (pixbuf);
+ texture_width = gdk_pixbuf_get_width (pixbuf);
+ texture_height = gdk_pixbuf_get_height (pixbuf);
gint32 texture_image = gimp_image_new (texture_width, texture_height, GIMP_RGB);
gint32 texture_layer = gimp_layer_new_from_pixbuf (texture_image, "texture", pixbuf, 100, GIMP_NORMAL_MODE, 0, 0);
@@ -245,8 +249,14 @@ border (gint32 image_ID)
GIMP_NORMAL_MODE);
gimp_image_add_layer (image_ID, layer, -1);
- gint margin_x = (texture_width - bvals.border->length) / 2;
- gint margin_y = (texture_height - bvals.border->length) / 2;
+ if (width > texture_width - bvals.border->length)
+ margin_x = (texture_width - bvals.border->length) / 2;
+ else
+ margin_x = (gdouble) width / 2;
+ if (height > texture_height - bvals.border->length)
+ margin_y = (texture_height - bvals.border->length) / 2;
+ else
+ margin_y = (gdouble) height / 2;
gimp_context_set_pattern ("Clipboard");

0 comments on commit 6ac30bb

Please sign in to comment.