Merge branch 'matthiasc/for-master' into 'master'

pixbufutils: Remove an unused function

See merge request GNOME/gtk!3447
This commit is contained in:
Matthias Clasen 2021-04-16 15:16:48 +00:00
commit 486a2c9651
2 changed files with 52 additions and 151 deletions

View File

@ -294,99 +294,6 @@ load_symbolic_svg (const char *escaped_file_data,
return pixbuf;
}
static void
rgba_to_pixel (const GdkRGBA *rgba,
guint8 pixel[4])
{
pixel[0] = rgba->red * 255;
pixel[1] = rgba->green * 255;
pixel[2] = rgba->blue * 255;
pixel[3] = 255;
}
GdkPixbuf *
gtk_color_symbolic_pixbuf (GdkPixbuf *symbolic,
const GdkRGBA *fg_color,
const GdkRGBA *success_color,
const GdkRGBA *warning_color,
const GdkRGBA *error_color)
{
int width, height, x, y, src_stride, dst_stride;
guchar *src_data, *dst_data;
guchar *src_row, *dst_row;
int alpha;
GdkPixbuf *colored;
guint8 fg_pixel[4], success_pixel[4], warning_pixel[4], error_pixel[4];
alpha = fg_color->alpha * 255;
rgba_to_pixel (fg_color, fg_pixel);
rgba_to_pixel (success_color, success_pixel);
rgba_to_pixel (warning_color, warning_pixel);
rgba_to_pixel (error_color, error_pixel);
width = gdk_pixbuf_get_width (symbolic);
height = gdk_pixbuf_get_height (symbolic);
colored = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, width, height);
src_stride = gdk_pixbuf_get_rowstride (symbolic);
src_data = gdk_pixbuf_get_pixels (symbolic);
dst_data = gdk_pixbuf_get_pixels (colored);
dst_stride = gdk_pixbuf_get_rowstride (colored);
for (y = 0; y < height; y++)
{
src_row = src_data + src_stride * y;
dst_row = dst_data + dst_stride * y;
for (x = 0; x < width; x++)
{
guint r, g, b, a;
int c1, c2, c3, c4;
a = src_row[3];
dst_row[3] = a * alpha / 255;
if (a == 0)
{
dst_row[0] = 0;
dst_row[1] = 0;
dst_row[2] = 0;
}
else
{
c2 = src_row[0];
c3 = src_row[1];
c4 = src_row[2];
if (c2 == 0 && c3 == 0 && c4 == 0)
{
dst_row[0] = fg_pixel[0];
dst_row[1] = fg_pixel[1];
dst_row[2] = fg_pixel[2];
}
else
{
c1 = 255 - c2 - c3 - c4;
r = fg_pixel[0] * c1 + success_pixel[0] * c2 + warning_pixel[0] * c3 + error_pixel[0] * c4;
g = fg_pixel[1] * c1 + success_pixel[1] * c2 + warning_pixel[1] * c3 + error_pixel[1] * c4;
b = fg_pixel[2] * c1 + success_pixel[2] * c2 + warning_pixel[2] * c3 + error_pixel[2] * c4;
dst_row[0] = r / 255;
dst_row[1] = g / 255;
dst_row[2] = b / 255;
}
}
src_row += 4;
dst_row += 4;
}
}
return colored;
}
static void
extract_plane (GdkPixbuf *src,
GdkPixbuf *dst,

View File

@ -22,64 +22,58 @@
G_BEGIN_DECLS
GdkPixbuf *_gdk_pixbuf_new_from_stream (GInputStream *stream,
const char *format,
GCancellable *cancellable,
GError **error);
GdkPixbuf *_gdk_pixbuf_new_from_stream_at_scale (GInputStream *stream,
const char *format,
int width,
int height,
gboolean aspect,
GCancellable *cancellable,
GError **error);
GdkPixbuf *_gdk_pixbuf_new_from_stream_scaled (GInputStream *stream,
const char *format,
double scale,
GCancellable *cancellable,
GError **error);
GdkPixbuf *_gdk_pixbuf_new_from_resource (const char *resource_path,
const char *format,
GError **error);
GdkPixbuf *_gdk_pixbuf_new_from_resource_at_scale (const char *resource_path,
const char *format,
int width,
int height,
gboolean preserve_aspect,
GError **error);
GdkPixbuf *_gdk_pixbuf_new_from_resource_scaled (const char *resource_path,
const char *format,
double scale,
GError **error);
GdkPixbuf *_gdk_pixbuf_new_from_stream (GInputStream *stream,
const char *format,
GCancellable *cancellable,
GError **error);
GdkPixbuf *_gdk_pixbuf_new_from_stream_at_scale (GInputStream *stream,
const char *format,
int width,
int height,
gboolean aspect,
GCancellable *cancellable,
GError **error);
GdkPixbuf *_gdk_pixbuf_new_from_stream_scaled (GInputStream *stream,
const char *format,
double scale,
GCancellable *cancellable,
GError **error);
GdkPixbuf *_gdk_pixbuf_new_from_resource (const char *resource_path,
const char *format,
GError **error);
GdkPixbuf *_gdk_pixbuf_new_from_resource_at_scale (const char *resource_path,
const char *format,
int width,
int height,
gboolean preserve_aspect,
GError **error);
GdkPixbuf *_gdk_pixbuf_new_from_resource_scaled (const char *resource_path,
const char *format,
double scale,
GError **error);
GdkPixbuf *gtk_color_symbolic_pixbuf (GdkPixbuf *symbolic,
const GdkRGBA *fg_color,
const GdkRGBA *success_color,
const GdkRGBA *warning_color,
const GdkRGBA *error_color);
GdkPixbuf *gtk_make_symbolic_pixbuf_from_data (const char *data,
gsize len,
int width,
int height,
double scale,
const char *debug_output_to,
GError **error);
GdkPixbuf *gtk_make_symbolic_pixbuf_from_file (GFile *file,
int width,
int height,
double scale,
GError **error);
GdkPixbuf *gtk_make_symbolic_pixbuf_from_path (const char *path,
int width,
int height,
double scale,
GError **error);
GdkPixbuf *gtk_make_symbolic_pixbuf_from_resource (const char *path,
int width,
int height,
double scale,
GError **error);
GdkPixbuf *gtk_make_symbolic_pixbuf_from_data (const char *data,
gsize len,
int width,
int height,
double scale,
const char *debug_output_to,
GError **error);
GdkPixbuf *gtk_make_symbolic_pixbuf_from_file (GFile *file,
int width,
int height,
double scale,
GError **error);
GdkPixbuf *gtk_make_symbolic_pixbuf_from_path (const char *path,
int width,
int height,
double scale,
GError **error);
GdkPixbuf *gtk_make_symbolic_pixbuf_from_resource (const char *path,
int width,
int height,
double scale,
GError **error);
GdkTexture *gtk_load_symbolic_texture_from_file (GFile *file);
GdkTexture *gtk_make_symbolic_texture_from_file (GFile *file,
int width,
@ -91,7 +85,7 @@ GdkTexture *gtk_make_symbolic_texture_from_resource (const char *path,
int width,
int height,
double scale,
GError **error);
GError **error);
G_END_DECLS
#endif /* __GDK_PIXBUF_UTILS_PRIVATE_H__ */