Merge branch 'master' into working
This commit is contained in:
@ -39,9 +39,10 @@ RSC=rc.exe
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /W3 /GX /O2 /I ".." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c
|
||||
# ADD CPP /nologo /W3 /GX /Zi /O2 /I ".." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
@ -50,7 +51,7 @@ BSC32=bscmake.exe
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386
|
||||
|
||||
!ELSEIF "$(CFG)" == "image_test - Win32 Debug"
|
||||
|
||||
|
@ -15,11 +15,15 @@ find $SRC/stb/tests/pngsuite -name "*.png" | \
|
||||
|
||||
cp $SRC/stb/tests/stb_png.dict $OUT/stb_png_read_fuzzer.dict
|
||||
|
||||
tar xvzf $SRC/stb/jpg.tar.gz --directory $SRC/stb/tests
|
||||
tar xvzf $SRC/stb/gif.tar.gz --directory $SRC/stb/tests
|
||||
tar xvzf $SRC/stbi/jpg.tar.gz --directory $SRC/stb/tests
|
||||
tar xvzf $SRC/stbi/gif.tar.gz --directory $SRC/stb/tests
|
||||
unzip $SRC/stbi/bmp.zip -d $SRC/stb/tests
|
||||
unzip $SRC/stbi/tga.zip -d $SRC/stb/tests
|
||||
|
||||
find $SRC/stb/tests -name "*.png" -o -name "*.jpg" -o -name ".gif" | \
|
||||
xargs zip $OUT/stbi_read_fuzzer_seed_corpus.zip
|
||||
find $SRC/stb/tests -name "*.png" -o -name "*.jpg" -o -name "*.gif" \
|
||||
-o -name "*.bmp" -o -name "*.tga" -o -name "*.TGA" \
|
||||
-o -name "*.ppm" -o -name "*.pgm" \
|
||||
| xargs zip $OUT/stbi_read_fuzzer_seed_corpus.zip
|
||||
|
||||
echo "" >> $SRC/stb/tests/gif.dict
|
||||
cat $SRC/stb/tests/gif.dict $SRC/stb/tests/stb_png.dict > $OUT/stbi_read_fuzzer.dict
|
||||
echo "" >> $SRC/stbi/gif.dict
|
||||
cat $SRC/stbi/gif.dict $SRC/stb/tests/stb_png.dict > $OUT/stbi_read_fuzzer.dict
|
||||
|
BIN
tests/pbm/basi0g16.pgm
Normal file
BIN
tests/pbm/basi0g16.pgm
Normal file
Binary file not shown.
BIN
tests/pbm/basi2c16.ppm
Normal file
BIN
tests/pbm/basi2c16.ppm
Normal file
Binary file not shown.
BIN
tests/pbm/cdfn2c08.ppm
Normal file
BIN
tests/pbm/cdfn2c08.ppm
Normal file
Binary file not shown.
BIN
tests/pbm/cdun2c08.ppm
Normal file
BIN
tests/pbm/cdun2c08.ppm
Normal file
Binary file not shown.
BIN
tests/pbm/comment.pgm
Normal file
BIN
tests/pbm/comment.pgm
Normal file
Binary file not shown.
BIN
tests/pbm/ctfn0g04.pgm
Normal file
BIN
tests/pbm/ctfn0g04.pgm
Normal file
Binary file not shown.
259
tests/pngsuite/ref_results.csv
Normal file
259
tests/pngsuite/ref_results.csv
Normal file
@ -0,0 +1,259 @@
|
||||
filename,width,height,ncomp,error,hash
|
||||
pngsuite/16bit/basi0g16.png,32,32,1,,0xfc8f2f99
|
||||
pngsuite/16bit/basi2c16.png,32,32,3,,0x65567ed5
|
||||
pngsuite/16bit/basi4a16.png,32,32,2,,0x198cf245
|
||||
pngsuite/16bit/basi6a16.png,32,32,4,,0x3016e9b5
|
||||
pngsuite/16bit/basn0g16.png,32,32,1,,0xfc8f2f99
|
||||
pngsuite/16bit/basn2c16.png,32,32,3,,0x65567ed5
|
||||
pngsuite/16bit/basn4a16.png,32,32,2,,0x198cf245
|
||||
pngsuite/16bit/basn6a16.png,32,32,4,,0x3016e9b5
|
||||
pngsuite/16bit/bgai4a16.png,32,32,2,,0x198cf245
|
||||
pngsuite/16bit/bgan6a16.png,32,32,4,,0x3016e9b5
|
||||
pngsuite/16bit/bggn4a16.png,32,32,2,,0x198cf245
|
||||
pngsuite/16bit/bgyn6a16.png,32,32,4,,0x3016e9b5
|
||||
pngsuite/16bit/oi1n0g16.png,32,32,1,,0xfc8f2f99
|
||||
pngsuite/16bit/oi1n2c16.png,32,32,3,,0x65567ed5
|
||||
pngsuite/16bit/oi2n0g16.png,32,32,1,,0xfc8f2f99
|
||||
pngsuite/16bit/oi2n2c16.png,32,32,3,,0x65567ed5
|
||||
pngsuite/16bit/oi4n0g16.png,32,32,1,,0xfc8f2f99
|
||||
pngsuite/16bit/oi4n2c16.png,32,32,3,,0x65567ed5
|
||||
pngsuite/16bit/oi9n0g16.png,32,32,1,,0xfc8f2f99
|
||||
pngsuite/16bit/oi9n2c16.png,32,32,3,,0x65567ed5
|
||||
pngsuite/16bit/tbbn2c16.png,32,32,4,,0xaa9bfe44
|
||||
pngsuite/16bit/tbgn2c16.png,32,32,4,,0xaa9bfe44
|
||||
pngsuite/16bit/tbwn0g16.png,32,32,2,,0x075e519a
|
||||
pngsuite/corrupt/xc1n0g08.png,32,32,2,bad ctype,0x00000000
|
||||
pngsuite/corrupt/xc9n2c08.png,32,32,2,bad ctype,0x00000000
|
||||
pngsuite/corrupt/xcrn0g04.png,32,32,2,unknown image type,0x00000000
|
||||
pngsuite/corrupt/xcsn0g01.png,32,32,1,,0x43b9891f
|
||||
pngsuite/corrupt/xd0n2c08.png,32,32,1,1/2/4/8/16-bit only,0x00000000
|
||||
pngsuite/corrupt/xd3n2c08.png,32,32,1,1/2/4/8/16-bit only,0x00000000
|
||||
pngsuite/corrupt/xd9n2c08.png,32,32,1,1/2/4/8/16-bit only,0x00000000
|
||||
pngsuite/corrupt/xdtn0g01.png,32,32,1,no IDAT,0x00000000
|
||||
pngsuite/corrupt/xhdn0g08.png,32,32,1,,0x414f1ca9
|
||||
pngsuite/corrupt/xlfn0g04.png,32,32,1,unknown image type,0x00000000
|
||||
pngsuite/corrupt/xs1n0g01.png,32,32,1,unknown image type,0x00000000
|
||||
pngsuite/corrupt/xs2n0g01.png,32,32,1,unknown image type,0x00000000
|
||||
pngsuite/corrupt/xs4n0g01.png,32,32,1,unknown image type,0x00000000
|
||||
pngsuite/corrupt/xs7n0g01.png,32,32,1,unknown image type,0x00000000
|
||||
pngsuite/iphone/iphone_basi0g01.png,32,32,4,,0x5fb33cfd
|
||||
pngsuite/iphone/iphone_basi0g02.png,32,32,4,,0x5bbe95c5
|
||||
pngsuite/iphone/iphone_basi3p02.png,32,32,4,,0x50ba29c5
|
||||
pngsuite/iphone/iphone_bgwn6a08.png,32,32,4,,0x45d8548a
|
||||
pngsuite/iphone/iphone_bgyn6a16.png,32,32,4,,0x4b2b7545
|
||||
pngsuite/iphone/iphone_tbyn3p08.png,32,32,4,,0x8ea9aaaf
|
||||
pngsuite/iphone/iphone_z06n2c08.png,32,32,4,,0xb5dd034b
|
||||
pngsuite/primary/basi0g01.png,32,32,1,,0x43b9891f
|
||||
pngsuite/primary/basi0g02.png,32,32,1,,0xaf0bb3c5
|
||||
pngsuite/primary/basi0g04.png,32,32,1,,0x6fbaeb45
|
||||
pngsuite/primary/basi0g08.png,32,32,1,,0x414f1ca9
|
||||
pngsuite/primary/basi2c08.png,32,32,3,,0x522345c5
|
||||
pngsuite/primary/basi3p01.png,32,32,3,,0x9c5b75c5
|
||||
pngsuite/primary/basi3p02.png,32,32,3,,0x46f26ec5
|
||||
pngsuite/primary/basi3p04.png,32,32,3,,0x35b2e4a5
|
||||
pngsuite/primary/basi3p08.png,32,32,3,,0xfe066865
|
||||
pngsuite/primary/basi4a08.png,32,32,2,,0x77cbbfa5
|
||||
pngsuite/primary/basi6a08.png,32,32,4,,0xb472197d
|
||||
pngsuite/primary/basn0g01.png,32,32,1,,0x43b9891f
|
||||
pngsuite/primary/basn0g02.png,32,32,1,,0xaf0bb3c5
|
||||
pngsuite/primary/basn0g04.png,32,32,1,,0x6fbaeb45
|
||||
pngsuite/primary/basn0g08.png,32,32,1,,0x414f1ca9
|
||||
pngsuite/primary/basn2c08.png,32,32,3,,0x522345c5
|
||||
pngsuite/primary/basn3p01.png,32,32,3,,0x9c5b75c5
|
||||
pngsuite/primary/basn3p02.png,32,32,3,,0x46f26ec5
|
||||
pngsuite/primary/basn3p04.png,32,32,3,,0x35b2e4a5
|
||||
pngsuite/primary/basn3p08.png,32,32,3,,0xfe066865
|
||||
pngsuite/primary/basn4a08.png,32,32,2,,0x77cbbfa5
|
||||
pngsuite/primary/basn6a08.png,32,32,4,,0xb472197d
|
||||
pngsuite/primary/bgai4a08.png,32,32,2,,0x77cbbfa5
|
||||
pngsuite/primary/bgan6a08.png,32,32,4,,0xb472197d
|
||||
pngsuite/primary/bgbn4a08.png,32,32,2,,0x77cbbfa5
|
||||
pngsuite/primary/bgwn6a08.png,32,32,4,,0xb472197d
|
||||
pngsuite/primary/s01i3p01.png,1,1,3,,0xafb003b6
|
||||
pngsuite/primary/s01n3p01.png,1,1,3,,0xafb003b6
|
||||
pngsuite/primary/s02i3p01.png,2,2,3,,0x96f3dd85
|
||||
pngsuite/primary/s02n3p01.png,2,2,3,,0x96f3dd85
|
||||
pngsuite/primary/s03i3p01.png,3,3,3,,0xb0cf1241
|
||||
pngsuite/primary/s03n3p01.png,3,3,3,,0xb0cf1241
|
||||
pngsuite/primary/s04i3p01.png,4,4,3,,0xbfcedd75
|
||||
pngsuite/primary/s04n3p01.png,4,4,3,,0xbfcedd75
|
||||
pngsuite/primary/s05i3p02.png,5,5,3,,0xc322cedd
|
||||
pngsuite/primary/s05n3p02.png,5,5,3,,0xc322cedd
|
||||
pngsuite/primary/s06i3p02.png,6,6,3,,0x46916799
|
||||
pngsuite/primary/s06n3p02.png,6,6,3,,0x46916799
|
||||
pngsuite/primary/s07i3p02.png,7,7,3,,0xfdabc297
|
||||
pngsuite/primary/s07n3p02.png,7,7,3,,0xfdabc297
|
||||
pngsuite/primary/s08i3p02.png,8,8,3,,0x8f036d09
|
||||
pngsuite/primary/s08n3p02.png,8,8,3,,0x8f036d09
|
||||
pngsuite/primary/s09i3p02.png,9,9,3,,0x16a46830
|
||||
pngsuite/primary/s09n3p02.png,9,9,3,,0x16a46830
|
||||
pngsuite/primary/s32i3p04.png,32,32,3,,0x4bd4fbd3
|
||||
pngsuite/primary/s32n3p04.png,32,32,3,,0x4bd4fbd3
|
||||
pngsuite/primary/s33i3p04.png,33,33,3,,0x51aa005e
|
||||
pngsuite/primary/s33n3p04.png,33,33,3,,0x51aa005e
|
||||
pngsuite/primary/s34i3p04.png,34,34,3,,0x84818775
|
||||
pngsuite/primary/s34n3p04.png,34,34,3,,0x84818775
|
||||
pngsuite/primary/s35i3p04.png,35,35,3,,0x6359ec75
|
||||
pngsuite/primary/s35n3p04.png,35,35,3,,0x6359ec75
|
||||
pngsuite/primary/s36i3p04.png,36,36,3,,0xe4878065
|
||||
pngsuite/primary/s36n3p04.png,36,36,3,,0xe4878065
|
||||
pngsuite/primary/s37i3p04.png,37,37,3,,0x3cefc423
|
||||
pngsuite/primary/s37n3p04.png,37,37,3,,0x3cefc423
|
||||
pngsuite/primary/s38i3p04.png,38,38,3,,0xffc55a2b
|
||||
pngsuite/primary/s38n3p04.png,38,38,3,,0xffc55a2b
|
||||
pngsuite/primary/s39i3p04.png,39,39,3,,0x0c790240
|
||||
pngsuite/primary/s39n3p04.png,39,39,3,,0x0c790240
|
||||
pngsuite/primary/s40i3p04.png,40,40,3,,0x951a316d
|
||||
pngsuite/primary/s40n3p04.png,40,40,3,,0x951a316d
|
||||
pngsuite/primary/tbbn0g04.png,32,32,2,,0x9c8410ea
|
||||
pngsuite/primary/tbbn3p08.png,32,32,4,,0x82bf9a57
|
||||
pngsuite/primary/tbgn3p08.png,32,32,4,,0x82bf9a57
|
||||
pngsuite/primary/tbrn2c08.png,32,32,4,,0xaa9bfe44
|
||||
pngsuite/primary/tbwn3p08.png,32,32,4,,0x82bf9a57
|
||||
pngsuite/primary/tbyn3p08.png,32,32,4,,0x82bf9a57
|
||||
pngsuite/primary/tm3n3p02.png,32,32,4,,0xf59745c5
|
||||
pngsuite/primary/tp0n0g08.png,32,32,1,,0xbac0864c
|
||||
pngsuite/primary/tp0n2c08.png,32,32,3,,0x82687c37
|
||||
pngsuite/primary/tp0n3p08.png,32,32,3,,0x61f54e37
|
||||
pngsuite/primary/tp1n3p08.png,32,32,4,,0x82bf9a57
|
||||
pngsuite/primary/z00n2c08.png,32,32,3,,0x65b4a72f
|
||||
pngsuite/primary/z03n2c08.png,32,32,3,,0x65b4a72f
|
||||
pngsuite/primary/z06n2c08.png,32,32,3,,0x65b4a72f
|
||||
pngsuite/primary/z09n2c08.png,32,32,3,,0x65b4a72f
|
||||
pngsuite/primary_check/basi0g01.png,32,32,4,,0x5fb33cfd
|
||||
pngsuite/primary_check/basi0g02.png,32,32,4,,0x5bbe95c5
|
||||
pngsuite/primary_check/basi0g04.png,32,32,4,,0x3468b9c5
|
||||
pngsuite/primary_check/basi0g08.png,32,32,4,,0x262ef46d
|
||||
pngsuite/primary_check/basi2c08.png,32,32,4,,0x1fc92bc5
|
||||
pngsuite/primary_check/basi3p01.png,32,32,4,,0x28a3e1c5
|
||||
pngsuite/primary_check/basi3p02.png,32,32,4,,0x803be5c5
|
||||
pngsuite/primary_check/basi3p04.png,32,32,4,,0xf3fc60e5
|
||||
pngsuite/primary_check/basi3p08.png,32,32,4,,0x30ef4f45
|
||||
pngsuite/primary_check/basi4a08.png,32,32,4,,0x23c8536d
|
||||
pngsuite/primary_check/basi6a08.png,32,32,4,,0xb472197d
|
||||
pngsuite/primary_check/basn0g01.png,32,32,4,,0x5fb33cfd
|
||||
pngsuite/primary_check/basn0g02.png,32,32,4,,0x5bbe95c5
|
||||
pngsuite/primary_check/basn0g04.png,32,32,4,,0x3468b9c5
|
||||
pngsuite/primary_check/basn0g08.png,32,32,4,,0x262ef46d
|
||||
pngsuite/primary_check/basn2c08.png,32,32,4,,0x1fc92bc5
|
||||
pngsuite/primary_check/basn3p01.png,32,32,4,,0x28a3e1c5
|
||||
pngsuite/primary_check/basn3p02.png,32,32,4,,0x803be5c5
|
||||
pngsuite/primary_check/basn3p04.png,32,32,4,,0xf3fc60e5
|
||||
pngsuite/primary_check/basn3p08.png,32,32,4,,0x30ef4f45
|
||||
pngsuite/primary_check/basn4a08.png,32,32,4,,0x23c8536d
|
||||
pngsuite/primary_check/basn6a08.png,32,32,4,,0xb472197d
|
||||
pngsuite/primary_check/bgai4a08.png,32,32,4,,0x23c8536d
|
||||
pngsuite/primary_check/bgan6a08.png,32,32,4,,0xb472197d
|
||||
pngsuite/primary_check/bgbn4a08.png,32,32,4,,0x23c8536d
|
||||
pngsuite/primary_check/bgwn6a08.png,32,32,4,,0xb472197d
|
||||
pngsuite/primary_check/s01i3p01.png,1,1,4,,0xdb152beb
|
||||
pngsuite/primary_check/s01n3p01.png,1,1,4,,0xdb152beb
|
||||
pngsuite/primary_check/s02i3p01.png,2,2,4,,0xa344a3a5
|
||||
pngsuite/primary_check/s02n3p01.png,2,2,4,,0xa344a3a5
|
||||
pngsuite/primary_check/s03i3p01.png,3,3,4,,0x594d3bfa
|
||||
pngsuite/primary_check/s03n3p01.png,3,3,4,,0x594d3bfa
|
||||
pngsuite/primary_check/s04i3p01.png,4,4,4,,0xd59d4605
|
||||
pngsuite/primary_check/s04n3p01.png,4,4,4,,0xd59d4605
|
||||
pngsuite/primary_check/s05i3p02.png,5,5,4,,0x41e58366
|
||||
pngsuite/primary_check/s05n3p02.png,5,5,4,,0x41e58366
|
||||
pngsuite/primary_check/s06i3p02.png,6,6,4,,0xcad1a885
|
||||
pngsuite/primary_check/s06n3p02.png,6,6,4,,0xcad1a885
|
||||
pngsuite/primary_check/s07i3p02.png,7,7,4,,0x09184108
|
||||
pngsuite/primary_check/s07n3p02.png,7,7,4,,0x09184108
|
||||
pngsuite/primary_check/s08i3p02.png,8,8,4,,0x4fd11cad
|
||||
pngsuite/primary_check/s08n3p02.png,8,8,4,,0x4fd11cad
|
||||
pngsuite/primary_check/s09i3p02.png,9,9,4,,0xc50dbecd
|
||||
pngsuite/primary_check/s09n3p02.png,9,9,4,,0xc50dbecd
|
||||
pngsuite/primary_check/s32i3p04.png,32,32,4,,0x95cbb1d3
|
||||
pngsuite/primary_check/s32n3p04.png,32,32,4,,0x95cbb1d3
|
||||
pngsuite/primary_check/s33i3p04.png,33,33,4,,0x6649fc5b
|
||||
pngsuite/primary_check/s33n3p04.png,33,33,4,,0x6649fc5b
|
||||
pngsuite/primary_check/s34i3p04.png,34,34,4,,0x35b98e15
|
||||
pngsuite/primary_check/s34n3p04.png,34,34,4,,0x35b98e15
|
||||
pngsuite/primary_check/s35i3p04.png,35,35,4,,0xc9ddf938
|
||||
pngsuite/primary_check/s35n3p04.png,35,35,4,,0xc9ddf938
|
||||
pngsuite/primary_check/s36i3p04.png,36,36,4,,0x7bb4e1cd
|
||||
pngsuite/primary_check/s36n3p04.png,36,36,4,,0x7bb4e1cd
|
||||
pngsuite/primary_check/s37i3p04.png,37,37,4,,0xee50001c
|
||||
pngsuite/primary_check/s37n3p04.png,37,37,4,,0xee50001c
|
||||
pngsuite/primary_check/s38i3p04.png,38,38,4,,0x51b76813
|
||||
pngsuite/primary_check/s38n3p04.png,38,38,4,,0x51b76813
|
||||
pngsuite/primary_check/s39i3p04.png,39,39,4,,0x42f23327
|
||||
pngsuite/primary_check/s39n3p04.png,39,39,4,,0x42f23327
|
||||
pngsuite/primary_check/s40i3p04.png,40,40,4,,0xf91b6a7d
|
||||
pngsuite/primary_check/s40n3p04.png,40,40,4,,0xf91b6a7d
|
||||
pngsuite/primary_check/tbbn0g04.png,32,32,4,,0x8a0117a4
|
||||
pngsuite/primary_check/tbbn3p08.png,32,32,4,,0x82bf9a57
|
||||
pngsuite/primary_check/tbgn3p08.png,32,32,4,,0x82bf9a57
|
||||
pngsuite/primary_check/tbrn2c08.png,32,32,4,,0xaa9bfe44
|
||||
pngsuite/primary_check/tbwn3p08.png,32,32,4,,0x82bf9a57
|
||||
pngsuite/primary_check/tbyn3p08.png,32,32,4,,0x82bf9a57
|
||||
pngsuite/primary_check/tm3n3p02.png,32,32,4,,0xf59745c5
|
||||
pngsuite/primary_check/tp0n0g08.png,32,32,4,,0xd405ad2e
|
||||
pngsuite/primary_check/tp0n2c08.png,32,32,4,,0x5a66ca09
|
||||
pngsuite/primary_check/tp0n3p08.png,32,32,4,,0x06e81adf
|
||||
pngsuite/primary_check/tp1n3p08.png,32,32,4,,0x82bf9a57
|
||||
pngsuite/primary_check/z00n2c08.png,32,32,4,,0xaa698493
|
||||
pngsuite/primary_check/z03n2c08.png,32,32,4,,0xaa698493
|
||||
pngsuite/primary_check/z06n2c08.png,32,32,4,,0xaa698493
|
||||
pngsuite/primary_check/z09n2c08.png,32,32,4,,0xaa698493
|
||||
pngsuite/unused/ccwn2c08.png,32,32,3,,0xbb576418
|
||||
pngsuite/unused/ccwn3p08.png,32,32,3,,0x5c4df060
|
||||
pngsuite/unused/cdfn2c08.png,8,32,3,,0xe30ed48f
|
||||
pngsuite/unused/cdhn2c08.png,32,8,3,,0x999321f5
|
||||
pngsuite/unused/cdsn2c08.png,8,8,3,,0x7f63fa01
|
||||
pngsuite/unused/cdun2c08.png,32,32,3,,0xbd325d71
|
||||
pngsuite/unused/ch1n3p04.png,32,32,3,,0x35b2e4a5
|
||||
pngsuite/unused/ch2n3p08.png,32,32,3,,0xfe066865
|
||||
pngsuite/unused/cm0n0g04.png,32,32,1,,0xe9f53e6c
|
||||
pngsuite/unused/cm7n0g04.png,32,32,1,,0xe9f53e6c
|
||||
pngsuite/unused/cm9n0g04.png,32,32,1,,0xe9f53e6c
|
||||
pngsuite/unused/cs3n2c16.png,32,32,3,,0x7f0fa2c5
|
||||
pngsuite/unused/cs3n3p08.png,32,32,3,,0x5533bac5
|
||||
pngsuite/unused/cs5n2c08.png,32,32,3,,0x8a80f8c5
|
||||
pngsuite/unused/cs5n3p08.png,32,32,3,,0x8a80f8c5
|
||||
pngsuite/unused/cs8n2c08.png,32,32,3,,0x7f0fa2c5
|
||||
pngsuite/unused/cs8n3p08.png,32,32,3,,0x7f0fa2c5
|
||||
pngsuite/unused/ct0n0g04.png,32,32,1,,0xe9f53e6c
|
||||
pngsuite/unused/ct1n0g04.png,32,32,1,,0xe9f53e6c
|
||||
pngsuite/unused/cten0g04.png,32,32,1,,0x1c073b45
|
||||
pngsuite/unused/ctfn0g04.png,32,32,1,,0xfa9fd205
|
||||
pngsuite/unused/ctgn0g04.png,32,32,1,,0xf28c8085
|
||||
pngsuite/unused/cthn0g04.png,32,32,1,,0x7c039595
|
||||
pngsuite/unused/ctjn0g04.png,32,32,1,,0xc520f455
|
||||
pngsuite/unused/ctzn0g04.png,32,32,1,,0xe9f53e6c
|
||||
pngsuite/unused/f00n0g08.png,32,32,1,,0x21db411b
|
||||
pngsuite/unused/f00n2c08.png,32,32,3,,0x1f25ded0
|
||||
pngsuite/unused/f01n0g08.png,32,32,1,,0x7437b32a
|
||||
pngsuite/unused/f01n2c08.png,32,32,3,,0x0d4507ae
|
||||
pngsuite/unused/f02n0g08.png,32,32,1,,0x6b633c7c
|
||||
pngsuite/unused/f02n2c08.png,32,32,3,,0x4b278986
|
||||
pngsuite/unused/f03n0g08.png,32,32,1,,0x2f31c08e
|
||||
pngsuite/unused/f03n2c08.png,32,32,3,,0x843ecc7e
|
||||
pngsuite/unused/f04n0g08.png,32,32,1,,0xfd3a0b73
|
||||
pngsuite/unused/f04n2c08.png,32,32,3,,0x557174bc
|
||||
pngsuite/unused/f99n0g04.png,32,32,1,,0xb79aa6e1
|
||||
pngsuite/unused/g03n0g16.png,32,32,1,,0xecd13817
|
||||
pngsuite/unused/g03n2c08.png,32,32,3,,0x242407a8
|
||||
pngsuite/unused/g03n3p04.png,32,32,3,,0xe801ecc8
|
||||
pngsuite/unused/g04n0g16.png,32,32,1,,0xc11bc972
|
||||
pngsuite/unused/g04n2c08.png,32,32,3,,0xdf843cc4
|
||||
pngsuite/unused/g04n3p04.png,32,32,3,,0x60e41f3b
|
||||
pngsuite/unused/g05n0g16.png,32,32,1,,0xbe6615a5
|
||||
pngsuite/unused/g05n2c08.png,32,32,3,,0x5c312116
|
||||
pngsuite/unused/g05n3p04.png,32,32,3,,0x2e0fbf86
|
||||
pngsuite/unused/g07n0g16.png,32,32,1,,0x2b54a398
|
||||
pngsuite/unused/g07n2c08.png,32,32,3,,0xf765fb10
|
||||
pngsuite/unused/g07n3p04.png,32,32,3,,0x9a8c3338
|
||||
pngsuite/unused/g10n0g16.png,32,32,1,,0xb08a92e1
|
||||
pngsuite/unused/g10n2c08.png,32,32,3,,0xa43f2291
|
||||
pngsuite/unused/g10n3p04.png,32,32,3,,0xb733194c
|
||||
pngsuite/unused/g25n0g16.png,32,32,1,,0xa6b1f5dd
|
||||
pngsuite/unused/g25n2c08.png,32,32,3,,0x767aee0c
|
||||
pngsuite/unused/g25n3p04.png,32,32,3,,0x4cf349a8
|
||||
pngsuite/unused/pp0n2c16.png,32,32,3,,0x65567ed5
|
||||
pngsuite/unused/pp0n6a08.png,32,32,4,,0x3188c645
|
||||
pngsuite/unused/ps1n0g08.png,32,32,1,,0x414f1ca9
|
||||
pngsuite/unused/ps1n2c16.png,32,32,3,,0x65567ed5
|
||||
pngsuite/unused/ps2n0g08.png,32,32,1,,0x414f1ca9
|
||||
pngsuite/unused/ps2n2c16.png,32,32,3,,0x65567ed5
|
|
@ -64,7 +64,7 @@ void stbir_progress(float p)
|
||||
#define STBIR_PROGRESS_REPORT stbir_progress
|
||||
#define STB_IMAGE_RESIZE_IMPLEMENTATION
|
||||
#define STB_IMAGE_RESIZE_STATIC
|
||||
#include "stb_image_resize.h"
|
||||
#include "stb_image_resize2.h"
|
||||
|
||||
#define STB_IMAGE_WRITE_IMPLEMENTATION
|
||||
#include "stb_image_write.h"
|
||||
@ -143,7 +143,7 @@ void resizer(int argc, char **argv)
|
||||
out_h = h*3;
|
||||
output_pixels = (unsigned char*) malloc(out_w*out_h*n);
|
||||
//stbir_resize_uint8_srgb(input_pixels, w, h, 0, output_pixels, out_w, out_h, 0, n, -1,0);
|
||||
stbir_resize_uint8(input_pixels, w, h, 0, output_pixels, out_w, out_h, 0, n);
|
||||
stbir_resize_uint8_linear(input_pixels, w, h, 0, output_pixels, out_w, out_h, 0, (stbir_pixel_layout) n);
|
||||
stbi_write_png("output.png", out_w, out_h, n, output_pixels, 0);
|
||||
exit(0);
|
||||
}
|
||||
@ -171,9 +171,9 @@ void performance(int argc, char **argv)
|
||||
output_pixels = (unsigned char*) malloc(out_w*out_h*n);
|
||||
for (i=0; i < count; ++i)
|
||||
if (srgb)
|
||||
stbir_resize_uint8_srgb(input_pixels, w, h, 0, output_pixels, out_w, out_h, 0, n,-1,0);
|
||||
stbir_resize_uint8_srgb(input_pixels, w, h, 0, output_pixels, out_w, out_h, 0, (stbir_pixel_layout) n);
|
||||
else
|
||||
stbir_resize(input_pixels, w, h, 0, output_pixels, out_w, out_h, 0, STBIR_TYPE_UINT8, n,-1, 0, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_FILTER_DEFAULT, STBIR_FILTER_DEFAULT, STBIR_COLORSPACE_LINEAR, NULL);
|
||||
stbir_resize_uint8_linear(input_pixels, w, h, 0, output_pixels, out_w, out_h, 0, (stbir_pixel_layout) n);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
@ -188,6 +188,7 @@ int main(int argc, char** argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
void resize_image(const char* filename, float width_percent, float height_percent, stbir_filter filter, stbir_edge edge, stbir_colorspace colorspace, const char* output_filename)
|
||||
{
|
||||
int w, h, n;
|
||||
@ -1120,3 +1121,7 @@ void test_suite(int argc, char **argv)
|
||||
resize_image("gamma_2.2.jpg", .5f, .5f, STBIR_FILTER_CATMULLROM, STBIR_EDGE_REFLECT, STBIR_COLORSPACE_SRGB, "test-output/gamma_2.2.jpg");
|
||||
resize_image("gamma_dalai_lama_gray.jpg", .5f, .5f, STBIR_FILTER_CATMULLROM, STBIR_EDGE_REFLECT, STBIR_COLORSPACE_SRGB, "test-output/gamma_dalai_lama_gray.jpg");
|
||||
}
|
||||
#endif
|
||||
void test_suite(int argc, char **argv)
|
||||
{
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ SOURCE=.\resample_test.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\stb_image_resize.h
|
||||
SOURCE=..\stb_image_resize2.h
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
|
@ -66,7 +66,7 @@ LINK32=link.exe
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /GX /Zi /Od /I ".." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "DS_TEST" /FR /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /GX /Zi /Od /I ".." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "TT_TEST" /FR /FD /GZ /c
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
@ -130,7 +130,7 @@ SOURCE=..\stb_image.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\stb_image_resize.h
|
||||
SOURCE=..\stb_image_resize2.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@ -154,14 +154,6 @@ SOURCE=..\stb_perlin.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\stb_pg.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\stb_query.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\stb_rect_pack.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
@ -1,3 +1,6 @@
|
||||
#define STB_IMAGE_RESIZE_IMPLEMENTATION
|
||||
#include "stb_image_resize2.h"
|
||||
|
||||
#define STB_SPRINTF_IMPLEMENTATION
|
||||
#include "stb_sprintf.h"
|
||||
|
||||
@ -7,7 +10,6 @@
|
||||
#define STB_DIVIDE_IMPLEMENTATION
|
||||
#define STB_IMAGE_IMPLEMENTATION
|
||||
#define STB_HERRINGBONE_WANG_TILE_IMEPLEMENTATIOn
|
||||
#define STB_IMAGE_RESIZE_IMPLEMENTATION
|
||||
#define STB_RECT_PACK_IMPLEMENTATION
|
||||
#define STB_VOXEL_RENDER_IMPLEMENTATION
|
||||
#define STB_EASY_FONT_IMPLEMENTATION
|
||||
@ -20,7 +22,6 @@
|
||||
#include "stb_perlin.h"
|
||||
#include "stb_c_lexer.h"
|
||||
#include "stb_divide.h"
|
||||
#include "stb_image_resize.h"
|
||||
#include "stb_rect_pack.h"
|
||||
#include "stb_dxt.h"
|
||||
#include "stb_include.h"
|
||||
|
@ -1 +1,50 @@
|
||||
#include "stb_c_lexer.h"
|
||||
#include "stb_c_lexer.h"
|
||||
|
||||
#define STB_C_LEX_C_DECIMAL_INTS Y // "0|[1-9][0-9]*" CLEX_intlit
|
||||
#define STB_C_LEX_C_HEX_INTS Y // "0x[0-9a-fA-F]+" CLEX_intlit
|
||||
#define STB_C_LEX_C_OCTAL_INTS Y // "[0-7]+" CLEX_intlit
|
||||
#define STB_C_LEX_C_DECIMAL_FLOATS Y // "[0-9]*(.[0-9]*([eE][-+]?[0-9]+)?) CLEX_floatlit
|
||||
#define STB_C_LEX_C99_HEX_FLOATS N // "0x{hex}+(.{hex}*)?[pP][-+]?{hex}+ CLEX_floatlit
|
||||
#define STB_C_LEX_C_IDENTIFIERS Y // "[_a-zA-Z][_a-zA-Z0-9]*" CLEX_id
|
||||
#define STB_C_LEX_C_DQ_STRINGS Y // double-quote-delimited strings with escapes CLEX_dqstring
|
||||
#define STB_C_LEX_C_SQ_STRINGS N // single-quote-delimited strings with escapes CLEX_ssstring
|
||||
#define STB_C_LEX_C_CHARS Y // single-quote-delimited character with escape CLEX_charlits
|
||||
#define STB_C_LEX_C_COMMENTS Y // "/* comment */"
|
||||
#define STB_C_LEX_CPP_COMMENTS Y // "// comment to end of line\n"
|
||||
#define STB_C_LEX_C_COMPARISONS Y // "==" CLEX_eq "!=" CLEX_noteq "<=" CLEX_lesseq ">=" CLEX_greatereq
|
||||
#define STB_C_LEX_C_LOGICAL Y // "&&" CLEX_andand "||" CLEX_oror
|
||||
#define STB_C_LEX_C_SHIFTS Y // "<<" CLEX_shl ">>" CLEX_shr
|
||||
#define STB_C_LEX_C_INCREMENTS Y // "++" CLEX_plusplus "--" CLEX_minusminus
|
||||
#define STB_C_LEX_C_ARROW Y // "->" CLEX_arrow
|
||||
#define STB_C_LEX_EQUAL_ARROW N // "=>" CLEX_eqarrow
|
||||
#define STB_C_LEX_C_BITWISEEQ Y // "&=" CLEX_andeq "|=" CLEX_oreq "^=" CLEX_xoreq
|
||||
#define STB_C_LEX_C_ARITHEQ Y // "+=" CLEX_pluseq "-=" CLEX_minuseq
|
||||
// "*=" CLEX_muleq "/=" CLEX_diveq "%=" CLEX_modeq
|
||||
// if both STB_C_LEX_SHIFTS & STB_C_LEX_ARITHEQ:
|
||||
// "<<=" CLEX_shleq ">>=" CLEX_shreq
|
||||
|
||||
#define STB_C_LEX_PARSE_SUFFIXES N // letters after numbers are parsed as part of those numbers, and must be in suffix list below
|
||||
#define STB_C_LEX_DECIMAL_SUFFIXES "" // decimal integer suffixes e.g. "uUlL" -- these are returned as-is in string storage
|
||||
#define STB_C_LEX_HEX_SUFFIXES "" // e.g. "uUlL"
|
||||
#define STB_C_LEX_OCTAL_SUFFIXES "" // e.g. "uUlL"
|
||||
#define STB_C_LEX_FLOAT_SUFFIXES "" //
|
||||
|
||||
#define STB_C_LEX_0_IS_EOF Y // if Y, ends parsing at '\0'; if N, returns '\0' as token
|
||||
#define STB_C_LEX_INTEGERS_AS_DOUBLES N // parses integers as doubles so they can be larger than 'int', but only if STB_C_LEX_STDLIB==N
|
||||
#define STB_C_LEX_MULTILINE_DSTRINGS N // allow newlines in double-quoted strings
|
||||
#define STB_C_LEX_MULTILINE_SSTRINGS N // allow newlines in single-quoted strings
|
||||
#define STB_C_LEX_USE_STDLIB Y // use strtod,strtol for parsing #s; otherwise inaccurate hack
|
||||
#define STB_C_LEX_DOLLAR_IDENTIFIER Y // allow $ as an identifier character
|
||||
#define STB_C_LEX_FLOAT_NO_DECIMAL Y // allow floats that have no decimal point if they have an exponent
|
||||
|
||||
#define STB_C_LEX_DEFINE_ALL_TOKEN_NAMES N // if Y, all CLEX_ token names are defined, even if never returned
|
||||
// leaving it as N should help you catch config bugs
|
||||
|
||||
#define STB_C_LEX_DISCARD_PREPROCESSOR Y // discard C-preprocessor directives (e.g. after prepocess
|
||||
// still have #line, #pragma, etc)
|
||||
|
||||
//#define STB_C_LEX_ISWHITE(str) ... // return length in bytes of whitespace characters if first char is whitespace
|
||||
|
||||
#define STB_C_LEXER_DEFINITIONS // This line prevents the header file from replacing your definitions
|
||||
|
||||
#include "stb_c_lexer.h"
|
||||
|
@ -5,9 +5,9 @@
|
||||
#include "stb_rect_pack.h"
|
||||
#include "stb_truetype.h"
|
||||
#include "stb_image_write.h"
|
||||
#include "stb_c_lexer.h"
|
||||
#include "stb_perlin.h"
|
||||
#include "stb_dxt.h"
|
||||
#include "stb_c_lexer.h"
|
||||
#include "stb_divide.h"
|
||||
#include "stb_herringbone_wang_tile.h"
|
||||
#include "stb_ds.h"
|
||||
@ -47,7 +47,6 @@ void my_free(void *) { }
|
||||
#include "stb_image_write.h"
|
||||
#include "stb_perlin.h"
|
||||
#include "stb_dxt.h"
|
||||
#include "stb_c_lexer.h"
|
||||
#include "stb_divide.h"
|
||||
#include "stb_herringbone_wang_tile.h"
|
||||
#include "stb_ds.h"
|
||||
@ -71,7 +70,7 @@ void my_free(void *) { }
|
||||
#include "stb_leakcheck.h"
|
||||
|
||||
#define STB_IMAGE_RESIZE_IMPLEMENTATION
|
||||
#include "stb_image_resize.h"
|
||||
#include "stb_image_resize2.h"
|
||||
|
||||
//#include "stretchy_buffer.h" // deprecating
|
||||
|
||||
@ -183,3 +182,5 @@ void dummy3(void)
|
||||
stb_textedit_initialize_state(0,0);
|
||||
stb_textedit_paste(0,0,0,0);
|
||||
}
|
||||
|
||||
#include "stb_c_lexer.h"
|
||||
|
47
tests/test_png_paeth.c
Normal file
47
tests/test_png_paeth.c
Normal file
@ -0,0 +1,47 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
// Reference Paeth filter as per PNG spec
|
||||
static int ref_paeth(int a, int b, int c)
|
||||
{
|
||||
int p = a + b - c;
|
||||
int pa = abs(p-a);
|
||||
int pb = abs(p-b);
|
||||
int pc = abs(p-c);
|
||||
if (pa <= pb && pa <= pc) return a;
|
||||
if (pb <= pc) return b;
|
||||
return c;
|
||||
}
|
||||
|
||||
// Optimized Paeth filter
|
||||
static int opt_paeth(int a, int b, int c)
|
||||
{
|
||||
int thresh = c*3 - (a + b);
|
||||
int lo = a < b ? a : b;
|
||||
int hi = a < b ? b : a;
|
||||
int t0 = (hi <= thresh) ? lo : c;
|
||||
int t1 = (thresh <= lo) ? hi : t0;
|
||||
return t1;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
// Exhaustively test the functions match for all byte inputs a, b,c in [0,255]
|
||||
for (int i = 0; i < (1 << 24); ++i) {
|
||||
int a = i & 0xff;
|
||||
int b = (i >> 8) & 0xff;
|
||||
int c = (i >> 16) & 0xff;
|
||||
|
||||
int ref = ref_paeth(a, b, c);
|
||||
int opt = opt_paeth(a, b, c);
|
||||
if (ref != opt) {
|
||||
fprintf(stderr, "mismatch at a=%3d b=%3d c=%3d: ref=%3d opt=%3d\n", a, b, c, ref, opt);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
printf("all ok!\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// vim:sw=3:sts=3:et
|
75
tests/test_png_regress.c
Normal file
75
tests/test_png_regress.c
Normal file
@ -0,0 +1,75 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define STBI_WINDOWS_UTF8
|
||||
|
||||
#ifdef _WIN32
|
||||
#define WIN32 // what stb.h checks
|
||||
#pragma comment(lib, "advapi32.lib")
|
||||
#endif
|
||||
|
||||
#define STB_IMAGE_IMPLEMENTATION
|
||||
#include "stb_image.h"
|
||||
|
||||
#define STB_DEFINE
|
||||
#include "deprecated/stb.h"
|
||||
|
||||
static unsigned int fnv1a_hash32(const stbi_uc *bytes, size_t len)
|
||||
{
|
||||
unsigned int hash = 0x811c9dc5;
|
||||
unsigned int mul = 0x01000193;
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < len; ++i)
|
||||
hash = (hash ^ bytes[i]) * mul;
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
// The idea for this test is to leave pngsuite/ref_results.csv checked in,
|
||||
// and then you can run this test after making PNG loader changes. If the
|
||||
// ref results change (as per git diff), confirm that the change was
|
||||
// intentional. If so, commit them as well; if not, undo.
|
||||
int main()
|
||||
{
|
||||
char **files;
|
||||
FILE *csv_file;
|
||||
int i;
|
||||
|
||||
files = stb_readdir_recursive("pngsuite", "*.png");
|
||||
if (!files) {
|
||||
fprintf(stderr, "pngsuite files not found!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// sort files by name
|
||||
qsort(files, stb_arr_len(files), sizeof(char*), stb_qsort_strcmp(0));
|
||||
|
||||
csv_file = fopen("pngsuite/ref_results.csv", "w");
|
||||
if (!csv_file) {
|
||||
fprintf(stderr, "error opening ref results for writing!\n");
|
||||
stb_readdir_free(files);
|
||||
return 1;
|
||||
}
|
||||
|
||||
fprintf(csv_file, "filename,width,height,ncomp,error,hash\n");
|
||||
for (i = 0; i < stb_arr_len(files); ++i) {
|
||||
char *filename = files[i];
|
||||
int width, height, ncomp;
|
||||
stbi_uc *pixels = stbi_load(filename, &width, &height, &ncomp, 0);
|
||||
const char *error = "";
|
||||
unsigned int hash = 0;
|
||||
|
||||
if (!pixels)
|
||||
error = stbi_failure_reason();
|
||||
else {
|
||||
hash = fnv1a_hash32(pixels, width * height * ncomp);
|
||||
stbi_image_free(pixels);
|
||||
}
|
||||
|
||||
fprintf(csv_file, "%s,%d,%d,%d,%s,0x%08x\n", filename, width, height, ncomp, error, hash);
|
||||
}
|
||||
|
||||
fclose(csv_file);
|
||||
stb_readdir_free(files);
|
||||
}
|
@ -37,14 +37,37 @@ int main(int argc, char **argv)
|
||||
{
|
||||
stbtt_fontinfo font;
|
||||
unsigned char *bitmap;
|
||||
int w,h,i,j,c = (argc > 1 ? atoi(argv[1]) : 34807), s = (argc > 2 ? atoi(argv[2]) : 32);
|
||||
int w,h,i,j,c = (argc > 1 ? atoi(argv[1]) : '@'), s = (argc > 2 ? atoi(argv[2]) : 32);
|
||||
|
||||
//debug();
|
||||
|
||||
// @TODO: why is minglui.ttc failing?
|
||||
fread(ttf_buffer, 1, 1<<25, fopen(argc > 3 ? argv[3] : "c:/windows/fonts/mingliu.ttc", "rb"));
|
||||
//fread(ttf_buffer, 1, 1<<25, fopen(argc > 3 ? argv[3] : "c:/windows/fonts/mingliu.ttc", "rb"));
|
||||
|
||||
//fread(ttf_buffer, 1, 1<<25, fopen(argc > 3 ? argv[3] : "c:/x/DroidSansMono.ttf", "rb"));
|
||||
fread(ttf_buffer, 1, 1<<25, fopen(argc > 3 ? argv[3] : "c:/windows/fonts/DejaVuSans.ttf", "rb"));
|
||||
|
||||
stbtt_InitFont(&font, ttf_buffer, stbtt_GetFontOffsetForIndex(ttf_buffer,0));
|
||||
|
||||
#if 0
|
||||
{
|
||||
stbtt__bitmap b;
|
||||
stbtt__point p[2];
|
||||
int wcount[2] = { 2,0 };
|
||||
p[0].x = 0.2f;
|
||||
p[0].y = 0.3f;
|
||||
p[1].x = 3.8f;
|
||||
p[1].y = 0.8f;
|
||||
b.w = 16;
|
||||
b.h = 2;
|
||||
b.stride = 16;
|
||||
b.pixels = malloc(b.w*b.h);
|
||||
stbtt__rasterize(&b, p, wcount, 1, 1, 1, 0, 0, 0, 0, 0, NULL);
|
||||
for (i=0; i < 8; ++i)
|
||||
printf("%f\n", b.pixels[i]/255.0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
{
|
||||
static stbtt_pack_context pc;
|
||||
static stbtt_packedchar cd[256];
|
||||
@ -54,6 +77,25 @@ int main(int argc, char **argv)
|
||||
stbtt_PackFontRange(&pc, ttf_buffer, 0, 32.0, 0, 256, cd);
|
||||
stbtt_PackEnd(&pc);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if 1
|
||||
{
|
||||
static stbtt_pack_context pc;
|
||||
static stbtt_packedchar cd[256];
|
||||
static unsigned char atlas[1024*1024];
|
||||
unsigned char *data;
|
||||
|
||||
data = stbtt_GetCodepointSDF(&font, stbtt_ScaleForPixelHeight(&font,32.0), 'u', 4, 128, 128/4, &w,&h,&i,&j);
|
||||
for (j=0; j < h; ++j) {
|
||||
for (i=0; i < w; ++i) {
|
||||
putchar(" .:ioVM@"[data[j*w+i]>>5]);
|
||||
}
|
||||
putchar('\n');
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
stbtt_BakeFontBitmap(ttf_buffer,stbtt_GetFontOffsetForIndex(ttf_buffer,0), 40.0, temp_bitmap[0],BITMAP_W,BITMAP_H, 32,96, cdata); // no guarantee this fits!
|
||||
@ -92,9 +134,16 @@ int main(int argc, char **argv)
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
stbtt_InitFont(&font, ttf_buffer, stbtt_GetFontOffsetForIndex(ttf_buffer,0));
|
||||
bitmap = stbtt_GetCodepointBitmap(&font, 0,stbtt_ScaleForPixelHeight(&font, (float)s), c, &w, &h, 0,0);
|
||||
(void)stbtt_GetCodepointBitmapSubpixel(&font,
|
||||
0.4972374737262726f,
|
||||
0.4986416995525360f,
|
||||
0.2391788959503174f,
|
||||
0.1752119064331055f,
|
||||
'd',
|
||||
&w, &h,
|
||||
0,0);
|
||||
|
||||
bitmap = stbtt_GetCodepointBitmap(&font, 0,stbtt_ScaleForPixelHeight(&font, (float)s), c, &w, &h, 0,0);
|
||||
for (j=0; j < h; ++j) {
|
||||
for (i=0; i < w; ++i)
|
||||
putchar(" .:ioVM@"[bitmap[j*w+i]>>5]);
|
||||
|
184
tests/truetype_test_win32.c
Normal file
184
tests/truetype_test_win32.c
Normal file
@ -0,0 +1,184 @@
|
||||
// tested in VC6 (1998) and VS 2019
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#define WIN32_MEAN_AND_LEAN
|
||||
#include <windows.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <tchar.h>
|
||||
|
||||
#define STB_TRUETYPE_IMPLEMENTATION
|
||||
#include "stb_truetype.h"
|
||||
|
||||
#include <gl/gl.h>
|
||||
#include <gl/glu.h>
|
||||
|
||||
int screen_x=1024, screen_y=768;
|
||||
GLuint tex;
|
||||
|
||||
unsigned char ttf_buffer[1<<20];
|
||||
unsigned char temp_bitmap[1024*1024];
|
||||
stbtt_bakedchar cdata[96]; // ASCII 32..126 is 95 glyphs
|
||||
|
||||
void init(void)
|
||||
{
|
||||
fread(ttf_buffer, 1, 1<<20, fopen("c:/windows/fonts/times.ttf", "rb"));
|
||||
stbtt_BakeFontBitmap(ttf_buffer,0, 64.0, temp_bitmap,1024,1024, 32,96, cdata);
|
||||
glGenTextures(1, &tex);
|
||||
glBindTexture(GL_TEXTURE_2D, tex);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, 1024,1024,0, GL_ALPHA, GL_UNSIGNED_BYTE, temp_bitmap);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
}
|
||||
|
||||
void print(float x, float y, char *text)
|
||||
{
|
||||
// assume orthographic projection with units = screen pixels, origin at top left
|
||||
glBindTexture(GL_TEXTURE_2D, tex);
|
||||
glBegin(GL_QUADS);
|
||||
while (*text) {
|
||||
if (*text >= 32 && *text < 128) {
|
||||
stbtt_aligned_quad q;
|
||||
stbtt_GetBakedQuad(cdata, 1024,1024, *text-32, &x,&y,&q,1);//1=opengl & d3d10+,0=d3d9
|
||||
glTexCoord2f(q.s0,q.t0); glVertex2f(q.x0,q.y0);
|
||||
glTexCoord2f(q.s1,q.t0); glVertex2f(q.x1,q.y0);
|
||||
glTexCoord2f(q.s1,q.t1); glVertex2f(q.x1,q.y1);
|
||||
glTexCoord2f(q.s0,q.t1); glVertex2f(q.x0,q.y1);
|
||||
}
|
||||
++text;
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
|
||||
void draw(void)
|
||||
{
|
||||
glViewport(0,0,screen_x,screen_y);
|
||||
glClearColor(0.45f,0.45f,0.75f,0);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glDisable(GL_CULL_FACE);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(0,screen_x,screen_y,0,-1,1);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glColor3f(1,1,1);
|
||||
|
||||
print(100,150, "This is a simple test!");
|
||||
|
||||
// show font bitmap
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0,0); glVertex2f(256,200+0);
|
||||
glTexCoord2f(1,0); glVertex2f(768,200+0);
|
||||
glTexCoord2f(1,1); glVertex2f(768,200+512);
|
||||
glTexCoord2f(0,1); glVertex2f(256,200+512);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
///
|
||||
///
|
||||
/// Windows OpenGL setup
|
||||
///
|
||||
///
|
||||
|
||||
HINSTANCE app;
|
||||
HWND window;
|
||||
HGLRC rc;
|
||||
HDC dc;
|
||||
|
||||
#pragma comment(lib, "opengl32.lib")
|
||||
#pragma comment(lib, "glu32.lib")
|
||||
#pragma comment(lib, "winmm.lib")
|
||||
|
||||
int mySetPixelFormat(HWND win)
|
||||
{
|
||||
PIXELFORMATDESCRIPTOR pfd = { sizeof(pfd), 1, PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW | PFD_DOUBLEBUFFER, PFD_TYPE_RGBA };
|
||||
int pixel_format;
|
||||
pfd.dwLayerMask = PFD_MAIN_PLANE;
|
||||
pfd.cColorBits = 24;
|
||||
pfd.cAlphaBits = 8;
|
||||
pfd.cDepthBits = 24;
|
||||
pfd.cStencilBits = 8;
|
||||
pixel_format = ChoosePixelFormat(dc, &pfd);
|
||||
if (!pixel_format) return FALSE;
|
||||
if (!DescribePixelFormat(dc, pixel_format, sizeof(PIXELFORMATDESCRIPTOR), &pfd))
|
||||
return FALSE;
|
||||
SetPixelFormat(dc, pixel_format, &pfd);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static int WINAPI WinProc(HWND wnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
||||
{
|
||||
switch (msg) {
|
||||
case WM_CREATE: {
|
||||
LPCREATESTRUCT lpcs = (LPCREATESTRUCT) lparam;
|
||||
dc = GetDC(wnd);
|
||||
if (mySetPixelFormat(wnd)) {
|
||||
rc = wglCreateContext(dc);
|
||||
if (rc) {
|
||||
wglMakeCurrent(dc, rc);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
case WM_DESTROY:
|
||||
wglMakeCurrent(NULL, NULL);
|
||||
if (rc) wglDeleteContext(rc);
|
||||
PostQuitMessage (0);
|
||||
return 0;
|
||||
|
||||
default:
|
||||
return DefWindowProc (wnd, msg, wparam, lparam);
|
||||
}
|
||||
|
||||
return DefWindowProc (wnd, msg, wparam, lparam);
|
||||
}
|
||||
|
||||
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
|
||||
{
|
||||
DWORD dwstyle = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX;
|
||||
WNDCLASSEX wndclass;
|
||||
wndclass.cbSize = sizeof(wndclass);
|
||||
wndclass.style = CS_OWNDC;
|
||||
wndclass.lpfnWndProc = (WNDPROC) WinProc;
|
||||
wndclass.cbClsExtra = 0;
|
||||
wndclass.cbWndExtra = 0;
|
||||
wndclass.hInstance = hInstance;
|
||||
wndclass.hIcon = LoadIcon(hInstance, _T("appicon"));
|
||||
wndclass.hCursor = LoadCursor(NULL,IDC_ARROW);
|
||||
wndclass.hbrBackground = GetStockObject(NULL_BRUSH);
|
||||
wndclass.lpszMenuName = _T("truetype-test");
|
||||
wndclass.lpszClassName = _T("truetype-test");
|
||||
wndclass.hIconSm = NULL;
|
||||
app = hInstance;
|
||||
|
||||
if (!RegisterClassEx(&wndclass))
|
||||
return 0;
|
||||
|
||||
window = CreateWindow(_T("truetype-test"), _T("truetype test"), dwstyle,
|
||||
CW_USEDEFAULT,0, screen_x, screen_y,
|
||||
NULL, NULL, app, NULL);
|
||||
ShowWindow(window, SW_SHOWNORMAL);
|
||||
init();
|
||||
|
||||
for(;;) {
|
||||
MSG msg;
|
||||
if (GetMessage(&msg, NULL, 0, 0)) {
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
} else {
|
||||
return 1; // WM_QUIT
|
||||
}
|
||||
wglMakeCurrent(dc, rc);
|
||||
draw();
|
||||
SwapBuffers(dc);
|
||||
}
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user