static gboolean
memory_format_is_high_depth (GdkMemoryFormat format)
{ switch (format)
{ case GDK_MEMORY_R8G8B8: case GDK_MEMORY_B8G8R8: case GDK_MEMORY_B8G8R8A8_PREMULTIPLIED: case GDK_MEMORY_A8R8G8B8_PREMULTIPLIED: case GDK_MEMORY_R8G8B8A8_PREMULTIPLIED: case GDK_MEMORY_A8B8G8R8_PREMULTIPLIED: case GDK_MEMORY_B8G8R8A8: case GDK_MEMORY_A8R8G8B8: case GDK_MEMORY_R8G8B8A8: case GDK_MEMORY_A8B8G8R8: case GDK_MEMORY_B8G8R8X8: case GDK_MEMORY_X8R8G8B8: case GDK_MEMORY_R8G8B8X8: case GDK_MEMORY_X8B8G8R8: case GDK_MEMORY_G8: case GDK_MEMORY_G8A8: case GDK_MEMORY_G8A8_PREMULTIPLIED: case GDK_MEMORY_A8: case GDK_MEMORY_G8_B8R8_420: case GDK_MEMORY_G8_R8B8_420: case GDK_MEMORY_G8_B8R8_422: case GDK_MEMORY_G8_R8B8_422: case GDK_MEMORY_G8_B8R8_444: case GDK_MEMORY_G8_R8B8_444: case GDK_MEMORY_G8_B8_R8_410: case GDK_MEMORY_G8_R8_B8_410: case GDK_MEMORY_G8_B8_R8_411: case GDK_MEMORY_G8_R8_B8_411: case GDK_MEMORY_G8_B8_R8_420: case GDK_MEMORY_G8_R8_B8_420: case GDK_MEMORY_G8_B8_R8_422: case GDK_MEMORY_G8_R8_B8_422: case GDK_MEMORY_G8_B8_R8_444: case GDK_MEMORY_G8_R8_B8_444: case GDK_MEMORY_G8B8G8R8_422: case GDK_MEMORY_G8R8G8B8_422: case GDK_MEMORY_R8G8B8G8_422: case GDK_MEMORY_B8G8R8G8_422: returnFALSE;
case GDK_MEMORY_R16G16B16: case GDK_MEMORY_R16G16B16A16_PREMULTIPLIED: case GDK_MEMORY_R16G16B16A16: case GDK_MEMORY_G16: case GDK_MEMORY_G16A16: case GDK_MEMORY_G16A16_PREMULTIPLIED: case GDK_MEMORY_A16: case GDK_MEMORY_R16G16B16_FLOAT: case GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED: case GDK_MEMORY_R16G16B16A16_FLOAT: case GDK_MEMORY_A16_FLOAT: case GDK_MEMORY_R32G32B32_FLOAT: case GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED: case GDK_MEMORY_R32G32B32A32_FLOAT: case GDK_MEMORY_A32_FLOAT: case GDK_MEMORY_G10X6_B10X6R10X6_420: case GDK_MEMORY_G12X4_B12X4R12X4_420: case GDK_MEMORY_G16_B16R16_420: case GDK_MEMORY_X6G10_X6B10_X6R10_420: case GDK_MEMORY_X6G10_X6B10_X6R10_422: case GDK_MEMORY_X6G10_X6B10_X6R10_444: case GDK_MEMORY_X4G12_X4B12_X4R12_420: case GDK_MEMORY_X4G12_X4B12_X4R12_422: case GDK_MEMORY_X4G12_X4B12_X4R12_444: case GDK_MEMORY_G16_B16_R16_420: case GDK_MEMORY_G16_B16_R16_422: case GDK_MEMORY_G16_B16_R16_444: case GDK_MEMORY_ARGB2101010_PREMULTIPLIED: case GDK_MEMORY_ARGB2101010: case GDK_MEMORY_XRGB2101010: case GDK_MEMORY_ABGR2101010_PREMULTIPLIED: case GDK_MEMORY_ABGR2101010: case GDK_MEMORY_XBGR2101010: returnTRUE;
case GDK_MEMORY_N_FORMATS: default:
g_assert_not_reached (); returnFALSE;
}
}
for (y = 0; y < height; y++)
{ const guint32 *row_a = (const guint32 *) (buf_a + y * stride_a); const guint32 *row_b = (const guint32 *) (buf_b + y * stride_b);
guint32 *row = (guint32 *) (buf_diff + y * stride_diff);
for (x = 0; x < width; x++)
{ int channel;
guint32 diff_pixel = 0; unsignedint dist;
/* even if they're not literally the same, fully-transparent *pixelsareeffectivelythesameregardlessofcolour
*/ if ((row_a[x] & 0xff000000) == 0 && (row_b[x] & 0xff000000) == 0) continue;
/* check if the pixels are the same */
dist = 0; for (channel = 0; channel < 3; channel++)
{ int value_a = (row_a[x] >> (channel*8)) & 0xff; int value_b = (row_b[x] >> (channel*8)) & 0xff;
dist = MAX (dist, abs (value_a - value_b));
} if (dist < tolerance + 1) continue;
if (diff == NULL)
{
GdkMemoryTextureBuilder *builder;
GBytes *bytes;
if ((diff_pixel & 0x00ffffff) == 0)
{ /* alpha only difference, convert to luminance */
guint8 alpha = diff_pixel >> 24;
diff_pixel = alpha * 0x010101;
} /* make the pixel fully opaque */
diff_pixel |= 0xff000000;
row[x] = diff_pixel;
}
}
return diff;
}
/* Compares two FLOAT buffers, returning NULL if the *buffersareequalorasurfacecontainingadiffbetweenthetwo *surfaces.
*/ static GdkTexture *
buffer_diff_float (GdkColorState *color_state, const guchar *buf_a, int stride_a, const guchar *buf_b, int stride_b, int width, int height, int tolerance)
{ int x, y;
guchar *buf_diff = NULL; int stride_diff = 0;
GdkTexture *diff = NULL;
for (y = 0; y < height; y++)
{ constfloat *row_a = (constfloat *) (buf_a + y * stride_a); constfloat *row_b = (constfloat *) (buf_b + y * stride_b); float *row = (float *) (buf_diff + y * stride_diff);
for (x = 0; x < width; x++)
{ int channel; float dist;
/* even if they're not literally the same, fully-transparent *pixelsareeffectivelythesameregardlessofcolor
*/ if (G_APPROX_VALUE (row_a[4 * x + 3], 0.0, 1. / 255) &&
G_APPROX_VALUE (row_b[4 * x + 3], 0.0, 1. / 255)) continue;
/* check if the pixels are the same */
dist = 0; for (channel = 0; channel < 3; channel++)
{ float value_a = row_a[4 * x + channel]; float value_b = row_b[4 * x + channel];
dist = MAX (dist, fabs (value_a - value_b));
} if (dist * 255 < tolerance + 1) continue;
if (diff == NULL)
{
GdkMemoryTextureBuilder *builder;
GBytes *bytes;
w = MAX (gdk_texture_get_width (texture1), gdk_texture_get_width (texture2));
h = MAX (gdk_texture_get_height (texture1), gdk_texture_get_height (texture2));
color_state = gdk_texture_get_color_state (texture1);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.