// Copyright 2023 alexevier // licensed under the zlib license #include #include #include #include #include #include"test.h" void testImage(void){ testStart("image"); struct LexlibImage image; uint8_t err; if((err = lexlibImageNew(&image, 240,160, LEXLIB_RGB, 8))){ lexlibImageDelete(&image); printf("0x%X, ", err); testEnd("failed new"); return; } if((err = lexlibImageFillArea(&image, 0, 0, 1000, 1000, (struct LexlibColor){0x92, 0x59, 0xFF, 0xCC}, LEXLIB_NONE))){ lexlibImageDelete(&image); printf("0x%X, ", err); testEnd("new"); return; } if((err = lexlibImageProfileChange(&image, LEXLIB_RGBA))){ lexlibImageDelete(&image); printf("0x%X, ", err); testEnd("profile"); return; } // YES!1!1! for(int y = 0; y < 8; y++) for(int x = 0; x < 8; x++) lexlibImagePixelSet(&image, x, y, (struct LexlibColor){0xEE, 0xB5, 0x70, 0xFF}, LEXLIB_NONE); for(int i = 0; i < 8; i++) lexlibImagePixelSet(&image, i, 0, (struct LexlibColor){0xEC, 0xFF, 0xBC, 0xFF}, LEXLIB_NONE); lexlibImagePixelSet(&image, 0, 1, (struct LexlibColor){0xEC, 0xFF, 0xBC, 0xFF}, LEXLIB_NONE); lexlibImagePixelSet(&image, 6, 1, (struct LexlibColor){0xEC, 0xFF, 0xBC, 0xFF}, LEXLIB_NONE); lexlibImagePixelSet(&image, 7, 1, (struct LexlibColor){0xEC, 0xFF, 0xBC, 0xFF}, LEXLIB_NONE); lexlibImagePixelSet(&image, 6, 2, (struct LexlibColor){0xEC, 0xFF, 0xBC, 0xFF}, LEXLIB_NONE); for(int i = 0; i < 5; i++) lexlibImagePixelSet(&image, i+1, 1, (struct LexlibColor){0xEE, 0xB5, 0x70, 0xFF}, LEXLIB_NONE); lexlibImagePixelSet(&image, 2, 2, (struct LexlibColor){0x47, 0x47, 0x51, 0xFF}, LEXLIB_NONE); lexlibImagePixelSet(&image, 4, 2, (struct LexlibColor){0x47, 0x47, 0x51, 0xFF}, LEXLIB_NONE); for(int i = 0; i < 3; i++) lexlibImagePixelSet(&image, i+2, 3, (struct LexlibColor){0x47, 0x47, 0x51, 0xFF}, LEXLIB_NONE); for(int i = 0; i < 3; i++) lexlibImagePixelSet(&image, i+2, 4, (struct LexlibColor){0x47, 0x47, 0x51, 0xFF}, LEXLIB_NONE); lexlibImagePixelSet(&image, 2, 4, (struct LexlibColor){0xE3, 0xE3, 0xF2, 0xFF}, LEXLIB_NONE); lexlibImagePixelSet(&image, 4, 4, (struct LexlibColor){0xE3, 0xE3, 0xF2, 0xFF}, LEXLIB_NONE); lexlibImagePixelSet(&image, 2, 5, (struct LexlibColor){0x47, 0x47, 0x51, 0xFF}, LEXLIB_NONE); lexlibImagePixelSet(&image, 3, 5, (struct LexlibColor){0xE3, 0xE3, 0xF2, 0xFF}, LEXLIB_NONE); lexlibImagePixelSet(&image, 4, 5, (struct LexlibColor){0x47, 0x47, 0x51, 0xFF}, LEXLIB_NONE); for(int i = 0; i < 3; i++) lexlibImagePixelSet(&image, i+2, 6, (struct LexlibColor){0x47, 0x47, 0x51, 0xFF}, LEXLIB_NONE); for(int i = 0; i < 4; i++) lexlibImagePixelSet(&image, i+2, 7, (struct LexlibColor){0x47, 0x47, 0x51, 0xFF}, LEXLIB_NONE); lexlibImagePixelSet(&image, 6, 6, (struct LexlibColor){0x47, 0x47, 0x51, 0xFF}, LEXLIB_NONE); lexlibImagePixelSet(&image, 6, 5, (struct LexlibColor){0x47, 0x47, 0x51, 0xFF}, LEXLIB_NONE); if((err = lexlibImagePixelSet(&image, 7, 4, (struct LexlibColor){0x47, 0x47, 0x51, 0xFF}, LEXLIB_NONE))){ lexlibImageDelete(&image); printf("0x%X, ", err); testEnd("set"); return; } if((err = lexlibImageFlip(&image, LEXLIB_FLIP_X | LEXLIB_FLIP_Y))){ lexlibImageDelete(&image); printf("0x%X, ", err); testEnd("flip"); return; } if((err = lexlibImageSave(&image, "resources/out/image.png"))){ printf("0x%X, ", err); testEnd("save"); } lexlibImageDelete(&image); testEnd(NULL); }