You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
74 lines
1.7 KiB
C
74 lines
1.7 KiB
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include "images.h"
|
|
|
|
|
|
void test_transparency();
|
|
void test_4k_gradient();
|
|
|
|
void main() {
|
|
test_transparency();
|
|
}
|
|
|
|
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() {
|
|
int width = 1920 * 4,
|
|
height = 1080 * 4;
|
|
|
|
printf("allocating image\n");
|
|
Image img;
|
|
image_new(width, height, &img);
|
|
|
|
printf("writing pixies\n");
|
|
|
|
for (int i = 0; i < width; i++) {
|
|
for (int j = 0; j < height; j++) {
|
|
int color = ((j / ((float) height)) * 255);
|
|
image_set_px(img, i, j, 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");
|
|
} |