-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.c
70 lines (59 loc) · 1.82 KB
/
test.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include <stdio.h>
#include <stdlib.h>
#include "bmp_rgb332.h"
int main(void)
{
FILE *fp;
size_t writtenSize;
uint8_t *pbmp, *pbmp_resize;
// Set allocate functions
BMP_RGB332_setAllocFunc(malloc, free);
// Create image (100pixel x 100pixel)
pbmp = BMP_RGB332_create(100, 100);
// pbmp = BMP_RGB332_create(100, 100);
if(pbmp == NULL) {
printf("Failed to create image\n");
return -1;
}
// Fill image yellow
BMP_RGB332_fillRGB(pbmp, COL_RGB_SET(0xFFFF00));
// Draw Red line (20,50) - (70,60)
BMP_RGB332_drawLineRGB(pbmp, 20, 50, 70, 60, COL_RGB_SET(0xFF0000));
// Draw green rectangle (10,20) - (30,30)
BMP_RGB332_drawRectRGB(pbmp, 10, 20, 30, 30, COL_RGB_SET(0x00FF00));
// Draw text
BMP_RGB332_drawTextRGB(pbmp, "ABC", BMP_RGB332_FONT_6X10, 10, 80, COL_RGB_SET(0x0000FF));
// Save image
fp = fopen("output.bmp", "wb");
if (fp == NULL) {
printf("Failed to open file\n");
return -1;
}
writtenSize = fwrite((uint8_t *)pbmp, sizeof(uint8_t), BMP_RGB332_getFileSize(pbmp), fp);
if( (writtenSize * sizeof(uint8_t)) != BMP_RGB332_getFileSize(pbmp)) {
printf("Failed to write image\n");
return -1;
}
fclose(fp);
// Resize image (200pixel x 70pixel)
pbmp_resize = BMP_RGB332_resize_bicubic(pbmp, 200, 70);
if(pbmp_resize == NULL) {
printf("Failed to create resize image\n");
return -1;
}
// Save resize image
fp = fopen("output_resize.bmp", "wb");
if (fp == NULL) {
printf("Failed to open file\n");
return -1;
}
writtenSize = fwrite((uint8_t *)pbmp_resize, sizeof(uint8_t), BMP_RGB332_getFileSize(pbmp_resize), fp);
if( (writtenSize * sizeof(uint8_t)) != BMP_RGB332_getFileSize(pbmp_resize)) {
printf("Failed to write image\n");
return -1;
}
fclose(fp);
BMP_RGB332_free(pbmp);
BMP_RGB332_free(pbmp_resize);
return 0;
}