|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include "images/images.h"
|
|
|
|
|
|
|
|
void test_transparency();
|
|
|
|
void test_4k_gradient();
|
|
|
|
|
|
|
|
int main(int argc, char* argv[]) {
|
|
|
|
test_transparency();
|
|
|
|
test_4k_gradient();
|
|
|
|
}
|
|
|
|
|
|
|
|
void test_transparency() {
|
|
|
|
Image img;
|
|
|
|
Color white = color_new(255,255,255);
|
|
|
|
Color green = color_new(0,255,0);
|
|
|
|
Color blue = color_new(30,50,210);
|
|
|
|
Color black = color_new(0,0,0);
|
|
|
|
|
|
|
|
image_new(512, 512, &img);
|
|
|
|
|
|
|
|
// make it white
|
|
|
|
image_draw_rect(img, 0, 0, 512, 512, white);
|
|
|
|
|
|
|
|
// draw some circs
|
|
|
|
blue.alpha = 0.5;
|
|
|
|
image_draw_circ(img, 255,255, 100, blue);
|
|
|
|
image_draw_circ(img, 255,155, 100, blue);
|
|
|
|
image_draw_circ(img, 255,355, 100, blue);
|
|
|
|
green.alpha = .6;
|
|
|
|
image_draw_circ(img, 255, 255, 12, green);
|
|
|
|
|
|
|
|
// draw a couple of rects
|
|
|
|
black.alpha = 0.5;
|
|
|
|
white.alpha = 0.5;
|
|
|
|
image_draw_square(img, 200, 255, 111, black);
|
|
|
|
image_draw_square(img, 200, 255, 101, white);
|
|
|
|
|
|
|
|
if (!image_save_bmp(img, "test-transparency.bmp")) {
|
|
|
|
printf("error writing file!\n");
|
|
|
|
} else {
|
|
|
|
printf("writing finished\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
image_destroy(img);
|
|
|
|
}
|
|
|
|
|
|
|
|
void test_4k_gradient() {
|
|
|
|
printf("allocating image\n");
|
|
|
|
Image img;
|
|
|
|
image_new(1920 * 4,1080 * 4, &img);
|
|
|
|
|
|
|
|
printf("writing pixies\n");
|
|
|
|
|
|
|
|
for (int i = 0; i < 1920 * 4; i++) {
|
|
|
|
for (int j = 0; j < 1080 * 4; j++) {
|
|
|
|
float color = (j / (1080.0f * 4)) * 255;
|
|
|
|
image_set_px(img, i, j, (int) color, 255, 255);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("writing file to disk\n");
|
|
|
|
|
|
|
|
if (!image_save_bmp(img, "test-4k.bmp")) {
|
|
|
|
printf("error writing file!\n");
|
|
|
|
} else {
|
|
|
|
printf("writing finished\n");
|
|
|
|
}
|
|
|
|
image_destroy(img);
|
|
|
|
printf("image destroyed\n");
|
|
|
|
}
|