mirror of
https://gitlab.gnome.org/GNOME/nautilus
synced 2024-11-05 16:04:31 +00:00
Add function to create a GdkPixbuf from a string. Also fixed a debuggin
* libnautilus-extensions/nautilus-scalable-font.h: * libnautilus-extensions/nautilus-scalable-font.c: (nautilus_scalable_font_draw_text), (nautilus_text_layout_paint), (nautilus_gdk_pixbuf_new_from_text): Add function to create a GdkPixbuf from a string. Also fixed a debuggin typo from before. * test/test-nautilus-font.c: (create_named_background), (rgba_run_alpha), (pixbuf_draw_rectangle), (pixbuf_draw_rectangle_around), (main): Add text to GdkPixbuf to GdkPixbuf compositing test. Also add a bunch of hacks to make the tests more useful.
This commit is contained in:
parent
0f1d07d9f9
commit
afc5e4d4e4
6 changed files with 369 additions and 82 deletions
15
ChangeLog
15
ChangeLog
|
@ -1,3 +1,18 @@
|
|||
2000-09-07 Ramiro Estrugo <ramiro@eazel.com>
|
||||
|
||||
* libnautilus-extensions/nautilus-scalable-font.h:
|
||||
* libnautilus-extensions/nautilus-scalable-font.c:
|
||||
(nautilus_scalable_font_draw_text), (nautilus_text_layout_paint),
|
||||
(nautilus_gdk_pixbuf_new_from_text):
|
||||
Add function to create a GdkPixbuf from a string. Also fixed a
|
||||
debuggin typo from before.
|
||||
|
||||
* test/test-nautilus-font.c: (create_named_background),
|
||||
(rgba_run_alpha), (pixbuf_draw_rectangle),
|
||||
(pixbuf_draw_rectangle_around), (main):
|
||||
Add text to GdkPixbuf to GdkPixbuf compositing test. Also add a
|
||||
bunch of hacks to make the tests more useful.
|
||||
|
||||
2000-09-07 Mathieu Lacage <mathieu@eazel.com>
|
||||
|
||||
First work toward bug 2353, fixes bug 2570, 1289
|
||||
|
|
|
@ -785,8 +785,7 @@ nautilus_scalable_font_draw_text (const NautilusScalableFont *font,
|
|||
invert_area = glyph_area;
|
||||
}
|
||||
|
||||
//if (!art_irect_empty (&invert_area)) {
|
||||
{
|
||||
if (!art_irect_empty (&invert_area)) {
|
||||
guchar *glyph_pixels;
|
||||
guint glyph_rowstride;
|
||||
|
||||
|
@ -1703,7 +1702,7 @@ nautilus_text_layout_paint (const NautilusTextLayout *text_layout,
|
|||
text_layout->font_size,
|
||||
row->text,
|
||||
row->text_length,
|
||||
color,
|
||||
NAUTILUS_RGBA_COLOR_PACK (255, 255, 255, 255),
|
||||
255,
|
||||
inverted);
|
||||
|
||||
|
@ -1731,6 +1730,60 @@ nautilus_text_layout_paint (const NautilusTextLayout *text_layout,
|
|||
}
|
||||
}
|
||||
|
||||
GdkPixbuf *
|
||||
nautilus_gdk_pixbuf_new_from_text (const NautilusScalableFont *font,
|
||||
guint font_width,
|
||||
guint font_height,
|
||||
const char *text,
|
||||
guint text_length,
|
||||
guint32 color,
|
||||
guchar overall_alpha,
|
||||
gboolean inverted)
|
||||
{
|
||||
GdkPixbuf *pixbuf;
|
||||
guint text_width;
|
||||
guint text_height;
|
||||
|
||||
g_return_val_if_fail (NAUTILUS_IS_SCALABLE_FONT (font), NULL);
|
||||
g_return_val_if_fail (font_width > 0, NULL);
|
||||
g_return_val_if_fail (font_height > 0, NULL);
|
||||
|
||||
if (text == NULL || text[0] == '\0' || text_length == 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
g_return_val_if_fail (text_length <= strlen (text), NULL);
|
||||
|
||||
nautilus_scalable_font_measure_text (font,
|
||||
font_width,
|
||||
font_height,
|
||||
text,
|
||||
strlen (text),
|
||||
&text_width,
|
||||
&text_height);
|
||||
g_assert (text_width > 0);
|
||||
g_assert (text_height > 0);
|
||||
|
||||
pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, text_width, text_height);
|
||||
|
||||
nautilus_gdk_pixbuf_fill_rectangle_with_color (pixbuf, NULL, NAUTILUS_RGBA_COLOR_PACK (0, 0, 0, 0));
|
||||
|
||||
nautilus_scalable_font_draw_text (font,
|
||||
pixbuf,
|
||||
0,
|
||||
0,
|
||||
NULL,
|
||||
font_width,
|
||||
font_height,
|
||||
text,
|
||||
strlen (text),
|
||||
color,
|
||||
overall_alpha,
|
||||
inverted);
|
||||
|
||||
return pixbuf;
|
||||
}
|
||||
|
||||
#if !defined (NAUTILUS_OMIT_SELF_CHECK)
|
||||
|
||||
void
|
||||
|
|
|
@ -100,13 +100,13 @@ void nautilus_scalable_font_draw_text (c
|
|||
guint text_length,
|
||||
guint32 color,
|
||||
guchar overall_alpha,
|
||||
gboolean inverted);
|
||||
gboolean inverted);
|
||||
void nautilus_scalable_font_measure_text_lines (const NautilusScalableFont *font,
|
||||
guint font_width,
|
||||
guint font_height,
|
||||
const char *text,
|
||||
guint num_text_lines,
|
||||
double empty_line_height,
|
||||
double empty_line_height,
|
||||
guint text_line_widths[],
|
||||
guint text_line_heights[],
|
||||
guint *max_width_out,
|
||||
|
@ -124,10 +124,10 @@ void nautilus_scalable_font_draw_text_lines_with_dimensions (c
|
|||
const guint *text_line_heights,
|
||||
GtkJustification justification,
|
||||
guint line_offset,
|
||||
double empty_line_height,
|
||||
double empty_line_height,
|
||||
guint32 color,
|
||||
guchar overall_alpha,
|
||||
gboolean inverted);
|
||||
gboolean inverted);
|
||||
void nautilus_scalable_font_draw_text_lines (const NautilusScalableFont *font,
|
||||
GdkPixbuf *destination_pixbuf,
|
||||
int x,
|
||||
|
@ -138,10 +138,10 @@ void nautilus_scalable_font_draw_text_lines (c
|
|||
const char *text,
|
||||
GtkJustification justification,
|
||||
guint line_offset,
|
||||
double empty_line_height,
|
||||
double empty_line_height,
|
||||
guint32 color,
|
||||
guchar overall_alpha,
|
||||
gboolean inverted);
|
||||
gboolean inverted);
|
||||
guint nautilus_scalable_font_largest_fitting_font_size (const NautilusScalableFont *font,
|
||||
const char *text,
|
||||
guint available_width,
|
||||
|
@ -157,6 +157,16 @@ gboolean nautilus_scalable_font_query_font (c
|
|||
NautilusStringList **weights,
|
||||
NautilusStringList **slants,
|
||||
NautilusStringList **set_widths);
|
||||
GdkPixbuf * nautilus_gdk_pixbuf_new_from_text (const NautilusScalableFont *font,
|
||||
guint font_width,
|
||||
guint font_height,
|
||||
const char *text,
|
||||
guint text_length,
|
||||
guint32 color,
|
||||
guchar overall_alpha,
|
||||
gboolean inverted);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* The following text_layout stuff was shamelessly plundered
|
||||
|
@ -198,7 +208,7 @@ void nautilus_text_layout_paint (const NautilusTextLayout *text
|
|||
GdkPixbuf *pixbuf,
|
||||
int x,
|
||||
int y,
|
||||
GtkJustification just,
|
||||
GtkJustification justification,
|
||||
guint32 color,
|
||||
gboolean inverted,
|
||||
gboolean underlined);
|
||||
|
|
|
@ -785,8 +785,7 @@ nautilus_scalable_font_draw_text (const NautilusScalableFont *font,
|
|||
invert_area = glyph_area;
|
||||
}
|
||||
|
||||
//if (!art_irect_empty (&invert_area)) {
|
||||
{
|
||||
if (!art_irect_empty (&invert_area)) {
|
||||
guchar *glyph_pixels;
|
||||
guint glyph_rowstride;
|
||||
|
||||
|
@ -1703,7 +1702,7 @@ nautilus_text_layout_paint (const NautilusTextLayout *text_layout,
|
|||
text_layout->font_size,
|
||||
row->text,
|
||||
row->text_length,
|
||||
color,
|
||||
NAUTILUS_RGBA_COLOR_PACK (255, 255, 255, 255),
|
||||
255,
|
||||
inverted);
|
||||
|
||||
|
@ -1731,6 +1730,60 @@ nautilus_text_layout_paint (const NautilusTextLayout *text_layout,
|
|||
}
|
||||
}
|
||||
|
||||
GdkPixbuf *
|
||||
nautilus_gdk_pixbuf_new_from_text (const NautilusScalableFont *font,
|
||||
guint font_width,
|
||||
guint font_height,
|
||||
const char *text,
|
||||
guint text_length,
|
||||
guint32 color,
|
||||
guchar overall_alpha,
|
||||
gboolean inverted)
|
||||
{
|
||||
GdkPixbuf *pixbuf;
|
||||
guint text_width;
|
||||
guint text_height;
|
||||
|
||||
g_return_val_if_fail (NAUTILUS_IS_SCALABLE_FONT (font), NULL);
|
||||
g_return_val_if_fail (font_width > 0, NULL);
|
||||
g_return_val_if_fail (font_height > 0, NULL);
|
||||
|
||||
if (text == NULL || text[0] == '\0' || text_length == 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
g_return_val_if_fail (text_length <= strlen (text), NULL);
|
||||
|
||||
nautilus_scalable_font_measure_text (font,
|
||||
font_width,
|
||||
font_height,
|
||||
text,
|
||||
strlen (text),
|
||||
&text_width,
|
||||
&text_height);
|
||||
g_assert (text_width > 0);
|
||||
g_assert (text_height > 0);
|
||||
|
||||
pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, text_width, text_height);
|
||||
|
||||
nautilus_gdk_pixbuf_fill_rectangle_with_color (pixbuf, NULL, NAUTILUS_RGBA_COLOR_PACK (0, 0, 0, 0));
|
||||
|
||||
nautilus_scalable_font_draw_text (font,
|
||||
pixbuf,
|
||||
0,
|
||||
0,
|
||||
NULL,
|
||||
font_width,
|
||||
font_height,
|
||||
text,
|
||||
strlen (text),
|
||||
color,
|
||||
overall_alpha,
|
||||
inverted);
|
||||
|
||||
return pixbuf;
|
||||
}
|
||||
|
||||
#if !defined (NAUTILUS_OMIT_SELF_CHECK)
|
||||
|
||||
void
|
||||
|
|
|
@ -100,13 +100,13 @@ void nautilus_scalable_font_draw_text (c
|
|||
guint text_length,
|
||||
guint32 color,
|
||||
guchar overall_alpha,
|
||||
gboolean inverted);
|
||||
gboolean inverted);
|
||||
void nautilus_scalable_font_measure_text_lines (const NautilusScalableFont *font,
|
||||
guint font_width,
|
||||
guint font_height,
|
||||
const char *text,
|
||||
guint num_text_lines,
|
||||
double empty_line_height,
|
||||
double empty_line_height,
|
||||
guint text_line_widths[],
|
||||
guint text_line_heights[],
|
||||
guint *max_width_out,
|
||||
|
@ -124,10 +124,10 @@ void nautilus_scalable_font_draw_text_lines_with_dimensions (c
|
|||
const guint *text_line_heights,
|
||||
GtkJustification justification,
|
||||
guint line_offset,
|
||||
double empty_line_height,
|
||||
double empty_line_height,
|
||||
guint32 color,
|
||||
guchar overall_alpha,
|
||||
gboolean inverted);
|
||||
gboolean inverted);
|
||||
void nautilus_scalable_font_draw_text_lines (const NautilusScalableFont *font,
|
||||
GdkPixbuf *destination_pixbuf,
|
||||
int x,
|
||||
|
@ -138,10 +138,10 @@ void nautilus_scalable_font_draw_text_lines (c
|
|||
const char *text,
|
||||
GtkJustification justification,
|
||||
guint line_offset,
|
||||
double empty_line_height,
|
||||
double empty_line_height,
|
||||
guint32 color,
|
||||
guchar overall_alpha,
|
||||
gboolean inverted);
|
||||
gboolean inverted);
|
||||
guint nautilus_scalable_font_largest_fitting_font_size (const NautilusScalableFont *font,
|
||||
const char *text,
|
||||
guint available_width,
|
||||
|
@ -157,6 +157,16 @@ gboolean nautilus_scalable_font_query_font (c
|
|||
NautilusStringList **weights,
|
||||
NautilusStringList **slants,
|
||||
NautilusStringList **set_widths);
|
||||
GdkPixbuf * nautilus_gdk_pixbuf_new_from_text (const NautilusScalableFont *font,
|
||||
guint font_width,
|
||||
guint font_height,
|
||||
const char *text,
|
||||
guint text_length,
|
||||
guint32 color,
|
||||
guchar overall_alpha,
|
||||
gboolean inverted);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* The following text_layout stuff was shamelessly plundered
|
||||
|
@ -198,7 +208,7 @@ void nautilus_text_layout_paint (const NautilusTextLayout *text
|
|||
GdkPixbuf *pixbuf,
|
||||
int x,
|
||||
int y,
|
||||
GtkJustification just,
|
||||
GtkJustification justification,
|
||||
guint32 color,
|
||||
gboolean inverted,
|
||||
gboolean underlined);
|
||||
|
|
|
@ -25,6 +25,11 @@
|
|||
#include <libart_lgpl/art_svp_vpath_stroke.h>
|
||||
#include <libart_lgpl/art_rgb_svp.h>
|
||||
#include <libart_lgpl/art_svp_vpath.h>
|
||||
#include <libart_lgpl/art_rgb.h>
|
||||
|
||||
#include <libgnomevfs/gnome-vfs-init.h>
|
||||
|
||||
/* Danger! Many Gremlins live here. */
|
||||
|
||||
/* FIXME: Need to account for word endianess in these macros */
|
||||
#define ART_OPACITY_NONE 255
|
||||
|
@ -54,67 +59,144 @@
|
|||
#define BLUE ART_RGB_COLOR_PACK (0, 0, 255)
|
||||
#define WHITE ART_RGB_COLOR_PACK (255, 255, 255)
|
||||
#define BLACK ART_RGB_COLOR_PACK (0, 0, 0)
|
||||
#define TRANSPARENT ART_RGB_COLOR_PACK (255, 255, 255)
|
||||
#define TRANSPARENT ART_RGBA_COLOR_PACK (255, 255, 255, 0)
|
||||
|
||||
static void
|
||||
gdk_pixbuf_draw_rectangle (GdkPixbuf *pixbuf,
|
||||
const ArtIRect *rectangle,
|
||||
guint32 color)
|
||||
static GdkPixbuf *
|
||||
create_named_background (const char *name)
|
||||
{
|
||||
ArtVpath vpath[6];
|
||||
ArtSVP *svp;
|
||||
|
||||
g_return_if_fail (pixbuf != NULL);
|
||||
g_return_if_fail (rectangle != NULL);
|
||||
g_return_if_fail (rectangle->x1 > rectangle->x0);
|
||||
g_return_if_fail (rectangle->y1 > rectangle->y0);
|
||||
|
||||
vpath[0].code = ART_MOVETO;
|
||||
vpath[0].x = rectangle->x0;
|
||||
vpath[0].y = rectangle->y0;
|
||||
|
||||
vpath[1].code = ART_LINETO;
|
||||
vpath[1].x = rectangle->x1;
|
||||
vpath[1].y = rectangle->y0;
|
||||
|
||||
vpath[2].code = ART_LINETO;
|
||||
vpath[2].x = rectangle->x1;
|
||||
vpath[2].y = rectangle->y1;
|
||||
|
||||
vpath[3].code = ART_LINETO;
|
||||
vpath[3].x = rectangle->x0;
|
||||
vpath[3].y = rectangle->y1;
|
||||
|
||||
vpath[4].code = ART_LINETO;
|
||||
vpath[4].x = rectangle->x0;
|
||||
vpath[4].y = rectangle->y0;
|
||||
|
||||
vpath[5].code = ART_END;
|
||||
|
||||
svp = art_svp_vpath_stroke (vpath,
|
||||
ART_PATH_STROKE_JOIN_BEVEL,
|
||||
ART_PATH_STROKE_CAP_SQUARE,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0);
|
||||
|
||||
art_rgb_svp_alpha (svp,
|
||||
0,
|
||||
0,
|
||||
gdk_pixbuf_get_width (pixbuf),
|
||||
gdk_pixbuf_get_height (pixbuf),
|
||||
color,
|
||||
gdk_pixbuf_get_pixels (pixbuf),
|
||||
gdk_pixbuf_get_rowstride (pixbuf),
|
||||
NULL);
|
||||
GdkPixbuf *pixbuf;
|
||||
char *path;
|
||||
|
||||
art_svp_free (svp);
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
|
||||
path = nautilus_make_path (NAUTILUS_DATADIR "/backgrounds", name);
|
||||
|
||||
if (path == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pixbuf = gdk_pixbuf_new_from_file (path);
|
||||
g_free (path);
|
||||
|
||||
return pixbuf;
|
||||
}
|
||||
|
||||
static void
|
||||
draw_rectangle_around (GdkPixbuf *pixbuf,
|
||||
rgba_run_alpha (art_u8 *buf, art_u8 r, art_u8 g, art_u8 b, int alpha, int n)
|
||||
{
|
||||
int i;
|
||||
int v;
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
v = *buf;
|
||||
*buf++ = v + (((r - v) * alpha + 0x80) >> 8);
|
||||
v = *buf;
|
||||
*buf++ = v + (((g - v) * alpha + 0x80) >> 8);
|
||||
v = *buf;
|
||||
*buf++ = v + (((b - v) * alpha + 0x80) >> 8);
|
||||
|
||||
*buf++ = 255;
|
||||
}
|
||||
}
|
||||
|
||||
typedef void (*RunFunc) (art_u8 *buf, art_u8 r, art_u8 g, art_u8 b, int alpha, int n);
|
||||
|
||||
static void
|
||||
pixbuf_draw_rectangle (GdkPixbuf *pixbuf,
|
||||
const ArtIRect *rectangle,
|
||||
guint32 color)
|
||||
guint32 color,
|
||||
gboolean filled)
|
||||
{
|
||||
guchar red;
|
||||
guchar green;
|
||||
guchar blue;
|
||||
guchar alpha;
|
||||
|
||||
guint width;
|
||||
guint height;
|
||||
guchar *pixels;
|
||||
guint rowstride;
|
||||
int y;
|
||||
gboolean has_alpha;
|
||||
guint pixel_offset;
|
||||
guchar *offset;
|
||||
|
||||
guint rect_width;
|
||||
guint rect_height;
|
||||
|
||||
ArtIRect draw_area;
|
||||
|
||||
RunFunc run_func;
|
||||
|
||||
g_return_if_fail (pixbuf != NULL);
|
||||
|
||||
width = gdk_pixbuf_get_width (pixbuf);
|
||||
height = gdk_pixbuf_get_height (pixbuf);
|
||||
pixels = gdk_pixbuf_get_pixels (pixbuf);
|
||||
rowstride = gdk_pixbuf_get_rowstride (pixbuf);
|
||||
has_alpha = gdk_pixbuf_get_has_alpha (pixbuf);
|
||||
pixel_offset = has_alpha ? 4 : 3;
|
||||
|
||||
red = ART_RGBA_GET_R (color);
|
||||
green = ART_RGBA_GET_G (color);
|
||||
blue = ART_RGBA_GET_B (color);
|
||||
alpha = ART_RGBA_GET_A (color);
|
||||
|
||||
run_func = has_alpha ? rgba_run_alpha : art_rgb_run_alpha;
|
||||
|
||||
if (rectangle != NULL) {
|
||||
g_return_if_fail (rectangle->x1 > rectangle->x0);
|
||||
g_return_if_fail (rectangle->y1 > rectangle->y0);
|
||||
|
||||
rect_width = rectangle->x1 - rectangle->x0;
|
||||
rect_height = rectangle->y1 - rectangle->y0;
|
||||
|
||||
draw_area = *rectangle;
|
||||
}
|
||||
else {
|
||||
rect_width = width;
|
||||
rect_height = height;
|
||||
|
||||
draw_area.x0 = 0;
|
||||
draw_area.y0 = 0;
|
||||
draw_area.x1 = width;
|
||||
draw_area.y1 = height;
|
||||
}
|
||||
|
||||
if (filled) {
|
||||
offset = pixels + (draw_area.y0 * rowstride) + (draw_area.x0 * pixel_offset);
|
||||
|
||||
for (y = draw_area.y0; y < draw_area.y1; y++) {
|
||||
(*run_func) (offset, red, green, blue, 255, rect_width);
|
||||
offset += rowstride;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* top */
|
||||
offset = pixels + (draw_area.y0 * rowstride) + (draw_area.x0 * pixel_offset);
|
||||
(*run_func) (offset, red, green, blue, 255, rect_width);
|
||||
|
||||
/* bottom */
|
||||
offset += ((rect_height - 1) * rowstride);
|
||||
(*run_func) (offset, red, green, blue, 255, rect_width);
|
||||
|
||||
for (y = draw_area.y0 + 1; y < (draw_area.y1 - 1); y++) {
|
||||
/* left */
|
||||
offset = pixels + (y * rowstride) + (draw_area.x0 * pixel_offset);
|
||||
(*run_func) (offset, red, green, blue, 255, 1);
|
||||
|
||||
/* right */
|
||||
offset += (rect_width - 1) * pixel_offset;
|
||||
(*run_func) (offset, red, green, blue, 255, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
pixbuf_draw_rectangle_around (GdkPixbuf *pixbuf,
|
||||
const ArtIRect *rectangle,
|
||||
guint32 color)
|
||||
{
|
||||
ArtIRect area;
|
||||
|
||||
|
@ -129,7 +211,7 @@ draw_rectangle_around (GdkPixbuf *pixbuf,
|
|||
area.y0 -= 1;
|
||||
area.x1 += 1;
|
||||
area.y1 += 1;
|
||||
gdk_pixbuf_draw_rectangle (pixbuf, &area, color);
|
||||
pixbuf_draw_rectangle (pixbuf, &area, color, FALSE);
|
||||
area.x0 += 1;
|
||||
area.y0 += 1;
|
||||
area.x1 -= 1;
|
||||
|
@ -159,6 +241,7 @@ main (int argc, char* argv[])
|
|||
|
||||
gtk_init (&argc, &argv);
|
||||
gdk_rgb_init ();
|
||||
gnome_vfs_init ();
|
||||
|
||||
font = NAUTILUS_SCALABLE_FONT (nautilus_scalable_font_new ("Nimbus Sans L", NULL, NULL, NULL));
|
||||
g_assert (font != NULL);
|
||||
|
@ -166,7 +249,7 @@ main (int argc, char* argv[])
|
|||
pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, pixbuf_width, pixbuf_height);
|
||||
g_assert (pixbuf != NULL);
|
||||
|
||||
nautilus_gdk_pixbuf_fill_rectangle_with_color (pixbuf, NULL, TRANSPARENT);
|
||||
pixbuf_draw_rectangle (pixbuf, NULL, TRANSPARENT, TRUE);
|
||||
|
||||
multi_lines_area.x0 = multi_line_x;
|
||||
multi_lines_area.y0 = multi_line_y;
|
||||
|
@ -213,14 +296,14 @@ main (int argc, char* argv[])
|
|||
clip_area.x1 = clip_area.x0 + 100;
|
||||
clip_area.y1 = clip_area.y0 + 30;
|
||||
|
||||
draw_rectangle_around (pixbuf, &clip_area, RED);
|
||||
pixbuf_draw_rectangle_around (pixbuf, &clip_area, RED);
|
||||
|
||||
whole_area.x0 = 0;
|
||||
whole_area.y0 = 0;
|
||||
whole_area.x1 = whole_area.x0 + pixbuf_width;
|
||||
whole_area.y1 = whole_area.y0 + pixbuf_height;
|
||||
|
||||
draw_rectangle_around (pixbuf, &multi_lines_area, RED);
|
||||
pixbuf_draw_rectangle_around (pixbuf, &multi_lines_area, RED);
|
||||
|
||||
/*
|
||||
* Multiple text lines test.
|
||||
|
@ -276,6 +359,67 @@ main (int argc, char* argv[])
|
|||
255,
|
||||
TRUE);
|
||||
|
||||
|
||||
/*
|
||||
* Composited text lines test.
|
||||
*/
|
||||
{
|
||||
ArtIRect composited_area;
|
||||
GdkPixbuf *background_pixbuf;
|
||||
GdkPixbuf *text_pixbuf;
|
||||
GdkRectangle dest_rect;
|
||||
|
||||
const char *text = "Foo Bar";
|
||||
const guint font_size = 50;
|
||||
|
||||
background_pixbuf = create_named_background ("pale_coins.png");
|
||||
|
||||
composited_area.x0 = 270;
|
||||
composited_area.y0 = 80;
|
||||
composited_area.x1 = composited_area.x0 + 200;
|
||||
composited_area.y1 = composited_area.y0 + 200;
|
||||
|
||||
pixbuf_draw_rectangle_around (pixbuf, &composited_area, RED);
|
||||
|
||||
dest_rect.x = composited_area.x0;
|
||||
dest_rect.y = composited_area.y0;
|
||||
dest_rect.width = composited_area.x1 - composited_area.x0;
|
||||
dest_rect.height = composited_area.y1 - composited_area.y0;
|
||||
|
||||
nautilus_gdk_pixbuf_render_to_pixbuf_tiled (background_pixbuf,
|
||||
pixbuf,
|
||||
&dest_rect,
|
||||
0,
|
||||
0);
|
||||
|
||||
gdk_pixbuf_unref (background_pixbuf);
|
||||
|
||||
text_pixbuf = nautilus_gdk_pixbuf_new_from_text (font,
|
||||
font_size,
|
||||
font_size,
|
||||
text,
|
||||
strlen (text),
|
||||
BLACK,
|
||||
255,
|
||||
FALSE);
|
||||
g_assert (text_pixbuf != NULL);
|
||||
|
||||
gdk_pixbuf_composite (text_pixbuf,
|
||||
pixbuf,
|
||||
composited_area.x0,
|
||||
composited_area.y0,
|
||||
gdk_pixbuf_get_width (text_pixbuf),
|
||||
gdk_pixbuf_get_height (text_pixbuf),
|
||||
(double) composited_area.x0,
|
||||
(double) composited_area.y0,
|
||||
1.0,
|
||||
1.0,
|
||||
GDK_INTERP_BILINEAR,
|
||||
255);
|
||||
|
||||
gdk_pixbuf_unref (text_pixbuf);
|
||||
}
|
||||
|
||||
/*
|
||||
* Text layout test.
|
||||
*/
|
||||
|
@ -300,7 +444,7 @@ main (int argc, char* argv[])
|
|||
layout_area.x1 = layout_area.x0 + max_text_width;
|
||||
layout_area.y1 = layout_area.y0 + 130;
|
||||
|
||||
draw_rectangle_around (pixbuf, &layout_area, RED);
|
||||
pixbuf_draw_rectangle_around (pixbuf, &layout_area, RED);
|
||||
|
||||
nautilus_text_layout_paint (text_layout,
|
||||
pixbuf,
|
||||
|
@ -314,7 +458,7 @@ main (int argc, char* argv[])
|
|||
layout_area.x0 += (max_text_width + 20);
|
||||
layout_area.x1 += (max_text_width + 20);
|
||||
|
||||
draw_rectangle_around (pixbuf, &layout_area, RED);
|
||||
pixbuf_draw_rectangle_around (pixbuf, &layout_area, RED);
|
||||
|
||||
nautilus_text_layout_paint (text_layout,
|
||||
pixbuf,
|
||||
|
@ -328,7 +472,7 @@ main (int argc, char* argv[])
|
|||
layout_area.x0 += (max_text_width + 20);
|
||||
layout_area.x1 += (max_text_width + 20);
|
||||
|
||||
draw_rectangle_around (pixbuf, &layout_area, RED);
|
||||
pixbuf_draw_rectangle_around (pixbuf, &layout_area, RED);
|
||||
|
||||
nautilus_text_layout_paint (text_layout,
|
||||
pixbuf,
|
||||
|
@ -366,7 +510,7 @@ main (int argc, char* argv[])
|
|||
layout_area.x1 = layout_area.x0 + text_layout->width;
|
||||
layout_area.y1 = layout_area.y0 + text_layout->height;
|
||||
|
||||
draw_rectangle_around (pixbuf, &layout_area, RED);
|
||||
pixbuf_draw_rectangle_around (pixbuf, &layout_area, RED);
|
||||
|
||||
nautilus_text_layout_paint (text_layout,
|
||||
pixbuf,
|
||||
|
@ -386,5 +530,7 @@ main (int argc, char* argv[])
|
|||
|
||||
gdk_pixbuf_unref (pixbuf);
|
||||
|
||||
gnome_vfs_shutdown ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue