예제 #1
0
파일: test.cpp 프로젝트: caomw/heatmap
void test_render_to_normalizing()
{
    static unsigned char expected[] = {
                0, 0, 0, 0,   127, 127, 127, 255,   0, 0, 0, 0,
        127, 127, 127, 255,   255, 255, 255, 255,   127, 127, 127, 255,
                0, 0, 0, 0,   127, 127, 127, 255,   0, 0, 0, 0,
    };

    heatmap_t* hm = heatmap_new(3, 3);
    heatmap_add_point_with_stamp(hm, 1, 1, &g_3x3_stamp);

    unsigned char img[3*3*4] = {1};
    heatmap_render_to(hm, heatmap_cs_b2w, img);

    ENSURE_THAT("simple rendered 3x3 heatmap is correct", 0 == memcmp(img, expected, 3*3*4));

    heatmap_add_point_with_stamp(hm, 1, 1, &g_3x3_stamp);
    heatmap_render_to(hm, heatmap_cs_b2w, img);

    ENSURE_THAT("two points on one spot don't change the outcome, due to normalization.", 0 == memcmp(img, expected, 3*3*4));

    heatmap_free(hm);
    // TODO: (Also try negative and non-one-max stamps?)
}
예제 #2
0
파일: test.cpp 프로젝트: caomw/heatmap
void test_render_to_nothing()
{
    static unsigned char expected[] = {
        0, 0, 0, 0,   0, 0, 0, 0,   0, 0, 0, 0,
        0, 0, 0, 0,   0, 0, 0, 0,   0, 0, 0, 0,
        0, 0, 0, 0,   0, 0, 0, 0,   0, 0, 0, 0,
    };

    heatmap_t* hm = heatmap_new(3, 3);

    unsigned char img[3*3*4] = {1};
    heatmap_render_to(hm, heatmap_cs_b2w, img);
    ENSURE_THAT("empty rendered 3x3 heatmap is correct", 0 == memcmp(img, expected, 3*3*4));

    heatmap_free(hm);
}
예제 #3
0
파일: test.cpp 프로젝트: caomw/heatmap
void test_render_to_creation()
{
    static unsigned char expected[] = {
                0, 0, 0, 0,   127, 127, 127, 255,   0, 0, 0, 0,
        127, 127, 127, 255,   255, 255, 255, 255,   127, 127, 127, 255,
                0, 0, 0, 0,   127, 127, 127, 255,   0, 0, 0, 0,
    };

    heatmap_t* hm = heatmap_new(3, 3);
    heatmap_add_point_with_stamp(hm, 1, 1, &g_3x3_stamp);

    unsigned char* img = heatmap_render_to(hm, heatmap_cs_b2w, nullptr);

    ENSURE_THAT("simple rendered 3x3 heatmap is correct", 0 == memcmp(img, expected, 3*3*4));

    heatmap_free(hm);
    free(img);
}
예제 #4
0
unsigned char* heatmap_render_default_to(const heatmap_t* h, unsigned char* colorbuf)
{
    return heatmap_render_to(h, heatmap_cs_default, colorbuf);
}