/** This function tests three differently encoded images against the original bitmap */ static void test_three_encodings(skiatest::Reporter* reporter, InstallEncoded install) { SkBitmap original; make_test_image(&original); REPORTER_ASSERT(reporter, !original.empty()); REPORTER_ASSERT(reporter, !original.isNull()); if (original.empty() || original.isNull()) { return; } static const SkImageEncoder::Type types[] = { SkImageEncoder::kPNG_Type, SkImageEncoder::kJPEG_Type, SkImageEncoder::kWEBP_Type }; for (size_t i = 0; i < SK_ARRAY_COUNT(types); i++) { SkImageEncoder::Type type = types[i]; SkAutoDataUnref encoded(create_data_from_bitmap(original, type)); REPORTER_ASSERT(reporter, encoded.get() != NULL); if (NULL == encoded.get()) { continue; } SkBitmap lazy; bool installSuccess = install(encoded.get(), &lazy); REPORTER_ASSERT(reporter, installSuccess); if (!installSuccess) { continue; } REPORTER_ASSERT(reporter, NULL == lazy.getPixels()); { SkAutoLockPixels autoLockPixels(lazy); // now pixels are good. REPORTER_ASSERT(reporter, lazy.getPixels()); if (NULL == lazy.getPixels()) { continue; } } // pixels should be gone! REPORTER_ASSERT(reporter, NULL == lazy.getPixels()); { SkAutoLockPixels autoLockPixels(lazy); // now pixels are good. REPORTER_ASSERT(reporter, lazy.getPixels()); if (NULL == lazy.getPixels()) { continue; } } bool comparePixels = (SkImageEncoder::kPNG_Type == type); compare_bitmaps(reporter, original, lazy, comparePixels); } }
int main(int argc, char *argv[]) { GdkPixbuf *pxb; GError *error=NULL; guchar *buffer; gsize size, pos; FILE *fh; gint i, j; GwyDataField *a, *b, *c, *d, *p; GwyDataLine *k, *m, n; GwyPalette *pal; g_type_init(); g_message("preparing data_field..."); a = (GwyDataField *) gwy_data_field_new(512, 512, 512, 512, 1); b = (GwyDataField *) gwy_data_field_new(512, 512, 512, 512, 1); c = (GwyDataField *) gwy_data_field_new(512, 512, 512, 512, 1); d = (GwyDataField *) gwy_data_field_new(512, 512, 512, 512, 1); p = (GwyDataField *) gwy_data_field_new(512, 512, 512, 512, 1); k = (GwyDataLine *) gwy_data_line_new(20, 20, 1); m = (GwyDataLine *) gwy_data_line_new(500, 20, 1); gwy_data_line_initialize(&n, 500, 20, 1); make_test_image(a); make_test_image(p); make_test_line(m); // gwy_data_line_hhcf(m, k); gwy_data_field_get_line_stat_function(a, &n, 0, 0, 300, 300, /*GwySFOutputType*/ GWY_SF_OUTPUT_PSDF, /*GtkOrientation*/ 0, /*interpolation*/ 1, /*GwyWindowingType*/ 1, /*nstats*/ 200); printf("Dataline:\n"); for (i=0; i<10; i++) printf("%d %f\n", i, n.data[i]); /* gwy_data_field_2dfft(a, b, c, d, gwy_data_line_fft_hum, GWY_WINDOWING_RECT, 1, GWY_INTERPOLATION_BILINEAR, 0, 0); gwy_data_field_copy(c, a); gwy_data_field_copy(d, b); gwy_data_field_fill(c, 0); gwy_data_field_fill(d, 0); gwy_data_field_2dfft(a, b, c, d, gwy_data_line_fft_hum, GWY_WINDOWING_RECT, -1, GWY_INTERPOLATION_BILINEAR, 0, 0); */ /* for (i=0; i<512; i++) { printf("%f %f\n", a->data[20 + 512*i], //sqrt(a->data[20 + 512*i]*a->data[20 + 512*i]+ b->data[20 + 512*i]*b->data[20 + 512*i]), p->data[20 + 512*i]); } */ /* gwy_palette_def_setup_presets(); pal = (GwyPalette*) gwy_palette_new(NULL); gwy_palette_set_by_name(pal, GWY_PALETTE_OLIVE); pxb = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, a->xres, a->yres); gwy_pixfield_do(pxb, a, pal); gdk_pixbuf_save(pxb, "a.jpg", "jpeg", &error, "quality", "100", NULL); gwy_pixfield_do(pxb, b, pal); gdk_pixbuf_save(pxb, "b.jpg", "jpeg", &error, "quality", "100", NULL); gwy_pixfield_do(pxb, c, pal); gdk_pixbuf_save(pxb, "c.jpg", "jpeg", &error, "quality", "100", NULL); gwy_pixfield_do(pxb, d, pal); gdk_pixbuf_save(pxb, "d.jpg", "jpeg", &error, "quality", "100", NULL); */ return 0; }