summaryrefslogtreecommitdiff
path: root/libnautilus-extensions
diff options
context:
space:
mode:
authorAndy Hertzfeld <andy@src.gnome.org>2000-05-19 01:35:56 +0000
committerAndy Hertzfeld <andy@src.gnome.org>2000-05-19 01:35:56 +0000
commit3b559d2729d4bf4a738ffbb6f058fb0dfdceb454 (patch)
tree2b77fbe040f27c26f5cb0a742f56e9a7faf4b05d /libnautilus-extensions
parentc49ece8a7cebff4ce4d22ff2c5ac29c6281126d2 (diff)
downloadnautilus-3b559d2729d4bf4a738ffbb6f058fb0dfdceb454.tar.gz
at Arlo's suggestion, added a drop shadow to image thumbnails. Also fixed
at Arlo's suggestion, added a drop shadow to image thumbnails. Also fixed embarrassing bug where non-png thumbnails were being stored in weird directories with the wrong extension.
Diffstat (limited to 'libnautilus-extensions')
-rw-r--r--libnautilus-extensions/nautilus-graphic-effects.c89
-rw-r--r--libnautilus-extensions/nautilus-graphic-effects.h3
-rw-r--r--libnautilus-extensions/nautilus-icon-factory.c66
3 files changed, 103 insertions, 55 deletions
diff --git a/libnautilus-extensions/nautilus-graphic-effects.c b/libnautilus-extensions/nautilus-graphic-effects.c
index 5f9f62f57..8ea37a7ce 100644
--- a/libnautilus-extensions/nautilus-graphic-effects.c
+++ b/libnautilus-extensions/nautilus-graphic-effects.c
@@ -221,6 +221,95 @@ nautilus_create_colorized_pixbuf (GdkPixbuf *src,
return dest;
}
+/* draw a frame with a drop shadow into the passed in pixbuf */
+
+void
+nautilus_draw_frame (GdkPixbuf *frame_pixbuf)
+{
+ int index, h_index, last_index, pin_width;
+ int width, height, depth, rowstride, fill_value;
+ guchar *pixels, *temp_pixels;
+
+ width = gdk_pixbuf_get_width (frame_pixbuf);
+ height = gdk_pixbuf_get_height (frame_pixbuf);
+ depth = gdk_pixbuf_get_bits_per_sample (frame_pixbuf);
+ pixels = gdk_pixbuf_get_pixels (frame_pixbuf);
+ rowstride = gdk_pixbuf_get_rowstride (frame_pixbuf);
+
+ /* loop through the pixbuf a scaleline at a time, drawing the frame */
+ for (index = 0; index < height; index++) {
+ /* special case the first and last few lines to make them dark */
+ fill_value = 239;
+ pin_width = width;
+ last_index = height - index;
+ if (index == 0)
+ fill_value = 0;
+ else if (index > (height - 6)) {
+ fill_value = (index - (height - 5)) * 50;
+ pin_width = width - (height - index);
+ }
+ /* memset(pixels, fill_value, rowstride); */
+ temp_pixels = pixels;
+ for (h_index = 0; h_index < pin_width; h_index++) {
+ *temp_pixels++ = fill_value;
+ *temp_pixels++ = fill_value;
+ *temp_pixels++ = fill_value;
+ *temp_pixels++ = ((last_index < 6) && ((4 - last_index) > h_index)) ? 0 : 255;
+ }
+
+ /* draw the frame at the edge for each scanline */
+ if (last_index > 5) {
+ temp_pixels = pixels;
+ *temp_pixels++ = 0;
+ *temp_pixels++ = 0;
+ *temp_pixels++ = 0;
+ *temp_pixels++ = 255;
+ }
+
+ pixels += rowstride;
+
+ /* handle the last 5 pixels specially for the drop shadow */
+
+ temp_pixels = pixels - 5*4;
+
+ if (last_index > 4) {
+ *temp_pixels++ = 0;
+ *temp_pixels++ = 0;
+ *temp_pixels++ = 0;
+ *temp_pixels++ = 255;
+ } else temp_pixels += 4;
+
+ if (last_index > 3) {
+ *temp_pixels++ = 50;
+ *temp_pixels++ = 50;
+ *temp_pixels++ = 50;
+ *temp_pixels++ = index < 1 ? 0 : 255;
+ } else temp_pixels += 4;
+
+ if (last_index > 2) {
+ *temp_pixels++ = 100;
+ *temp_pixels++ = 100;
+ *temp_pixels++ = 100;
+ *temp_pixels++ = index < 2 ? 0 : 255;
+ } else temp_pixels += 4;
+
+ if (last_index > 1) {
+ *temp_pixels++ = 150;
+ *temp_pixels++ = 150;
+ *temp_pixels++ = 150;
+ *temp_pixels++ = index < 3 ? 0 : 255;
+ } else temp_pixels += 4;
+
+ if (last_index > 0) {
+ *temp_pixels++ = 200;
+ *temp_pixels++ = 200;
+ *temp_pixels++ = 200;
+ *temp_pixels++ = index < 4 ? 0 : 255;
+ }
+ }
+}
+
+
/* this routine takes the source pixbuf and returns a new one that's semi-transparent, by
clearing every other pixel's alpha value in a checkerboard grip. We have to do the
checkerboard instead of reducing the alpha since it will be turned into an alpha-less
diff --git a/libnautilus-extensions/nautilus-graphic-effects.h b/libnautilus-extensions/nautilus-graphic-effects.h
index bae25a193..a2508b247 100644
--- a/libnautilus-extensions/nautilus-graphic-effects.h
+++ b/libnautilus-extensions/nautilus-graphic-effects.h
@@ -41,6 +41,9 @@ GdkPixbuf* nautilus_create_colorized_pixbuf (GdkPixbuf *source_pixbuf,
int green_value,
int blue_value);
+/* draw a frame with a drop shadow into the passed-in pixbuf */
+void nautilus_draw_frame (GdkPixbuf *frame_pixbuf);
+
/* return a semi-transparent pixbuf from the source pixbuf using a checkboard
stipple in the alpha channel (so it can be converted to an alpha-less pixmap) */
GdkPixbuf *nautilus_make_semi_transparent (GdkPixbuf *source_pixbuf);
diff --git a/libnautilus-extensions/nautilus-icon-factory.c b/libnautilus-extensions/nautilus-icon-factory.c
index 1ebc17fba..6cf3b6af5 100644
--- a/libnautilus-extensions/nautilus-icon-factory.c
+++ b/libnautilus-extensions/nautilus-icon-factory.c
@@ -47,8 +47,10 @@
#include "nautilus-default-file-icon.h"
#include "nautilus-file-utilities.h"
#include "nautilus-gdk-extensions.h"
+#include "nautilus-gdk-pixbuf-extensions.h"
#include "nautilus-glib-extensions.h"
#include "nautilus-global-preferences.h"
+#include "nautilus-graphic-effects.h"
#include "nautilus-gtk-macros.h"
#include "nautilus-lib-self-check-functions.h"
#include "nautilus-link.h"
@@ -975,7 +977,7 @@ make_thumbnail_path (const char *image_uri, gboolean directory_only, gboolean us
/* append an image suffix if the correct one isn't already present */
if (!nautilus_str_has_suffix (image_uri, ".png") && !nautilus_str_has_suffix (image_uri, ".PNG")) {
char* old_uri = thumbnail_uri;
- thumbnail_uri = g_strdup_printf("%s/%s", thumbnail_uri, last_slash + 1);
+ thumbnail_uri = g_strdup_printf("%s.png", thumbnail_uri);
g_free(old_uri);
}
@@ -2065,40 +2067,6 @@ check_for_thumbnails (NautilusIconFactory *factory)
return FALSE;
}
-/* utility to draw the thumbnail frame. The frame is rectangular, so it doesn't need an alpha channel */
-static void
-draw_thumbnail_frame (GdkPixbuf *frame_pixbuf)
-{
- int index, width, height, depth, rowstride, fill_value;
- guchar *pixels, *temp_pixels;
-
- width = gdk_pixbuf_get_width (frame_pixbuf);
- height = gdk_pixbuf_get_height (frame_pixbuf);
- depth = gdk_pixbuf_get_bits_per_sample (frame_pixbuf);
- pixels = gdk_pixbuf_get_pixels (frame_pixbuf);
- rowstride = gdk_pixbuf_get_rowstride (frame_pixbuf);
-
- /* loop through the pixbuf a scaleline at a time, drawing the frame */
- for (index = 0; index < height; index++) {
- /* special case the first and last line to make them dark */
- fill_value = (index == 0 || index == height - 1) ? 0 : 239;
- memset(pixels, fill_value, rowstride);
-
- /* draw the frame at the edge for each scanline */
- temp_pixels = pixels;
- *temp_pixels++ = 0;
- *temp_pixels++ = 0;
- *temp_pixels++ = 0;
-
- pixels += rowstride;
-
- temp_pixels = pixels - 3;
- *temp_pixels++ = 0;
- *temp_pixels++ = 0;
- *temp_pixels++ = 0;
- }
-}
-
/* make_thumbnails is invoked periodically as a timer task to launch a task to make thumbnails */
static int
@@ -2141,28 +2109,16 @@ nautilus_icon_factory_make_thumbnails (gpointer data)
if (full_size_image != NULL) {
GdkPixbuf *scaled_image, *framed_image;
int scaled_width, scaled_height;
- int full_width = gdk_pixbuf_get_width (full_size_image);
- int full_height = gdk_pixbuf_get_height (full_size_image);
-
- if (full_width > full_height) {
- scaled_width = 96;
- scaled_height = full_height * 96 / full_width;
- } else {
- scaled_height = 96;
- scaled_width = full_width * 96 / full_height;
- }
-
- /* scale the image, then release the large one */
- scaled_image = gdk_pixbuf_scale_simple (full_size_image,
- scaled_width, scaled_height,
- GDK_INTERP_BILINEAR);
- gdk_pixbuf_unref (full_size_image);
- /* make the frame to mount it in - don't use an alpha channel, since it's rectangular */
+ scaled_image = nautilus_gdk_pixbuf_scale_to_fit(full_size_image, 96, 96);
+ scaled_width = gdk_pixbuf_get_width (scaled_image);
+ scaled_height = gdk_pixbuf_get_height (scaled_image);
+
+ /* make the frame to mount it in - use an alpha channel, so part of the drop shadow can be transparent */
framed_image = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
- FALSE, 8,
- scaled_width + 12, scaled_height + 12);
- draw_thumbnail_frame(framed_image);
+ TRUE, 8,
+ scaled_width + 16, scaled_height + 16);
+ nautilus_draw_frame(framed_image);
/* copy the scaled image into it, then release it */
gdk_pixbuf_copy_area (scaled_image, 0, 0,