Add test for .ico & .cur loader
|
@ -91,7 +91,7 @@ class CurIcoImage {
|
||||||
|
|
||||||
Header(Stream &stream) { ReadFromStream(stream); }
|
Header(Stream &stream) { ReadFromStream(stream); }
|
||||||
|
|
||||||
bool IsValid() { return reserved == 0 && (type == Type::Icon || type == Type::Cursor) && count > 0; }
|
auto IsValid() { return reserved == 0 && (type == Type::Icon || type == Type::Cursor) && count > 0; }
|
||||||
|
|
||||||
static auto GetStructSize() noexcept { return 6; } // sizeof(Header)
|
static auto GetStructSize() noexcept { return 6; } // sizeof(Header)
|
||||||
|
|
||||||
|
@ -285,7 +285,7 @@ class CurIcoImage {
|
||||||
/// @param fileName The name of the icon file
|
/// @param fileName The name of the icon file
|
||||||
/// @param payloadData A pointer to the PNG payload
|
/// @param payloadData A pointer to the PNG payload
|
||||||
/// @param payloadSize The size of the PNG payload in bytes
|
/// @param payloadSize The size of the PNG payload in bytes
|
||||||
static bool WriteToFile(const char *fileName, const uint8_t *payloadData, uint32_t payloadSize) {
|
static auto WriteToFile(const char *fileName, const uint8_t *payloadData, uint32_t payloadSize) {
|
||||||
if (fileName && fileName[0] && payloadData && payloadSize) {
|
if (fileName && fileName[0] && payloadData && payloadSize) {
|
||||||
auto file = fopen(fileName, "wb");
|
auto file = fopen(fileName, "wb");
|
||||||
|
|
||||||
|
@ -601,9 +601,9 @@ class CurIcoImage {
|
||||||
|
|
||||||
auto src = input.GetData();
|
auto src = input.GetData();
|
||||||
auto dst = *out_data;
|
auto dst = *out_data;
|
||||||
auto pixels = width * height;
|
size_t pixels = width * height;
|
||||||
|
|
||||||
for (auto i = 0; i < pixels; i++) {
|
for (size_t i = 0; i < pixels; i++) {
|
||||||
auto r = *src;
|
auto r = *src;
|
||||||
++src;
|
++src;
|
||||||
auto g = *src;
|
auto g = *src;
|
||||||
|
|
79
tests/compile_tests/image/curico_test.bas
Normal file
|
@ -0,0 +1,79 @@
|
||||||
|
DEFLNG A-Z
|
||||||
|
OPTION _EXPLICIT
|
||||||
|
$CONSOLE:ONLY
|
||||||
|
CHDIR _STARTDIR$
|
||||||
|
|
||||||
|
CONST ICON_DIR = "./icons/"
|
||||||
|
CONST TEST_FILE_FORMAT = "bmp"
|
||||||
|
CONST TOLERANCE_LIMIT = 0
|
||||||
|
|
||||||
|
RESTORE file_list
|
||||||
|
|
||||||
|
DIM fileName AS STRING: READ fileName
|
||||||
|
|
||||||
|
DO
|
||||||
|
DoImageFile ICON_DIR + fileName
|
||||||
|
READ fileName
|
||||||
|
LOOP WHILE LEN(fileName)
|
||||||
|
|
||||||
|
SYSTEM
|
||||||
|
|
||||||
|
file_list:
|
||||||
|
DATA 1bpp.ico
|
||||||
|
DATA 24bpp.ico
|
||||||
|
DATA 4bpp.cur
|
||||||
|
DATA 4bpp.ico
|
||||||
|
DATA 8bpp.ico
|
||||||
|
DATA 8bpp.cur
|
||||||
|
DATA bard.ico
|
||||||
|
DATA broom.ico
|
||||||
|
DATA cat.ico
|
||||||
|
DATA computer.ico
|
||||||
|
DATA dumb1.ico
|
||||||
|
DATA dumb2.ico
|
||||||
|
DATA pencil.ico
|
||||||
|
DATA please_wait.ico
|
||||||
|
DATA question.ico
|
||||||
|
DATA really_huge_duck.ico
|
||||||
|
DATA sample3.ico
|
||||||
|
DATA sample4.ico
|
||||||
|
DATA soft_drink.ico
|
||||||
|
DATA taco.ico
|
||||||
|
DATA terra_globe.ico
|
||||||
|
DATA thumbs_up.ico
|
||||||
|
DATA volme_dialog.ico
|
||||||
|
DATA word-icon.ico
|
||||||
|
DATA x.ico
|
||||||
|
DATA ""
|
||||||
|
|
||||||
|
SUB PrintImageDetails (handle AS LONG, testFileName AS STRING)
|
||||||
|
DIM fullTestFileName AS STRING: fullTestFileName = testFileName + "." + TEST_FILE_FORMAT
|
||||||
|
|
||||||
|
PRINT "Testing against "; fullTestFileName; " ("; _WIDTH(handle); "x"; _HEIGHT(handle); ")."
|
||||||
|
'_SAVEIMAGE fullTestFileName, handle
|
||||||
|
AssertImage2 handle, fullTestFileName, TOLERANCE_LIMIT
|
||||||
|
|
||||||
|
PRINT
|
||||||
|
END SUB
|
||||||
|
|
||||||
|
|
||||||
|
SUB DoImageFile (testFileName AS STRING)
|
||||||
|
DIM fileName AS STRING: fileName = testFileName
|
||||||
|
|
||||||
|
PRINT "Loading image from storage "; fileName; " ... ";
|
||||||
|
|
||||||
|
DIM h AS LONG: h = _LOADIMAGE(fileName, 32)
|
||||||
|
|
||||||
|
IF h < -1 THEN
|
||||||
|
PRINT "done."
|
||||||
|
|
||||||
|
PrintImageDetails h, testFileName
|
||||||
|
|
||||||
|
_FREEIMAGE h
|
||||||
|
ELSE
|
||||||
|
PRINT "failed!"
|
||||||
|
END IF
|
||||||
|
END SUB
|
||||||
|
|
||||||
|
'$INCLUDE:'../utilities/imageassert.bm'
|
||||||
|
'$INCLUDE:'../utilities/base64.bm'
|
100
tests/compile_tests/image/curico_test.output
Normal file
|
@ -0,0 +1,100 @@
|
||||||
|
Loading image from storage ./icons/1bpp.ico ... done.
|
||||||
|
Testing against ./icons/1bpp.ico.bmp ( 128 x 128 ).
|
||||||
|
Success, images are identical!
|
||||||
|
|
||||||
|
Loading image from storage ./icons/24bpp.ico ... done.
|
||||||
|
Testing against ./icons/24bpp.ico.bmp ( 128 x 128 ).
|
||||||
|
Success, images are identical!
|
||||||
|
|
||||||
|
Loading image from storage ./icons/4bpp.cur ... done.
|
||||||
|
Testing against ./icons/4bpp.cur.bmp ( 16 x 16 ).
|
||||||
|
Success, images are identical!
|
||||||
|
|
||||||
|
Loading image from storage ./icons/4bpp.ico ... done.
|
||||||
|
Testing against ./icons/4bpp.ico.bmp ( 128 x 128 ).
|
||||||
|
Success, images are identical!
|
||||||
|
|
||||||
|
Loading image from storage ./icons/8bpp.ico ... done.
|
||||||
|
Testing against ./icons/8bpp.ico.bmp ( 128 x 128 ).
|
||||||
|
Success, images are identical!
|
||||||
|
|
||||||
|
Loading image from storage ./icons/8bpp.cur ... done.
|
||||||
|
Testing against ./icons/8bpp.cur.bmp ( 32 x 32 ).
|
||||||
|
Success, images are identical!
|
||||||
|
|
||||||
|
Loading image from storage ./icons/bard.ico ... done.
|
||||||
|
Testing against ./icons/bard.ico.bmp ( 1360 x 1083 ).
|
||||||
|
Success, images are identical!
|
||||||
|
|
||||||
|
Loading image from storage ./icons/broom.ico ... done.
|
||||||
|
Testing against ./icons/broom.ico.bmp ( 600 x 600 ).
|
||||||
|
Success, images are identical!
|
||||||
|
|
||||||
|
Loading image from storage ./icons/cat.ico ... done.
|
||||||
|
Testing against ./icons/cat.ico.bmp ( 150 x 150 ).
|
||||||
|
Success, images are identical!
|
||||||
|
|
||||||
|
Loading image from storage ./icons/computer.ico ... done.
|
||||||
|
Testing against ./icons/computer.ico.bmp ( 474 x 474 ).
|
||||||
|
Success, images are identical!
|
||||||
|
|
||||||
|
Loading image from storage ./icons/dumb1.ico ... done.
|
||||||
|
Testing against ./icons/dumb1.ico.bmp ( 540 x 500 ).
|
||||||
|
Success, images are identical!
|
||||||
|
|
||||||
|
Loading image from storage ./icons/dumb2.ico ... done.
|
||||||
|
Testing against ./icons/dumb2.ico.bmp ( 540 x 500 ).
|
||||||
|
Success, images are identical!
|
||||||
|
|
||||||
|
Loading image from storage ./icons/pencil.ico ... done.
|
||||||
|
Testing against ./icons/pencil.ico.bmp ( 256 x 256 ).
|
||||||
|
Success, images are identical!
|
||||||
|
|
||||||
|
Loading image from storage ./icons/please_wait.ico ... done.
|
||||||
|
Testing against ./icons/please_wait.ico.bmp ( 404 x 325 ).
|
||||||
|
Success, images are identical!
|
||||||
|
|
||||||
|
Loading image from storage ./icons/question.ico ... done.
|
||||||
|
Testing against ./icons/question.ico.bmp ( 512 x 512 ).
|
||||||
|
Success, images are identical!
|
||||||
|
|
||||||
|
Loading image from storage ./icons/really_huge_duck.ico ... done.
|
||||||
|
Testing against ./icons/really_huge_duck.ico.bmp ( 4293 x 4293 ).
|
||||||
|
Success, images are identical!
|
||||||
|
|
||||||
|
Loading image from storage ./icons/sample3.ico ... done.
|
||||||
|
Testing against ./icons/sample3.ico.bmp ( 256 x 171 ).
|
||||||
|
Success, images are identical!
|
||||||
|
|
||||||
|
Loading image from storage ./icons/sample4.ico ... done.
|
||||||
|
Testing against ./icons/sample4.ico.bmp ( 256 x 192 ).
|
||||||
|
Success, images are identical!
|
||||||
|
|
||||||
|
Loading image from storage ./icons/soft_drink.ico ... done.
|
||||||
|
Testing against ./icons/soft_drink.ico.bmp ( 256 x 256 ).
|
||||||
|
Success, images are identical!
|
||||||
|
|
||||||
|
Loading image from storage ./icons/taco.ico ... done.
|
||||||
|
Testing against ./icons/taco.ico.bmp ( 966 x 764 ).
|
||||||
|
Success, images are identical!
|
||||||
|
|
||||||
|
Loading image from storage ./icons/terra_globe.ico ... done.
|
||||||
|
Testing against ./icons/terra_globe.ico.bmp ( 772 x 769 ).
|
||||||
|
Success, images are identical!
|
||||||
|
|
||||||
|
Loading image from storage ./icons/thumbs_up.ico ... done.
|
||||||
|
Testing against ./icons/thumbs_up.ico.bmp ( 463 x 294 ).
|
||||||
|
Success, images are identical!
|
||||||
|
|
||||||
|
Loading image from storage ./icons/volme_dialog.ico ... done.
|
||||||
|
Testing against ./icons/volme_dialog.ico.bmp ( 32 x 32 ).
|
||||||
|
Success, images are identical!
|
||||||
|
|
||||||
|
Loading image from storage ./icons/word-icon.ico ... done.
|
||||||
|
Testing against ./icons/word-icon.ico.bmp ( 512 x 512 ).
|
||||||
|
Success, images are identical!
|
||||||
|
|
||||||
|
Loading image from storage ./icons/x.ico ... done.
|
||||||
|
Testing against ./icons/x.ico.bmp ( 256 x 256 ).
|
||||||
|
Success, images are identical!
|
||||||
|
|
BIN
tests/compile_tests/image/icons/1bpp.ico
Normal file
After Width: | Height: | Size: 3.4 KiB |
BIN
tests/compile_tests/image/icons/1bpp.ico.bmp
Normal file
After Width: | Height: | Size: 64 KiB |
BIN
tests/compile_tests/image/icons/24bpp.ico
Normal file
After Width: | Height: | Size: 50 KiB |
BIN
tests/compile_tests/image/icons/24bpp.ico.bmp
Normal file
After Width: | Height: | Size: 64 KiB |
BIN
tests/compile_tests/image/icons/4bpp.cur
Normal file
After Width: | Height: | Size: 318 B |
BIN
tests/compile_tests/image/icons/4bpp.cur.bmp
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
tests/compile_tests/image/icons/4bpp.ico
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
tests/compile_tests/image/icons/4bpp.ico.bmp
Normal file
After Width: | Height: | Size: 64 KiB |
BIN
tests/compile_tests/image/icons/8bpp.cur
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
tests/compile_tests/image/icons/8bpp.cur.bmp
Normal file
After Width: | Height: | Size: 4.1 KiB |
BIN
tests/compile_tests/image/icons/8bpp.ico
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
tests/compile_tests/image/icons/8bpp.ico.bmp
Normal file
After Width: | Height: | Size: 64 KiB |
BIN
tests/compile_tests/image/icons/bard.ico
Normal file
After Width: | Height: | Size: 1.6 MiB |
BIN
tests/compile_tests/image/icons/bard.ico.bmp
Normal file
After Width: | Height: | Size: 5.6 MiB |
BIN
tests/compile_tests/image/icons/broom.ico
Normal file
After Width: | Height: | Size: 1.1 MiB |
BIN
tests/compile_tests/image/icons/broom.ico.bmp
Normal file
After Width: | Height: | Size: 1.4 MiB |
BIN
tests/compile_tests/image/icons/cat.ico
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
tests/compile_tests/image/icons/cat.ico.bmp
Normal file
After Width: | Height: | Size: 88 KiB |
BIN
tests/compile_tests/image/icons/computer.ico
Normal file
After Width: | Height: | Size: 687 KiB |
BIN
tests/compile_tests/image/icons/computer.ico.bmp
Normal file
After Width: | Height: | Size: 878 KiB |
BIN
tests/compile_tests/image/icons/dumb1.ico
Normal file
After Width: | Height: | Size: 298 KiB |
BIN
tests/compile_tests/image/icons/dumb1.ico.bmp
Normal file
After Width: | Height: | Size: 1 MiB |
BIN
tests/compile_tests/image/icons/dumb2.ico
Normal file
After Width: | Height: | Size: 824 KiB |
BIN
tests/compile_tests/image/icons/dumb2.ico.bmp
Normal file
After Width: | Height: | Size: 1 MiB |
BIN
tests/compile_tests/image/icons/pencil.ico
Normal file
After Width: | Height: | Size: 200 KiB |
BIN
tests/compile_tests/image/icons/pencil.ico.bmp
Normal file
After Width: | Height: | Size: 256 KiB |
BIN
tests/compile_tests/image/icons/please_wait.ico
Normal file
After Width: | Height: | Size: 146 KiB |
BIN
tests/compile_tests/image/icons/please_wait.ico.bmp
Normal file
After Width: | Height: | Size: 513 KiB |
BIN
tests/compile_tests/image/icons/question.ico
Normal file
After Width: | Height: | Size: 800 KiB |
BIN
tests/compile_tests/image/icons/question.ico.bmp
Normal file
After Width: | Height: | Size: 1 MiB |
BIN
tests/compile_tests/image/icons/really_huge_duck.ico
Normal file
After Width: | Height: | Size: 55 MiB |
BIN
tests/compile_tests/image/icons/really_huge_duck.ico.bmp
Normal file
After Width: | Height: | Size: 70 MiB |
BIN
tests/compile_tests/image/icons/sample3.ico
Normal file
After Width: | Height: | Size: 176 KiB |
BIN
tests/compile_tests/image/icons/sample3.ico.bmp
Normal file
After Width: | Height: | Size: 171 KiB |
BIN
tests/compile_tests/image/icons/sample4.ico
Normal file
After Width: | Height: | Size: 198 KiB |
BIN
tests/compile_tests/image/icons/sample4.ico.bmp
Normal file
After Width: | Height: | Size: 192 KiB |
BIN
tests/compile_tests/image/icons/soft_drink.ico
Normal file
After Width: | Height: | Size: 200 KiB |
BIN
tests/compile_tests/image/icons/soft_drink.ico.bmp
Normal file
After Width: | Height: | Size: 256 KiB |
BIN
tests/compile_tests/image/icons/taco.ico
Normal file
After Width: | Height: | Size: 2.2 MiB |
BIN
tests/compile_tests/image/icons/taco.ico.bmp
Normal file
After Width: | Height: | Size: 2.8 MiB |
BIN
tests/compile_tests/image/icons/terra_globe.ico
Normal file
After Width: | Height: | Size: 1.8 MiB |
BIN
tests/compile_tests/image/icons/terra_globe.ico.bmp
Normal file
After Width: | Height: | Size: 2.3 MiB |
BIN
tests/compile_tests/image/icons/thumbs_up.ico
Normal file
After Width: | Height: | Size: 417 KiB |
BIN
tests/compile_tests/image/icons/thumbs_up.ico.bmp
Normal file
After Width: | Height: | Size: 532 KiB |
BIN
tests/compile_tests/image/icons/volme_dialog.ico
Normal file
After Width: | Height: | Size: 766 B |
BIN
tests/compile_tests/image/icons/volme_dialog.ico.bmp
Normal file
After Width: | Height: | Size: 4.1 KiB |
BIN
tests/compile_tests/image/icons/word-icon.ico
Normal file
After Width: | Height: | Size: 800 KiB |
BIN
tests/compile_tests/image/icons/word-icon.ico.bmp
Normal file
After Width: | Height: | Size: 1 MiB |
BIN
tests/compile_tests/image/icons/x.ico
Normal file
After Width: | Height: | Size: 200 KiB |
BIN
tests/compile_tests/image/icons/x.ico.bmp
Normal file
After Width: | Height: | Size: 256 KiB |
|
@ -118,7 +118,7 @@ END SUB
|
||||||
|
|
||||||
|
|
||||||
FUNCTION GetColorDelta~& (color1 AS _UNSIGNED LONG, color2 AS _UNSIGNED LONG)
|
FUNCTION GetColorDelta~& (color1 AS _UNSIGNED LONG, color2 AS _UNSIGNED LONG)
|
||||||
GetColorDelta = ABS(_RED32(color1) - _RED32(color2)) + ABS(_GREEN32(color1) - _GREEN32(color2)) + ABS(_BLUE32(color1) - _BLUE32(color2)) + ABS(_ALPHA32(color1) - _ALPHA32(color2))
|
GetColorDelta = ABS(_RED32(color1) - _RED32(color2)) + ABS(_GREEN32(color1) - _GREEN32(color2)) + ABS(_BLUE32(color1) - _BLUE32(color2))
|
||||||
END FUNCTION
|
END FUNCTION
|
||||||
|
|
||||||
|
|
||||||
|
@ -178,7 +178,7 @@ SUB AssertImage2 (originalActualImage AS LONG, expectedFileName AS STRING, toler
|
||||||
actualPixel = _MEMGET(actual, actual.OFFSET + pixelOffset, _UNSIGNED LONG)
|
actualPixel = _MEMGET(actual, actual.OFFSET + pixelOffset, _UNSIGNED LONG)
|
||||||
expectedPixel = _MEMGET(expected, expected.OFFSET + pixelOffset, _UNSIGNED LONG)
|
expectedPixel = _MEMGET(expected, expected.OFFSET + pixelOffset, _UNSIGNED LONG)
|
||||||
|
|
||||||
IF actualPixel <> expectedPixel _ANDALSO GetColorDelta(actualPixel, expectedPixel) > toleranceLimit THEN
|
IF actualPixel <> expectedPixel _ANDALSO _ALPHA32(actualPixel) <> 0 _ANDALSO _ALPHA32(expectedPixel) <> 0 _ANDALSO GetColorDelta(actualPixel, expectedPixel) > toleranceLimit THEN
|
||||||
PRINT "Failure! Image pixels at ("; x&; ","; y&; ") differ, actual: 0x"; HEX$(actualPixel); ", expected: 0x"; HEX$(expectedPixel)
|
PRINT "Failure! Image pixels at ("; x&; ","; y&; ") differ, actual: 0x"; HEX$(actualPixel); ", expected: 0x"; HEX$(expectedPixel)
|
||||||
GOTO freeImages
|
GOTO freeImages
|
||||||
END IF
|
END IF
|
||||||
|
|