Подробности
[В начало]
Проблема в реализации № S0654
Краткое описание
В функции gdk_pixbuf_composite_color используется неверное смещение checkboard
Подробное описание
В описании работы функции gdk_pixbuf_composite_color сказано следующее:
Creates a transformation of the source image src by scaling by scale_x and scale_y then translating by offset_x and offset_y, then composites the rectangle (dest_x ,dest_y, dest_width, dest_height) of the resulting image with a checkboard of the colors color1 and color2 and renders it onto the destination image.
Замечание к положению checkboard(в описании параметра check_x):
origin of checkboard is at -check_x, -check_y
Однако реализация такова, что checkboard подвергается сдвигу на dest_x и dest_y перед композицией с изображением-источником, то есть реальное положение начальной точки checkboard в момент композиции - (dest_x-check_x, dest_y-check_y).
Приведённый ниже пример демонстрирует данную проблему.
Раздел стандарта
Gdk-pixbuf 2.6.2 API Reference, Scaling
Пример
#include <stdio.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#define FILENAME_1 "checkboard.ico"
#define FILENAME_2 "result.ico"
const int width = 100, height = 100;
const int dest_x = 8, dest_y = 8;
int main()
{
g_type_init();
//because overall_alpha will be 0, contents of src don't matter.
GdkPixbuf *src = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8,
width, height);
gdk_pixbuf_fill(src, 0x000000ff);
//dest will be completely rewritten during composition,
//so its contents don't matter too
GdkPixbuf *dest = gdk_pixbuf_copy(src);
gdk_pixbuf_composite_color(src, dest, 0, 0, width, height,
0, 0, 1.0, 1.0, GDK_INTERP_NEAREST,
0,
0, 0, 16, 0xff0000, 0x00ff00);
//now dest is a simple checkboard with checksize = 16 and origin at (0,0)
gdk_pixbuf_save(dest, FILENAME_1, "ico", NULL, NULL);
//perform composition when dest_x and dest_y are not 0 both.
gdk_pixbuf_composite_color(src, dest, dest_x, dest_y,
width - dest_x, height - dest_y,
0, 0, 1.0, 1.0, GDK_INTERP_NEAREST,
0,
0, 0, 16, 0xff0000, 0x00ff00);
gdk_pixbuf_save(dest, FILENAME_2, "ico", NULL, NULL);
printf("If the origin of the checkboard has not changed,"
"the destination image should remain the same\n");
printf("(%s and %s are the same images).\n",
FILENAME_1, FILENAME_2);
}
Компонент
gtk-gdk-pixbuf 2.6.2 or later
Принято
Gnome Bugzilla 583029
[В начало]