+ pool = mp_new(1024);
+ image_context_init(&ctx);
+
+ /* Image allocation */
+ i1 = image_new(&ctx, 731, 327, COLOR_SPACE_RGB, NULL);
+ ASSERT(i1);
+ ASSERT(i1->pixel_size == 3);
+ image_destroy(i1);
+
+ /* Test invalid image size */
+ ctx.msg_callback = image_context_msg_silent;
+ i1 = image_new(&ctx, 2214, 0, COLOR_SPACE_RGB, NULL);
+ ASSERT(!i1);
+ i1 = image_new(&ctx, 0xffffff, 0xffffff, COLOR_SPACE_RGB, NULL);
+ ASSERT(!i1);
+ ctx.msg_callback = image_context_msg_default;
+
+ /* Various image allocatio parameters */
+ i1 = image_new(&ctx, 370, 100, COLOR_SPACE_GRAYSCALE, pool);
+ ASSERT(i1);
+ ASSERT(i1->pixel_size == 1);
+ image_destroy(i1);
+ mp_flush(pool);
+
+ i1 = image_new(&ctx, 373, 101, COLOR_SPACE_RGB | IMAGE_ALIGNED, NULL);
+ ASSERT(i1);
+ ASSERT(i1->pixel_size == 4);
+ ASSERT(IMAGE_SSE_ALIGN_SIZE >= 16);
+ ASSERT(!(i1->row_size & (IMAGE_SSE_ALIGN_SIZE - 1)));
+ ASSERT(!((uintptr_t)i1->pixels & (IMAGE_SSE_ALIGN_SIZE - 1)));
+ image_destroy(i1);
+
+ i1 = image_new(&ctx, 283, 329, COLOR_SPACE_RGB, NULL);
+ ASSERT(i1);
+ ASSERT(i1->pixel_size == 3);
+
+ /* Image structures cloning */
+ i2 = image_clone(&ctx, i1, COLOR_SPACE_RGB, NULL);
+ ASSERT(i2);
+ ASSERT(i2->pixel_size == 3);
+ image_destroy(i2);
+
+ i2 = image_clone(&ctx, i1, COLOR_SPACE_RGB | IMAGE_PIXELS_ALIGNED, NULL);
+ ASSERT(i2);
+ ASSERT(i2->pixel_size == 4);
+ image_destroy(i2);
+
+ /* Subimages */
+ i2 = image_init_subimage(&ctx, &s1, i1, 29, 39, 283 - 29, 100);
+ ASSERT(i2);
+ image_destroy(&s1);
+
+ image_destroy(i1);
+
+ image_context_cleanup(&ctx);
+ mp_delete(pool);